Пример #1
0
    public void AttackOn(Vector2Int targetPosition)
    {
        if (!CanAttack)
        {
            return;
        }
        int y = targetPosition.y;
        int x = targetPosition.x;

        OnBoardDestructible attackedDestructible = Board.Destructables[y, x];

        Debug.Log("first attack");
        attackedDestructible.ReceiveDamage(Attack);
        Debug.Log("first attack");
        CanAttack = false;

        if (x == 0 || x == Board.Width - 1 || y == 0 || y == Board.Height - 1)
        {
            return;
        }

        OnBoardDragon attackedDragon = (OnBoardDragon)attackedDestructible;

        if (attackedDragon.Alive && attackedDragon.Range >= attackedDragon.DistanceTo(this) &&
            attackedDragon.CanRetaliate)
        {
            Debug.Log("second attack");
            this.ReceiveDamage(attackedDragon.Attack);
            attackedDragon.CanRetaliate = false;
        }
    }
Пример #2
0
    private void InteractableObjectUsed(object sender, InteractableObjectEventArgs e)
    {
        Debug.Log($"used {myIndex}");
        int i = myIndex / Table.HEIGHT;
        int j = myIndex % Table.HEIGHT;

        Debug.Log($"used {i} {j}");

        OnBoardDestructible myDestructible = GameReferee.Instance.Board.Destructables[j, i];

        if (myDestructible != null)
        {
            Debug.Log($"There is something here {myDestructible.DestructibleType}");
        }

        if (myDestructible != null &&
            myDestructible.DestructibleType == OnBoardDestructible.DRAGON &&
            myDestructible.Owner == PlayerInfoScene.Instance.playerId
            )
        {
            Debug.Log("I am indeed a dragon");
            var movePositions = ((OnBoardDragon)myDestructible).GetMovingPositions();
            Debug.Log($"move positions: {movePositions.Count}");
            foreach (var pos in movePositions)
            {
                int index = pos.x * 8 + pos.y;
                Debug.Log($"Some position: {pos} index {index}");
                Table.SetCurrentColor(index, TileColor.MOVE);
            }
        }
    }
Пример #3
0
    public override void GoPlay(Vector2Int targetPosition)
    {
        int y = targetPosition.y;
        int x = targetPosition.x;
        OnBoardDestructible attackedDestructible = Board.Destructables[y, x];

        attackedDestructible.ReceiveDamage(DamageDealt);
    }
    private void OnTileUsed()
    {
        if (!GameReferee.Instance.IsMyTurn())
        {
            return;
        }
        Debug.Log("used used");
        if (tileBeingUsed != -1)
        {
            return;
        }
        tileBeingUsed = GetSelectedChild();
        if (tileBeingUsed == -1)
        {
            return;
        }
        Debug.Log($"used {tileBeingUsed}");

        int i = tileBeingUsed / tableColors.HEIGHT;
        int j = tileBeingUsed % tableColors.HEIGHT;

        Debug.Log($"used {i} {j}");

        myDestructible = GameReferee.Instance.Board.Destructables[i, j];

        if (myDestructible != null)
        {
            Debug.Log($"There is something here {myDestructible.DestructibleType}");
        }

        if (myDestructible != null &&
            myDestructible.DestructibleType == OnBoardDestructible.DRAGON &&
            myDestructible.Owner == PlayerInfoScene.Instance.playerId
            )
        {
            Debug.Log("I am indeed a dragon");
            var movePositions = ((OnBoardDragon)myDestructible).GetMovingPositions();
            Debug.Log($"move positions: {movePositions.Count}");
            foreach (var pos in movePositions)
            {
                int index = pos.x + 8 * pos.y;
                Debug.Log($"Some position: {pos} index {index}");
                tableColors.SetCurrentColor(index, TileColor.MOVE);
            }

            var attackPositions = ((OnBoardDragon)myDestructible).GetAttackingPositions();
            Debug.Log($"move positions: {attackPositions.Count}");
            foreach (var pos in attackPositions)
            {
                int index = pos.x + 8 * pos.y;
                Debug.Log($"Some position: {pos} index {index}");
                tableColors.SetCurrentColor(index, TileColor.ATTACK);
            }
        }
    }
Пример #5
0
    IEnumerator DieCoroutine(OnBoardDestructible toDie)
    {
        //yield on a new YieldInstruction that waits for 3 seconds.
        yield return(new WaitForSeconds(3));

        if (toDie.DestructibleType == OnBoardDestructible.DRAGON)
        {
            GameObject.Destroy(toDie.PhysicInstance);
        }
        else
        {
            toDie.PhysicInstance.SetActive(false);
        }
        //Destroy(this);

        if (IsMyTurn() && typeof(OnBoardNest).IsInstanceOfType(toDie))
        {
            CallRPCMethod("GameOver", 3 - toDie.Owner, false);
        }
        yield return(null);
    }
    private void OnTileUnused()
    {
        if (!GameReferee.Instance.IsMyTurn())
        {
            return;
        }

        int currentTile = GetSelectedChild();

        if (myDestructible != null &&
            myDestructible.DestructibleType == OnBoardDestructible.DRAGON &&
            myDestructible.Owner == PlayerInfoScene.Instance.playerId
            )
        {
            var myDragon = (OnBoardDragon)myDestructible;
            int i1       = tileBeingUsed / tableColors.HEIGHT;
            int j1       = tileBeingUsed % tableColors.HEIGHT;

            int i2 = currentTile / tableColors.HEIGHT;
            int j2 = currentTile % tableColors.HEIGHT;

            var OtherDestructible = GameReferee.Instance.Board.Destructables[i2, j2];

            if (OtherDestructible == null && myDragon.GetMovingPositions().Contains(new Vector2Int(j2, i2)))
            {
                GameReferee.Instance.CallRPCMethod("MoveOnBoardDragon", new int[] { i1, j1 }, new int[] { i2, j2 });
            }
            else
            {
                if (OtherDestructible != null && myDragon.GetAttackingPositions().Contains(new Vector2Int(j2, i2)))
                {
                    GameReferee.Instance.CallRPCMethod("AttackOnBoardDragon", new int[] { j1, i1 }, new int[] { j2, i2 });
                }
            }
        }

        tileBeingUsed  = -1;
        myDestructible = null;
        tableColors.ResetAll();
    }
Пример #7
0
    public void AttackOnBoardDragon(int[] allyPos, int[] attackedPos)
    {
        int x = attackedPos[0];
        int y = attackedPos[1];

        OnBoardDragon       chosenDragon         = (OnBoardDragon)Board.Destructables[allyPos[1], allyPos[0]];
        OnBoardDestructible attackedDestructible = Board.Destructables[y, x];

        chosenDragon.AttackOn(new Vector2Int(x, y));

        if (x == 0 || x == Board.Width - 1 || y == 0 || y == Board.Height - 1)
        {
            //Attacked a building
            var attackedBuilding = (OnBoardBuilding)attackedDestructible;
            attackedBuilding.UpdateStatus();
            return;
        }
        //Attacked a dragon
        var attackedDragon = (OnBoardDragon)attackedDestructible;

        chosenDragon.UpdateOnBoard();
        attackedDragon.UpdateOnBoard();
    }
Пример #8
0
 public void CallDeath(OnBoardDestructible toDie)
 {
     StartCoroutine(DieCoroutine(toDie));
 }
Пример #9
0
 public int DistanceTo(OnBoardDestructible destructible)
 {
     return(Math.Abs(destructible.BoardY - this.BoardY) + Math.Abs(destructible.BoardX - this.BoardX));
 }