public override void Update(GridPosition pos) { base.Update(pos); if (secondary != null) { return; } if (pos.Equals(Target.CurrentPosition)) { return; } int selecteddir = InputHandlerer.GetDirectionFromInput(); if (selecteddir == 1) { Target.PreviousTarget(); BattleUIContainer._instance.UnitView.SetDamagePreview(Character.GetCharacterAtTile(Target.CurrentPosition).stats, activator.stats); } else if (selecteddir == 3) { Target.NextTarget(); BattleUIContainer._instance.UnitView.SetDamagePreview(Character.GetCharacterAtTile(Target.CurrentPosition).stats, activator.stats); } GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode)); }
private GridPosition MoveTarget() { GridPosition newPos = Target.CurrentPosition; if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0) { int selecteddir = InputHandlerer.GetDirectionFromInput(); GridPosition futurePosition = Target.CurrentPosition.Clone(); if (selecteddir == 3) { futurePosition.y++; } else if (selecteddir == 1) { futurePosition.y--; } else if (selecteddir == 2) { futurePosition.x++; } else if (selecteddir == 4) { futurePosition.x--; } GridPosition pos; if (GameGrid.currentGrid.CanBeWalked(Target.CurrentPosition, futurePosition, out pos) != GameGrid.WalType.CannotWalk) { newPos = pos; } } return(newPos); }
public override void Update(GridPosition pos) { base.Update(pos); if (secondary != null) { return; } RangeDisplayControls(); if (pos.Equals(Target.CurrentPosition)) { return; } int selecteddir = InputHandlerer.GetDirectionFromInput(); if (pathDraw.GetPath().Count == 0) { activator.SetAnimatorDirection(selecteddir); } //Disable walking throught enemy if (pathDraw.GetPath().Count > 0) { if (Character.isOtherCharacterInTile(pathDraw.Last.Clone(), activator)) { if (pathDraw.GetPath().Count > 1) { if (!pathDraw.LastNode.Previous.Value.Equals(pos)) { GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode)); return; } } } } //Are we inside of character movement range if (currentMovementRange.Exists(item => item.Equals(pos))) { //Did we enter the movement range? if (!Target.isOutside) { Target.Clear(); bool characterInTile = Character.isCharacterInTile(pos); if (characterInTile) { Character chara = Character.GetCharacterAtTile(pos); if (chara != activator) { if (chara.TeamNumber != activator.TeamNumber && !activator.TurnActionsPreformed[0]) { if (pathDraw.AddPath(pos)) { AudioManager._instance.PlayClip("Click_Standard_03"); Target.Move(pos, Color.red); BattleUIContainer._instance.UnitView.SetDamagePreview(chara.stats, activator.stats); pathDraw.SetLastWaypointGraphic(Target.Indicator.gameObject); LastDirection = selecteddir; } } } else { //Return to same tiel as character pathDraw.Destroy(); Target.CurrentPosition = activator.Position; } } else { //No characters in tile if (pathDraw.AddPath(pos)) { AudioManager._instance.PlayClip("Click_Standard_03"); Target.CurrentPosition = pos.Clone(); LastDirection = selecteddir; } BattleUIContainer.RefreshUnitView(activator); BattleUIContainer._instance.UnitView.HideDamagePreview(); } } else { //If we return to walkarea from outside } } else { if (!Target.isOutside) { AudioManager._instance.PlayClip("Click_Standard_03"); secondary = new ViewAction(this, currentMovementRange); Target.Move(pos, Color.white); TurnManager._instance.AddCancel(secondary.Cancel); } //Move outside walkable range Target.isOutside = true; } GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode)); }