protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell) { if (_attack == null) { _attack = StartCoroutine(DoubleAttack(figure)); } }
public override void Activate(BattleFieldFigure figure) { if (_delay <= 0 || IsActive == true) { IsActive = !IsActive; } }
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)); }
public override void TakeDamage(BattleFieldFigure attacker) { if (attacker.Data.Team != Team) { _turnRemains -= 0.5f; } }
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++; } }
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; } }
public override BarrierType CanThisFigureToAttackThrough(BattleFieldFigure figure) { if (figure.Data.Team != Team) { return(BarrierType.Stopable); } return(BarrierType.Passable); }
public override void TakeDamage(BattleFieldFigure attacker) { if (attacker.Data.Team != Team) { attacker.TakeDamage(_damage); DestroyThisBattleFieldObject(); } }
public override void Visit(BattleFieldFigure visitor) { if (visitor.Data.Team != Team) { visitor.TakeDamage(_damage); DestroyThisBattleFieldObject(); } }
public override BarrierType CanThisFigureToCross(BattleFieldFigure figure) { if (figure.Data.Team != Team) { return(BarrierType.Impassable); } return(BarrierType.Passable); }
private BattleFieldCell GetMirrorCell(BattleFieldFigure owner) { Vector2Int currentOwnerPosition = owner.OnBoardPosition; var mirrorCellVector = new Vector2Int(owner.BattleField.Width - 1 - currentOwnerPosition.x, owner.BattleField.Height - 1 - currentOwnerPosition.y); var mirrorCell = owner.BattleField.BattleFieldCells[mirrorCellVector.x, mirrorCellVector.y]; return(mirrorCell); }
private BattleFieldCell GetMirrorCell(BattleFieldFigure figure) { Vector2Int currentFigurePosition = figure.OnBoardPosition; var mirrorCellVector = new Vector2Int(figure.BattleField.Width - 1 - currentFigurePosition.x, figure.BattleField.Height - 1 - currentFigurePosition.y); var mirrorCell = figure.BattleField.BattleFieldCells[mirrorCellVector.x, mirrorCellVector.y]; return(mirrorCell); }
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(); } }
private void Start() { _firstFigure = _battleController.BattleField.FirstFigure; _secondFigure = _battleController.BattleField.SecondFigure; _firstFigure.onHealthChanged.AddListener(UpdateHealthBars); _secondFigure.onHealthChanged.AddListener(UpdateHealthBars); _battleController.onSwitchTurn.AddListener(ShowCurrentTurn); _battleController.BattleField.FirstFigure.Skill.onChangeDelay.AddListener(ShowSkillDelay); _battleController.BattleField.SecondFigure.Skill.onChangeDelay.AddListener(ShowSkillDelay); UpdateHealthBars(); ShowCurrentTurn(); }
public override void Activate(BattleFieldFigure figure) { if (_controller == null) { SubscribeOnSwitchTurn(figure.BattleField.BattleController); } IsActive = false; if (_delay <= 0) { SkillAction(figure, null); } }
private void Start() { _text = GetComponent <Chess2Text>(); if (_isForFirstPlayer) { _figure = _field.FirstFigure; } else { _figure = _field.SecondFigure; } _text.Text = _figure.Talent.Name; }
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(); } }
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; } }
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); }
private IEnumerator DoubleAttack(BattleFieldFigure figure) { while (_controller != null && _controller.IsAnimationPlaying) { yield return(new WaitForSeconds(BattleController.animationDelay)); } _controller.IsAnimationPlaying = true; figure.LaunchAnAttack(); yield return(new WaitForSeconds(0.5f)); figure.LaunchAnAttack(); _controller.IsAnimationPlaying = false; _controller.SwitchTurn(); _attack = null; }
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(); } }
private IEnumerator FigureTurn(BattleFieldFigure figure, CellBase cell) { yield return(figure.MoveToAnotherCellWithAnimation(cell)); figure.LaunchAnAttack(); _controller.ActivateAllCells(figure.GetRelevantMoves()); if (_currentFreezeTime >= _freezeTime) { _delay = _maxDelay; _currentFreezeTime = 0; _freezing = false; IsActive = false; Destroy(_iceImageInstance); _controller.SwitchTurn(); } }
private void Start() { _image = GetComponent <Image>(); GetComponent <Button>().onClick.AddListener(Activate); if (IsForFirstPlayer) { _figure = _field.FirstFigure; } else { _figure = _field.SecondFigure; } if (_figure.Skill != null) { _figure.Skill.activateOrDisactivate.AddListener(UpdateButton); } }
public override BarrierType CanThisFigureToAttackThrough(BattleFieldFigure figure) { return(BarrierType.Passable); }
public override void Visit(BattleFieldFigure visitor) { }
public override void TakeDamage(BattleFieldFigure attacker) { }
public override BarrierType CanThisFigureToCross(BattleFieldFigure figure) { return(BarrierType.Passable); }
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(); }
public override void Activate(BattleFieldFigure figure) { Execute(figure, null); }
protected override void SkillAction(BattleFieldFigure figure, BattleFieldCell cell) { StartCoroutine(figure.MoveToAnotherCellWithAnimation(cell)); _controller.ActivateAllCells(figure.GetRelevantMoves()); }