예제 #1
0
    public void AfterMapMovement()
    {
        foreach (CombatTile CT in BattleFieldTiles)
        {
            CT.ChangeFromMovable();
            CT.ChangeFromAttackable();
            CT.ClearLists();
        }

        //ensure that tiles are properly threatened
        foreach (Character chara in Friends)
        {
            //do the movement Calculation, but for
            Vector2Int selectedPosition = chara.MapPosition;
            int        maxValue         = chara.MaxRangeOpportunity;
            Vector2Int tempPos;
            int        Xvalue = maxValue;
            int        Yvalue = 0;

            while (Xvalue >= -maxValue)
            {
                Yvalue = 0;
                do
                {
                    tempPos = new Vector2Int(selectedPosition.x + Xvalue, selectedPosition.y + Yvalue);

                    if ((tempPos.x >= 0 && tempPos.x < 4) && (tempPos.y >= 0 && tempPos.y < 12))
                    {
                        BattleFieldTiles[tempPos.x, tempPos.y].AddThreateningPlayer(chara);
                    }

                    tempPos = new Vector2Int(selectedPosition.x + Xvalue, selectedPosition.y - Yvalue);
                    if ((tempPos.x >= 0 && tempPos.x < 4) && (tempPos.y >= 0 && tempPos.y < 12))
                    {
                        BattleFieldTiles[tempPos.x, tempPos.y].AddThreateningPlayer(chara);
                    }

                    Yvalue++;
                } while ((Mathf.Abs(Xvalue) + Yvalue) <= maxValue);


                Xvalue--;
            }
        }
        foreach (Monster chara in Foes)
        {
            //do the movement Calculation, but for
            Vector2Int selectedPosition = chara.MapPosition;
            int        maxValue         = chara.MaxRangeOpportunity;
            Vector2Int tempPos;
            int        Xvalue = maxValue;
            int        Yvalue = 0;

            while (Xvalue >= -maxValue)
            {
                Yvalue = 0;
                do
                {
                    tempPos = new Vector2Int(selectedPosition.x + Xvalue, selectedPosition.y + Yvalue);

                    if ((tempPos.x >= 0 && tempPos.x < 4) && (tempPos.y >= 0 && tempPos.y < 12))
                    {
                        BattleFieldTiles[tempPos.x, tempPos.y].AddThreateningMonster(chara);
                    }

                    tempPos = new Vector2Int(selectedPosition.x + Xvalue, selectedPosition.y - Yvalue);
                    if ((tempPos.x >= 0 && tempPos.x < 4) && (tempPos.y >= 0 && tempPos.y < 12))
                    {
                        BattleFieldTiles[tempPos.x, tempPos.y].AddThreateningMonster(chara);
                    }

                    Yvalue++;
                } while ((Mathf.Abs(Xvalue) + Yvalue) <= maxValue);


                Xvalue--;
            }
        }
    }