Exemple #1
0
 protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
 {
     if (_attack == null)
     {
         _attack = StartCoroutine(DoubleAttack(figure));
     }
 }
Exemple #2
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        // Если противник заморожен, то умение будет активно еще ход
        if (_freezing)
        {
            IsActive = true;
        }

        // Если откат прошел и умение еще не активно
        if (_delay <= 0 && !IsActive)
        {
            var attackedCells = figure.GetRelevantAttackMoves();
            foreach (var attackedCell in attackedCells)
            {
                // Если попали в противника, то указывает это в переменную _freezing и повторно активирует умение
                if (attackedCell.BattleFieldFigure != null)
                {
                    _freezing         = true;
                    IsActive          = true;
                    _iceImageInstance = Instantiate(_iceImage, figure.BattleField.transform);
                    _iceImageInstance.rectTransform.localPosition = attackedCell.RectTransform.localPosition;
                }
                attackedCell.TakeDamage(0);
                _delay = _maxDelay;
            }
        }

        _delay = 0;
        // Если противник еще заморожен, то ходим на выбранную клетку обычным образом
        if (_freezing && cell != null)
        {
            StartCoroutine(FigureTurn(figure, cell));
            _currentFreezeTime++;
        }
    }
Exemple #3
0
        private void ReBuildContents()
        {
            contents.Children.Clear();
            contents.RowDefinitions.Clear();
            contents.ColumnDefinitions.Clear();

            int sz = this.FieldSize;

            _cells = new BattleFieldCell[sz, sz];

            contents.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0, GridUnitType.Auto)
            });
            contents.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(0, GridUnitType.Auto)
            });
            for (int i = 0; i < sz; i++)
            {
                contents.RowDefinitions.Add(new RowDefinition());
                contents.ColumnDefinitions.Add(new ColumnDefinition());

                var hh = new UserControl()
                {
                    Content             = ((char)('A' + i)).ToString(),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                contents.Children.Add(hh);
                Grid.SetRow(hh, 0);
                Grid.SetColumn(hh, i + 1);

                var vh = new UserControl()
                {
                    Content             = (i + 1).ToString(),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                contents.Children.Add(vh);
                Grid.SetRow(vh, i + 1);
                Grid.SetColumn(vh, 0);
            }

            for (int y = 0; y < sz; y++)
            {
                for (int x = 0; x < sz; x++)
                {
                    var cell = new BattleFieldCell(this, x, y);
                    _cells[x, y] = cell;
                    contents.Children.Add(cell.Control);
                    Grid.SetRow(cell.Control, y + 1);
                    Grid.SetColumn(cell.Control, x + 1);
                    cell.Control.PreviewMouseDown += (sender, ea) => ea.Handled = true;
                    cell.Control.MouseUp          += (sender, ea) => this.OnBattleFieldCellMouseUp(this, new BattleFieldCellEventArgs(cell, ea));
                    cell.Control.MouseEnter       += (sender, ea) => this.OnBattleFieldCellMouseEnter(this, new BattleFieldCellEventArgs(cell, ea));
                    cell.Control.MouseLeave       += (sender, ea) => this.OnBattleFieldCellMouseLeave(this, new BattleFieldCellEventArgs(cell, ea));
                }
            }
        }
Exemple #4
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        if (_baseDamage == -1)
        {
            _baseDamage = figure.Damage;
        }
        if (_baseDefence == -1)
        {
            _baseDefence = figure.Defence;
        }

        if (figure.Damage == _baseDamage)
        {
            if (figure.Defence == 0)
            {
                figure.Damage += _damageIfDefenceEqualsZero;
            }
            else
            {
                figure.Damage += figure.Defence;
            }
            figure.Defence = 0;
        }
        else
        {
            figure.Defence = _baseDefence;
            figure.Damage  = _baseDamage;
        }
    }
Exemple #5
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        var figurePos = figure.OnBoardPosition;
        List <BattleFieldCell> turns = new List <BattleFieldCell>();
        var isEvenCell       = (figurePos.x % 2 == 0) == (figurePos.y % 2 == 0);
        var battleFieldCells = figure.BattleField.BattleFieldCells;

        for (int x = 0; x < battleFieldCells.GetLongLength(0); x++)
        {
            for (int y = 0; y < battleFieldCells.GetLongLength(1); y++)
            {
                if ((battleFieldCells[x, y].OnBoardPosition.x % 2 == 0) ==
                    (battleFieldCells[x, y].OnBoardPosition.y % 2 == 0) == isEvenCell)
                {
                    if (battleFieldCells[x, y].BattleFieldFigure == null)
                    {
                        if (battleFieldCells[x, y].BattleFieldObject == null || battleFieldCells[x, y].BattleFieldObject.CanThisFigureToCross(figure) != BarrierType.Impassable)
                        {
                            turns.Add(battleFieldCells[x, y]);
                        }
                    }
                }
            }
        }

        var randomCell = turns[Random.Range(0, turns.Count)];

        StartCoroutine(MoveAndUpdateTurns(figure, randomCell));
    }
Exemple #6
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        var obj = Instantiate(_battleFieldObject, figure.BattleField.transform);

        obj.MoveToAnotherCell(cell);
        obj.Team = figure.Data.Team;
        if (!_continueTurn)
        {
            figure.BattleField.BattleController.SwitchTurn();
        }
    }
Exemple #7
0
 protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
 {
     if (GetMirrorCell(figure).BattleFieldFigure == null)
     {
         var shadowClone = Instantiate(_shadowClone, figure.BattleField.transform);
         shadowClone.Team  = figure.Data.Team;
         shadowClone.Owner = figure;
         _controller.SwitchTurn();
     }
     else
     {
         _delay = 0;
     }
 }
Exemple #8
0
    private IEnumerator MoveAndUpdateTurns(BattleFieldFigure figure, BattleFieldCell cell)
    {
        figure.BattleField.BattleController.DeactivateAllCells();
        yield return(figure.MoveToAnotherCellWithAnimation(cell));

        if (figure.GetRelevantMoves().Length > 0)
        {
            figure.BattleField.BattleController.ActivateAllCells(figure.GetRelevantMoves());
        }
        else
        {
            figure.BattleField.BattleController.SwitchTurn();
        }
    }
Exemple #9
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        var rawField = figure.BattleField.BattleFieldCells;

        for (int x = 0; x < rawField.GetLength(0); x++)
        {
            for (int y = 0; y < rawField.GetLength(1); y++)
            {
                rawField[x, y].TakeDamage(figure);
            }
        }

        figure.TakeDamage(1000);
    }
Exemple #10
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        var turns = figure.GetRelevantMoves();

        foreach (var turn in turns)
        {
            var obj = Instantiate(battleFieldObject, figure.BattleField.transform);
            obj.MoveToAnotherCell(turn);
            obj.Team = figure.Data.Team;
        }

        if (!_continueTurn)
        {
            figure.BattleField.BattleController.SwitchTurn();
        }
    }
Exemple #11
0
 protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
 {
     StartCoroutine(figure.MoveToAnotherCellWithAnimation(cell));
     _controller.ActivateAllCells(figure.GetRelevantMoves());
 }
Exemple #12
0
    protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
    {
        var rawField = figure.BattleField.BattleFieldCells;

        bool canBeCutFromTheTop   = true;
        bool canBeCutFromTheRight = true;

        if (figure.BattleField.BattleFieldCells.GetLength(0) <= 4)
        {
            canBeCutFromTheRight = false;
        }
        if (figure.BattleField.BattleFieldCells.GetLength(1) <= 4)
        {
            canBeCutFromTheTop = false;
        }

        for (int i = 0; i < rawField.GetLength(0); i++)
        {
            var currentCell = rawField[i, rawField.GetLength(1) - 1];
            if (currentCell.BattleFieldFigure != null)
            {
                canBeCutFromTheTop = false;
            }
        }

        for (int i = 0; i < rawField.GetLength(1); i++)
        {
            var currentCell = rawField[rawField.GetLength(0) - 1, rawField.GetLength(1) - 1 - i];
            if (currentCell.BattleFieldFigure != null)
            {
                canBeCutFromTheRight = false;
            }
        }

        if (canBeCutFromTheRight || canBeCutFromTheTop)
        {
            BattleFieldCell[,] newField = new BattleFieldCell[0, 0];

            if (canBeCutFromTheRight && canBeCutFromTheTop)
            {
                newField = new BattleFieldCell[rawField.GetLength(0) - 1, rawField.GetLength(1) - 1];
            }
            else if (canBeCutFromTheRight)
            {
                newField = new BattleFieldCell[rawField.GetLength(0) - 1, rawField.GetLength(1)];
            }
            else if (canBeCutFromTheTop)
            {
                newField = new BattleFieldCell[rawField.GetLength(0), rawField.GetLength(1) - 1];
            }

            for (int x = 0; x < rawField.GetLength(0); x++)
            {
                for (int y = 0; y < rawField.GetLength(1); y++)
                {
                    if (canBeCutFromTheRight && x >= newField.GetLength(0) || canBeCutFromTheTop && y >= newField.GetLength(1))
                    {
                        Destroy(rawField[x, y].gameObject);
                    }
                    else
                    {
                        newField[x, y] = rawField[x, y];
                        if (newField[x, y].BattleFieldObject != null)
                        {
                            newField[x, y].BattleFieldObject.DestroyThisBattleFieldObject();
                        }
                    }
                }
            }

            figure.BattleField.BattleFieldCells = newField;
        }
        figure.BattleField.BattleController.DeactivateAllCells();
        _controller.SwitchTurn();
    }
Exemple #13
0
 protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell)
 {
     figure.Health += _healAmount;
     _controller.SwitchTurn();
 }