예제 #1
0
    public void MakeStep(BattleField field, int x, int y)
    {
        if (field.FieldFilling[x, y] != FillTypes.WreckedShip && field.FieldFilling[x, y] != FillTypes.Shot)
        {
            field.SetShot(x, y);

            if (field.FieldFilling[x, y] == FillTypes.WreckedShip)
            {
                Ship ship = field.FindShip(x, y);

                if (ship != null)
                {
                    ship.SetDamage(x, y);

                    if (ship.Lives <= 0)
                    {
                        field.PutShipToPool(ship);
                    }
                    if (field.Fleet.Count <= 0)
                    {
                        this.Step = StepOrders.None;
                        OnGameOver.SafeInvoke();
                    }
                }
                else
                {
                    Debug.LogError("This ship should not be NULL");
                }
            }

            if (field.FieldFilling[x, y] != FillTypes.WreckedShip)
            {
                this.Step = this.Step == StepOrders.Player ? StepOrders.Enemy : StepOrders.Player;
            }
        }
    }