Esempio n. 1
0
    public override void Act(GameObject player, AgentHandler agent)
    {
        agent.mState = "Attack";
        //Attack the Player
        agent.BoidController.SetTarget(player.transform.position);
        agent.BoidController.SetShouldFlock(false);
        float range = agent.GetTargetTooCloseRange();

        if ((range * range) > (player.transform.position - agent.transform.position).sqrMagnitude)
        {
            agent.BoidController.FleePoint(player.transform.position, 5f);
        }

        EditableTree BasicAgentAttackTree = agent.GetBasicAgentDecisionTree();

        if (BasicAgentAttackTree != null)
        {
            BasicAgentAttackTree.mRoot.MakeDecision(agent);
        }
    }
Esempio n. 2
0
    public override void Reason(GameObject player, AgentHandler agent)
    {
        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agent.transform.position;

        if (Physics.Raycast(agent.transform.position, directionToPlayer.normalized, directionToPlayer.magnitude, LayerMask.GetMask("Default")))
        {
            agent.FSMTransitionPassthrough(fsmTransition.ToLostPlayer);
        }
        else
        {
            EditableTree SwitchToAttackDecisionTree = agent.GetSwitchToAttackDecisionTree();

            if (SwitchToAttackDecisionTree != null)
            {
                SwitchToAttackDecisionTree.mRoot.MakeDecision(agent);
            }

            //if (directionToPlayer.magnitude <= agent.GetAttackRange())
            //agent.FSMTransitionPassthrough(fsmTransition.ToAttack);
        }
    }