Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kerozard

Pages: [1] 2
1
I have a bit of a tricky setup that I need a bit of help with.

I intend to run 3 applications with TNet3:
- Unity as a client
- A standalone application as lobby Server
- A standalone application as game server

I want to tie those together by having one common library that holds the game logic, the IBinarySerializable objects etc.

My challenge now is that I need TNet3 in all four VS projects. I would need the lobby and the game server to use a build with the "STANDALONE" compilation symbol and Unity to use the standard unity build. The common library could technically use either of those. With other libraries in this kind of setup, I used to add the source to the common library and the problem was solved by referencing those in the main project. But since there is conditional compilation involved and the common library is not supposed to have reference to parts of Unity or the server project, I am not sure how to proceed.

Can I solve this somehow? I don't want to start working with symlinks or nested folder structures referencing the same files since that leads to a world of hurt in case you need to refactor anything. My ideal scenario is having everything in a single place and using it from there.

2
TNet 3 Support / Is loading levels additively an issue?
« on: September 13, 2017, 09:05:25 AM »
So, we are now past the prototype phase and TNet did a wonderful job. I intend to use it for our live project as well. Great job!

What I am missing however is a way to load levels additively on all clients. Can this be done?
I assume just sending an RFC telling all clients to load the level will not do the trick when TNBehaviours are involved.

Thanks in advance.

Patrick

3
TNet 3 Support / Re: Enum Issue
« on: September 07, 2017, 08:55:14 AM »
I will see if I can build a tiny repro case once I am done with the prototype. At this point we are just trying out a few concepts and I made the shift from UNet to TNet about 2 days before the first testing session was scheduled. UNet was driving me crazy and I remembered TNet 2 fondly. So there was not a lot of time to read up on all the docs. I kinda threw things in and saw that it works. It is not supposed to be pretty right now. :-)

But I am grateful for your input and will keep that model in mind if we decide to go forward with the project and start implementing the final version.

4
TNet 3 Support / Re: Enum Issue
« on: September 07, 2017, 08:00:39 AM »
In that case, I feel that this information should at be added to the "Example 1 - RFCs.pdf". Silent bugs can be very dangerous. :-)

5
TNet 3 Support / Enum Issue
« on: September 07, 2017, 05:28:28 AM »
I am experiencing an issue with enums and I can't seem to pinpoint the cause.

My data flow is this
-> PlayerManager confirms a move (BattlePlan) for a unit
-> UnitController sends this BattlePlan to the MatchManager on the host
-> MatchManager sets an order index (and performs a few local calculations) and sends the final BattlePlan data back to the client
-> UnitController updates the BattlePlan with the new values

  1. public enum AbilityLocation : int
  2. {
  3.     Default = 0,
  4.     Hand = 1
  5. }
  6.  

PlayerManager:
  1. Unit.tno.Send("HostRfcSetBattlePlan", Target.Host, location, index, x, z);
  2.  

UnitController:
  1. [RFC]
  2. public void RfcSetBattlePlan(int orderIndex, AbilityLocation location, int index, int targetX, int targetZ)
  3. {
  4.     Debug.Log($"Client battle plan from {tno.uid}: {location} {index} {targetX} {targetZ} (Order Index: {orderIndex})");
  5.     var battlePlan = new BattlePlan(tno.uid, location, index, targetX, targetZ) { OrderIndex = orderIndex } ;
  6.  
  7.     Main.Match.UpdateBattlePlan(battlePlan);
  8. }
  9.  
  10. [RFC]
  11. public void HostRfcSetBattlePlan(AbilityLocation location, int index, int targetX, int targetZ)
  12. {
  13.     var battlePlan = new BattlePlan(tno.uid, location, index, targetX, targetZ);
  14.     Debug.Log($"New    battle plan from {tno.uid}: {battlePlan.Location} {battlePlan.Index} {battlePlan.TargetX} {battlePlan.TargetZ} (Order Index: {battlePlan.OrderIndex})");
  15.     Main.Match.HostUpdateBattlePlan(battlePlan);
  16. }
  17.  

MatchManager:
  1. public void HostUpdateBattlePlan(BattlePlan battlePlan)
  2. {
  3.     UpdateBattlePlan(battlePlan);
  4.     Debug.Log($"Host   battle plan from {battlePlan.Creator.tno.uid}: {battlePlan.Location} {battlePlan.Index} {battlePlan.TargetX} {battlePlan.TargetZ} (Order Index: {battlePlan.OrderIndex})");
  5.  
  6.     battlePlan.Creator.tno.Send("RfcSetBattlePlan", Target.AllSaved, battlePlan.OrderIndex, battlePlan.Location, battlePlan.Index, battlePlan.TargetX, battlePlan.TargetZ);
  7. }
  8.  

The debug output:
  1. New    battle plan from 16777214: Hand 0 1 1 (Order Index: -1)
  2. Host   battle plan from 16777214: Hand 0 1 1 (Order Index: 0) // (order index set by the host)
  3. Client battle plan from 16777214: Default 0 1 1 (Order Index: 0)
  4.  

So for some reason the enum value "Hand" reaches the server just fine, but turns into "Default" when it gets send back to the clients. If I, however, cast my enum to an integer when sending it to the clients and back to an enum on the client, it does work and the output becomes this:

  1. New    battle plan from 16777214: Hand 0 1 1 (Order Index: -1)
  2. Host   battle plan from 16777214: Hand 0 1 1 (Order Index: 0)
  3. Client battle plan from 16777214: Hand 0 1 1 (Order Index: 0)
  4.  

I don't understand why it would work in one direction and not the other. The fact that manual casts to int seem to fix the issue makes me think it might not be my code.

I'm happy for any input on the matter.

6
TNet 3 Support / Re: Clear persistant data.
« on: September 01, 2017, 06:54:55 AM »
Alright, please disregard this. It was my fault. I was instantiating the prefab in the RCC, but calling the method in which I set the instance values not on the instance, but on the prefab thus changing the prefab values which then persisted until the next start when a new instance was instantiated. :-(

7
TNet 3 Support / Bug in TNUPnP.cs (ParseResponse)
« on: September 01, 2017, 02:32:50 AM »
I have been getting this exception with V3.0.9 and decided to look into it a bit.

  1. UPnP: Cannot be negative.
  2. Parameter name: length
  3. UnityEngine.Debug:LogError(Object)
  4. TNet.UPnP:ThreadDiscover(Object) (at Assets/TNet/Common/TNUPnP.cs:193)
  5.  

It gets thrown when the baseUrl in ParseResponse is "http://192.168.0.12:9080". The issue is caused in line 227. The code is trying to find the first slash after the http:// and fails to accomodate for the case when there is none by subsequently calling
  1. mGatewayURL = baseURL.Substring(0, offset);
with an offset of -1.

I hope posting one line of proprietary source does not get me banned. :-P

8
TNet 3 Support / Clear persistant data.
« on: September 01, 2017, 12:04:25 AM »
I have only been playing with TNet3 for a few houra. I am trying to put together a quick prototype of a game.

I have the following steps in place:

1. Start the game in the Unity Editor
2. Enter Name and select a character class.
3. Start the server and connect to it.
  1. if (TNServerInstance.Start(TcpPort, UdpPort, null))
  2. {
  3.     TNManager.Connect();
  4. }
  5.  
4. When connected, join a channel.
  1. private void OnNetworkConnect(bool success, string message)
  2. {
  3.     if (success)
  4.     {
  5.         TNManager.JoinChannel(ChannelId, "Main", false, 4, "pw", true);
  6.     }
  7. }
  8.  
5. When the channel has been joined, create the player
  1. private void OnNetworkJoinChannel(int channelid, bool success, string message)
  2. {
  3.     if (success)
  4.     {
  5.         Main.Unit.CreatePlayer();
  6.     }
  7. }
  8.  
In the Unit Manager
  1. public void CreatePlayer()
  2. {
  3.     var prefabPath = Main.Player.PlayerType.ToString();
  4.     TNManager.Instantiate(TnetManager.ChannelId, "CreateCharacterModel", prefabPath, false, Vector3.zero, Main.Player.PlayerName);
  5. }
  6.  
  7. [RCC][UsedImplicitly]
  8. static GameObject CreateCharacterModel(GameObject prefab, Vector3 position, string playerName)
  9. {
  10.     var go = prefab.Instantiate();
  11.     var controller = prefab.GetComponent<UnitController>();
  12.  
  13.     controller.SetCharacter(playerName, controller.Type, position);
  14.     return go;
  15. }
  16.  

So far so good, the prefab gets spawned and placed into the scene on all connected clients. Through added debug output I can also see that the name is set correctly. But when I name my character "Michael", then stop the Unity player, restart it, then name myself "Patrick", I can see the name "Patrick" set correctly, but it is then being overwritten with "Michael", the name I entered the last time I started a match. This leads me to believe that this is a persistence issue. My values get overwritten by values from the last session.

How do I make sure to have a clean start each time I start the player?

9
It looks like the DataNode.cs and TNSerializer.cs got moved from the Client folder to the common folder. Removing the old version from the client folder fixed it for me.

10
NGUI 3 Support / Re: UISprite FillAmount with Offset
« on: August 12, 2014, 12:29:11 PM »
I really need to get out of my old thinking patterns from when our game was based on HTML5/Canvas. Thank you.

My rudimentary Photoshop skills were enough to pull this off and I got the desired effect. ;-)

Thank you very much.

11
NGUI 3 Support / Re: UISprite FillAmount with Offset
« on: August 11, 2014, 12:30:48 AM »
Sadly it is not just repeating. There is a fade effect to the left/right and the sprite is also cropped on the sides to make it fit. The situation might become more apparent when you look at the power bar on the slot graphic I've added. That one goes from a darker orange to a lighter orange and also gets smaller on the sides. I have to do the same thing there.



I also think there would be some alignment issues with a tiled sprite when I put them next to each other. The left bar would always have to be (int) x times its size so the right bar would fit perfectly. Otherwise there would be weird overlaps. I realize this is probably barely noticable. Still I would rather have a solution that allows me to display exact values, not rounded ones.

12
NGUI 3 Support / [Solved] UISprite FillAmount with Offset
« on: August 10, 2014, 04:07:36 PM »
Hello again!

I have been using the filled UISprite with fillAmount to great success when displaying health and progress bars. Now my UX guy has requested that I display anticipated damage. I think the mockup makes it pretty clear. I need to create one basic UISprite with a fillAmount and another one that shows how much energy/life/capacity is gained/lost.



Right now there are two not so desirable ways to do it:

1. Just move the anticipation bar far enough to the right and display the small portion that is needed. This would work with other graphics, but in my case the small tilted bars just won't align.

2. Place the red bar behind the blue one. That just does not look good since the red shimmers through where there is transparency (as is visible in the screenshot).

So I am at a place where I need to place my two progressbars and then set some sort of fillAmount(float from, float to) with the blue one going using e.g. fillAmount(0f, 0.5f); and the red one fillAmount(0.5f, 0.6f);

Is there a tool available in the great product that is NGUI or do I have to come up with something myself?

Thanks in advance,

Patrick

13
NGUI 3 Support / Re: How to catch a click outside of a collider?
« on: August 07, 2014, 04:27:28 AM »
I was just composing a reply that this was the solution I came up with by scouring your forum.  ;)

But thank you for your timely response. The only thing I don't like about it is, that I set the EventListener when the user clicks on the filter button. But since the button itself is not part of the filter window hierarchy, it gets hidden again right away. I am now invoking the listener with a 0.1 second delay and I don't feel that is a very elegant solution.

14
NGUI 3 Support / [Solved] How to catch a click outside of a collider?
« on: August 07, 2014, 02:54:52 AM »
I am trying to create some kind of a tabbed display (the filter window in the screenshot). I want to hide it if the user clicks somewhere outside the filter window so i tried using

  1.    
  2. void OnSelect(bool isSelected)
  3.     {
  4.         if (!isSelected)
  5.         {
  6.             Manager.View.FadeOut(this.gameObject, 0.2f);
  7.         }
  8.     }
  9.  

The problem are the child elements that also have colliders. clicking on one of them sends an OnSelect(false) to the window itself and it gets hidden. I don't really want to go down the route of keeping track of all the window states and comparing them to mouse positions. there has to be an easier way. I was thinking about using UICamera.fallThrough but that way I could only hide it when the click event is not caught by any other object.

Any ideas how to get the desired functionality?


15
NGUI 3 Support / Re: Placing prefab on different panel
« on: August 05, 2014, 06:11:27 AM »
Hey rain,

thank you for your reply. The layers did not match, so I wrote an GameObject extension method to set the layer recursively and the warnings were gone.

For anyone interested, this is the extension method. No magic at all, but some people like copy&paste examples.

  1. public static void SetLayerRecursively(this GameObject go, int layerNumber)
  2. {
  3.     foreach (Transform trans in go.GetComponentsInChildren<Transform>(true))
  4.     {
  5.         trans.gameObject.layer = layerNumber;
  6.     }
  7. }
  8.  

And this is how I used it.

  1. public GameObject CreateAt(GameObject target, string cardId)
  2. {
  3.     GameObject prefab = (GameObject)Resources.Load("Prefabs/CardDisplay");
  4.     prefab.SetLayerRecursively(target.layer);
  5.     GameObject CardInstance = NGUITools.AddChild(target, prefab);
  6.     return CardInstance;
  7. }
  8.  

Thank you again for your help. :-)

Patrick

Pages: [1] 2