public void OnAttackTargetCommandIssued() { Npc nearestFarmer = NpcManager.FindNearest(NpcType.FARMER, this.transform); if (nearestFarmer != null && nearestFarmer is FarmerNpc && nearestFarmer is MonoBehaviour) { MonoBehaviour farmerBehaviour = nearestFarmer as MonoBehaviour; float step = this.speed * Time.deltaTime; this.transform.position = Vector3.MoveTowards(this.transform.position, farmerBehaviour.transform.position, step); } }
public bool IsAttackTargetCommandCompleted() { Npc nearestFarmer = NpcManager.FindNearest(NpcType.FARMER, this.transform); if (nearestFarmer != null && nearestFarmer is FarmerNpc && nearestFarmer is MonoBehaviour) { MonoBehaviour farmerBehaviour = nearestFarmer as MonoBehaviour; Vector3 vectorToFarmer = transform.position - farmerBehaviour.transform.position; return(vectorToFarmer.magnitude <= 1.0f); } return(false); }
public void OnCommandCompleted(Dictionary <string, object> newState, string actionType) { Debug.Log("Mercenary completed command: " + actionType); foreach (KeyValuePair <string, object> kvPair in newState) { blackboard.SetWorldStateVariable(kvPair.Key, kvPair.Value); } if (actionType == ActionType.ATTACK_TARGET.ToString()) { Npc nearestFarmer = NpcManager.FindNearest(NpcType.FARMER, this.transform); if (nearestFarmer is FarmerNpc) { (nearestFarmer as FarmerNpc).Kill(); this.blackboard.SetWorldStateVariable(WorldStateVariable.TARGET_IS_DEAD.ToString(), false); } } }