public override void Turn() { if (!isDead) { base.Turn(); StartCoroutine(WaitForFree()); NodeBehaviour bestCover = GetBestCoverWithinReach(); Debug.Log(bestCover); if (currentNode != bestCover && bestCover != null) { Command move = Factory.GetCommand(Commands.Move, this); move.target = bestCover.GetComponent <Targetable>(); move.Execute(); } StartCoroutine(WaitForFree()); if (weapon.actionCost < ActionPoints) { Command attack = Factory.GetCommand(Commands.Attack, this); if (attack.validTargets.Count > 0) { Pawn bestTarget = GetBestTarget(attack.validTargets); if (bestTarget != null) { attack.target = bestTarget.GetComponent <Targetable>(); attack.Execute(); } } } StartCoroutine(WaitForFree()); } }
public void SetSelectedNode(NodeBehaviour nodeBehaviour) { if (_selectedNode == null) { if (_inSelectionState) { if (!nodeBehaviour.IsSelected()) { Debug.Log("This tile is currently not selected"); return; } ChangeColorsToGreen(); } else { _selectedNode = nodeBehaviour; ChangeColorsToBlue(); } } else { if (_inSelectionState && nodeBehaviour.IsSelected()) { ChangeColorsToBlue(); } else if (_inSelectionState && !nodeBehaviour.IsSelected()) { Debug.Log("no blue or green tile clicked"); return; } else { ChangeColorsToOld(); } _selectedNode = nodeBehaviour; if (_inSelectionState) { ChangeColorsToGreen(); } else { ChangeColorsToBlue(); } } if (!_inSelectionState) { _selection.SetYesNoLocation(Camera.main.WorldToScreenPoint(_selectedNode.transform.position)); } else { _selection.SetYesNoBuildLocation(Camera.main.WorldToScreenPoint(_selectedNode.transform.position)); } if (_selectedNode.GetComponent <BuildingPrefab>() != null) { _selection.SetSidePanel(_selectedNode.GetComponent <BuildingPrefab>().MyBuilding); } else if (_selectedNode.GetComponent <PlantPrefab>() != null) { _selection.SetSidePanel(_selectedNode.GetComponent <PlantPrefab>().MyPlant); } else if (_selection.SidePannelActive()) { _selection.ToggleSidePanel(); } if (_selectionSize != 4 || _inSelectionState) { return; } if (!_selection.YesNoActive()) { _selection.ToggleYesNo(true); } }
public static void RemoveTiles(NodeBehaviour node) { if (node.GetListIndex() == -1) { return; } if (node.GetCurrentState() == NodeState.CurrentStateEnum.Field) { bool isPlant = false; if (node.gameObject.GetComponent <PlantPrefab>() != null) { SimpleMoneyManager.Instance.RemoveValue(node.gameObject.GetComponent <PlantPrefab>().MyPlant); EventManager.Instance.AddEnviromentValue ( node.GetComponent <NodeState>().FieldType, -node.GetComponent <PlantPrefab>().MyPlant.EnviromentValue ); EventManager.Instance.AddHappinessValue ( node.GetComponent <NodeState>().FieldType, -node.GetComponent <PlantPrefab>().MyPlant.Happiness ); if (node.GetComponent <PlantPrefab>().MyPlant.Upgrade) { CultivationManager.Instance.RemoveUpgradedCultivation(node.GetComponent <PlantPrefab>()); node.ResetNode(true, false); node.HighLight.ChangeColorToOld(); node.GetComponent <PlantPrefab>().ResetValues(); } isPlant = true; } node.ResetNode(isPlant, false); return; } int nodeCount = GridManager.Instance.GetCultivationLocationDictionary()[node.GetListIndex()].Count; int nodeIndex = node.GetListIndex(); for (int i = 0; i < nodeCount; i++) { var nodeBehaviour = GridManager.Instance.GetCultivationLocationDictionary()[nodeIndex][i]; nodeBehaviour.GetNodeFence().TryRemoveFence(); if (nodeBehaviour.gameObject.GetComponent <PlantPrefab>() != null) { SimpleMoneyManager.Instance.RemoveValue(nodeBehaviour.gameObject.GetComponent <PlantPrefab>().MyPlant); EventManager.Instance.AddEnviromentValue ( nodeBehaviour.GetComponent <NodeState>().FieldType, -nodeBehaviour.GetComponent <PlantPrefab>().MyPlant.EnviromentValue ); EventManager.Instance.AddHappinessValue ( nodeBehaviour.GetComponent <NodeState>().FieldType, -nodeBehaviour.GetComponent <PlantPrefab>().MyPlant.Happiness ); if (nodeBehaviour.GetComponent <PlantPrefab>().MyPlant.Upgrade) { CultivationManager.Instance.RemoveUpgradedCultivation(nodeBehaviour.GetComponent <PlantPrefab>()); } nodeBehaviour.GetComponent <PlantPrefab>().ResetValues(); } else if (nodeBehaviour.gameObject.GetComponent <BuildingPrefab>() != null) { SimpleMoneyManager.Instance.RemoveValue(nodeBehaviour.gameObject.GetComponent <BuildingPrefab>().MyBuilding); EventManager.Instance.AddEnviromentValue ( nodeBehaviour.GetComponent <NodeState>().FieldType, -nodeBehaviour.GetComponent <BuildingPrefab>().MyBuilding.EnviromentValue ); EventManager.Instance.AddHappinessValue ( nodeBehaviour.GetComponent <NodeState>().FieldType, -nodeBehaviour.GetComponent <BuildingPrefab>().MyBuilding.Happiness ); if (node.GetComponent <BuildingPrefab>().MyBuilding.Upgrade) { CultivationManager.Instance.RemoveUpgradedCultivation(node.GetComponent <BuildingPrefab>()); } } nodeBehaviour.ResetNode(false, true); } GridManager.Instance.GetCultivationLocationDictionary()[nodeIndex].Clear(); }