/// <summary> /// Clears all move state. /// Clears the army text and disables the current frame (if exists). /// </summary> private void ClearMoveState() { SetActiveFrame(null); armyText.Clear(); chosenArmyItem = null; currentTargetPosition = null; currentMover = null; chosenArmyPosition = null; SetSplitModeActive(false); }
/// <summary> /// Starts a movement of the chosen army to the given position. /// Board buttons are disabled. /// </summary> private void MoveChosen(IntVector2 targetPosition) { //TODO: maybe we should disable the whole menu here? It will remove the extra dependency in BoardStorage. boardStorage.DisableBoardButtons(); //Removes an item from the old position. boardStorage.SetItem(chosenArmyPosition, null); //Save target position for further processing after icon will reach the target. currentTargetPosition = targetPosition; //Get mover component of the chosen army. var armyObject = chosenArmyItem.StoredObject; currentMover = armyObject.GetComponent <ObjectMover>(); //Initialize the mover, subscribe on its finish event. currentMover.PrepareMovement(armyObject); currentMover.ReachedTarget += OnFinishMovement; //Get the target button object and start movement. var targetObject = boardStorage.GetBoardButton(targetPosition).gameObject; currentMover.MoveTo(targetObject); }