Esempio n. 1
0
    private void EventSink_UnitAttackEvent(UnitAttackEventArgs args)
    {
        List <GamePiece> targets = new List <GamePiece>();

        foreach (GameBoardTile tile in m_GameBoardRelative.CurrentlySelectedTiles)
        {
            if (tile.OccupyingPiece != null)
            {
                targets.Add(tile.OccupyingPiece);
                Debug.LogFormat("Tile Occupant ({0}): {1}",
                                tile.BoardVector, tile.OccupyingPiece.gameObject.name);
            }
        }

        if (m_CurrentFocusPiece.TestMode)
        {
            m_GameBoardRelative.ClearCurrentSelections();
            m_CurrentFocusPiece.FinalizeAttack(targets.ToArray(), args.Tile);
        }

        else if (m_CurrentFocusPiece.UnderLocalControl)
        {
            ClientManager.Instance.SendAttackTargetSyncCommand
                (MatchHandler.CurrentMatch.MatchIdentity, m_CurrentFocusPiece.NetworkIdentity,
                m_CurrentFocusPiece.AttackRating, targets.ToArray(), args.Tile.BoardVector);
        }

        if (m_CurrentFocusPiece.TestMode)
        {
            TurnStateHandler.FinishStep();
        }
    }
Esempio n. 2
0
    private void HandleAttackSyncCompleteEvent(string defendingPlayerId, string attackingPieceId, Vector2 boardVector)
    {
        List <GamePiece> targets = new List <GamePiece>();

        if (MatchHandler.CurrentMatch != null)
        {
            if (m_PieceSyncCache.ContainsKey(defendingPlayerId))
            {
                foreach (KeyValuePair <string, GamePieceNetworkState> kvp in m_PieceSyncCache[defendingPlayerId])
                {
                    if (m_ActiveGamePieces.ContainsKey(kvp.Key))
                    {
                        UpdateGamePiece(kvp.Value);
                        targets.Add(m_ActiveGamePieces[kvp.Key]);
                    }
                }

                m_PieceSyncCache[defendingPlayerId].Clear();

                m_GameBoardRelative.ClearCurrentSelections();

                if (m_ActiveGamePieces.ContainsKey(attackingPieceId))
                {
                    m_ActiveGamePieces[attackingPieceId].FinalizeAttack
                        (targets.ToArray(), m_GameBoardRelative.GetTileByVector(boardVector));
                }

                TurnStateHandler.FinishStep();
            }
        }
    }
Esempio n. 3
0
    internal void HandlePathComplete(GamePiece piece)
    {
        if (m_InitializedPieceMovement || m_GameBoardRelative.TestMode)
        {
            m_InitializedPieceMovement = false;
            RelayPieceSyncToClientManager
                (piece.ControllingPlayerId, piece.ControllingPlayerPosition, piece);

            if (piece.UnderLocalControl || m_GameBoardRelative.TestMode)
            {
                TurnStateHandler.FinishStep();
            }
        }
    }
    void SetDirection(Button button)
    {
        m_DeltaRotation = Quaternion.LookRotation
                              (button.transform.position - transform.parent.transform.position);

        m_DeltaRotation.z = 0;
        m_DeltaRotation.x = 0;

        transform.parent.transform.rotation = m_DeltaRotation;

        GamePiece piece = transform.parent.GetComponent <GamePiece>();

        piece.Handler.HandleRotationChange(piece);

        if (piece.UnderLocalControl || piece.TestMode)
        {
            TurnStateHandler.FinishStep();
        }

        gameObject.SetActive(false);
    }