Exemple #1
0
        public void Show(ClientParty party, ClientTile tile)
        {
            if (party.Tile == tile || tile == null)
            {
                Hide();
                return;
            }
            var pos = Camera.main.WorldToScreenPoint(tile.GetGameObject().transform.position);

            _gameObject.transform.position = pos;
            _gameObject.SetActive(true);
            var actions = new List <EntityAction>();

            if (tile.StaticEntity is ClientDungeon)
            {
                actions.Add(EntityAction.CHECK);
                actions.Add(EntityAction.ATTACK);
            }
            else
            {
                actions.Add(EntityAction.MOVE);
            }
            actions.Add(EntityAction.GUARD);
            BuildActions(actions.ToArray());
        }
Exemple #2
0
        public void OnFinishedMove(ClientParty party, ClientTile oldTile, ClientTile newTile)
        {
            if (_partyPaths.ContainsKey(party))
            {
                var partyPath      = _partyPaths[party];
                var pathsOnTile    = partyPath.Pop(newTile);
                var pathsOnOldTile = partyPath.Pop(oldTile);
                if (pathsOnTile != null)
                {
                    foreach (var path in pathsOnTile)
                    {
                        path.SetActive(false);
                    }
                }
                if (pathsOnOldTile != null)
                {
                    foreach (var path in pathsOnOldTile)
                    {
                        path.SetActive(false);
                    }
                }

                if (partyPath.Empty())
                {
                    _partyPaths.Remove(party);
                }
            }
        }
Exemple #3
0
        protected virtual void HandleUpdatePartyAtClient(LiteNetLibMessageHandler messageHandler)
        {
            UpdatePartyMessage message = messageHandler.ReadMessage <UpdatePartyMessage>();

            if (message.type == UpdatePartyMessage.UpdateType.Create)
            {
                ClientParty = new PartyData(message.id, message.shareExp, message.shareItem, message.characterId);
            }
            else if (ClientParty != null && ClientParty.id == message.id)
            {
                switch (message.type)
                {
                case UpdatePartyMessage.UpdateType.ChangeLeader:
                    ClientParty.SetLeader(message.characterId);
                    break;

                case UpdatePartyMessage.UpdateType.Setting:
                    ClientParty.Setting(message.shareExp, message.shareItem);
                    break;

                case UpdatePartyMessage.UpdateType.Terminate:
                    ClientParty = null;
                    break;
                }
            }
            if (onClientUpdateParty != null)
            {
                onClientUpdateParty.Invoke(ClientParty);
            }
        }
Exemple #4
0
 public void StartMoveReq(ClientParty party, List <ClientTile> path)
 {
     if (IsActive(_tileCursor))
     {
         Inactivate(_tileCursor);
     }
     _selectedTile = null;
 }
Exemple #5
0
        private void MoveToSelectedTile(MovementIntent intent)
        {
            ClientParty party        = UIManager.PartyUI.SelectedParty;
            ClientTile  selectedTile = UIManager.TileUI.SelectedTile;

            Log.Debug($"Moving {party} to {selectedTile}");
            var map      = selectedTile.Chunk.Map;
            var path     = map.FindPath(party.Tile, selectedTile);
            var tilePath = path.Select(node => (ClientTile)map.GetTile(node.X, node.Y)).ToList();

            ClientEvents.StartMovementRequest(party, tilePath);
            MainBehaviour.Networking.Send(new MoveRequestEvent()
            {
                PartyIndex = party.PartyIndex,
                Path       = path.Select(p => new Game.World.Position(p.X, p.Y)).ToList(),
                Intent     = intent
            });
        }
Exemple #6
0
        public ClientPath RenderPath(ClientParty party, List <ClientTile> tilePath)
        {
            //tilePath.RemoveAt(0); // remove where the party is
            var clientPath = new ClientPath();

            _partyPaths[party] = clientPath;
            _pathlinesPool.ForEach(path => path.SetActive(false));
            for (var x = 0; x < tilePath.Count; x++)
            {
                var nodeTile    = tilePath[x];
                var tilePos     = nodeTile.GetGameObject().transform.position;
                var hasNext     = x < tilePath.Count - 1;
                var hasPrevious = x > 0;
                if (hasNext)
                {
                    var next      = tilePath[x + 1];
                    var direction = nodeTile.GetDirection(next);
                    if (direction == Direction.SOUTH)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.position = new Vector3(tilePos.x, tilePos.y + 0.1f, tilePos.z - 0.25f);
                    }
                    else if (direction == Direction.NORTH)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.position = new Vector3(tilePos.x, tilePos.y + 0.1f, tilePos.z + 0.25f);
                    }
                    else if (direction == Direction.EAST)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.Rotate(new Vector3(0, 90, 0), Space.Self);
                        line.transform.position = new Vector3(tilePos.x + 0.25f, tilePos.y + 0.1f, tilePos.z);
                    }
                    else if (direction == Direction.WEST)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.Rotate(new Vector3(0, 90, 0), Space.Self);
                        line.transform.position = new Vector3(tilePos.x - 0.25f, tilePos.y + 0.1f, tilePos.z);
                    }
                }
                if (hasPrevious)
                {
                    var previous  = tilePath[x - 1];
                    var direction = nodeTile.GetDirection(previous);
                    if (direction == Direction.NORTH)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.position = new Vector3(tilePos.x, tilePos.y + 0.1f, tilePos.z + 0.25f);
                    }
                    else if (direction == Direction.SOUTH)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.position = new Vector3(tilePos.x, tilePos.y + 0.1f, tilePos.z - 0.25f);
                    }
                    else if (direction == Direction.EAST)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.Rotate(new Vector3(0, 90, 0), Space.Self);
                        line.transform.position = new Vector3(tilePos.x + 0.25f, tilePos.y + 0.1f, tilePos.z);
                    }
                    else if (direction == Direction.WEST)
                    {
                        var line = GetOrCreatePathLine(nodeTile, clientPath);
                        line.transform.Rotate(new Vector3(0, 90, 0), Space.Self);
                        line.transform.position = new Vector3(tilePos.x - 0.25f, tilePos.y + 0.1f, tilePos.z);
                    }
                }
            }
            return(clientPath);
        }
Exemple #7
0
 public void StartReqMove(ClientParty party, List <ClientTile> path)
 {
     this.RenderPath(party, path);
 }
Exemple #8
0
 private void SelectParty(ClientParty party)
 {
     Activate(_partyCursor);
     MoveToTile(_partyCursor, party.Tile);
     _partyCursor.transform.SetParent(party.GetGameObject().transform);
 }
Exemple #9
0
 public static void ActionSelected(ClientParty p, ClientTile tile, EntityAction action)
 {
     OnActionSelected?.Invoke(p, tile, action);
 }
Exemple #10
0
 public static void StartMovementRequest(ClientParty p, List <ClientTile> path)
 {
     OnStartMovementRequest?.Invoke(p, path);
 }
Exemple #11
0
 public static void PartyFinishedMove(ClientParty p, ClientTile o, ClientTile n)
 {
     OnPartyFinishedMove?.Invoke(p, o, n);
 }
Exemple #12
0
 public static void SelectParty(ClientParty party)
 {
     OnSelectParty?.Invoke(party);
 }