Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
    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);
            }
        }
    }