Exemple #1
0
        public override void Enter(SimpleBallManFSM agent)
        {
            NavMeshAgent nav_agent = agent.GetComponent <NavMeshAgent>();

            if (nav_agent)
            {
                Collider[] entities = Physics.OverlapSphere(agent.transform.position, agent.SearchRadius, agent.InteractableLayers);

                nav_agent.ResetPath();

                foreach (Collider entity in entities)
                {
                    NestScaler nest = entity.GetComponentInParent <NestScaler>();

                    if (nest != null)
                    {
                        nav_agent.SetDestination(nest.transform.position);
                        Debug.Log(agent.transform.name + " sees its nest (" + nest.transform.name + ") and is heading toward it!");

                        return;
                    }
                }

                Debug.Log(agent.transform.name + " doesn't see his home. :'(");
            }
            else
            {
                Debug.LogError(agent.transform.name + " [ReturnToNestState]: No NavMeshAgent found!");
            }
        }
Exemple #2
0
        public override void Run(SimpleBallManFSM agent)
        {
            NavMeshAgent nav_agent = agent.GetComponent <NavMeshAgent>();

            Collider[] entities = Physics.OverlapSphere(agent.transform.position, agent.InteractionRadius, agent.InteractableLayers);

            foreach (Collider entity in entities)
            {
                NestScaler nest = entity.GetComponentInParent <NestScaler>();

                if (nest != null)
                {
                    nest.Resources    += agent.CrystalsHeld;
                    agent.CrystalsHeld = 0;

                    Debug.Log(agent.transform.name + " deposited his crystals in his nest.");

                    if (agent.Exhaustion < 5)
                    {
                        agent.ChangeState(SleepState.Instance);
                    }
                    else if (agent.Hunger >= 8)
                    {
                        agent.ChangeState(FindCrystalState.Instance);
                    }
                    else
                    {
                        agent.ChangeState(FindFoodState.Instance);
                    }

                    return;
                }
            }

            if (nav_agent && nav_agent.hasPath)
            {
                Debug.Log(agent.transform.name + " is heading towards his nest!");
            }
            else
            {
                Debug.Log(agent.transform.name + " is lost...");
            }
        }
Exemple #3
0
        public override void Run(SimpleBallManFSM agent)
        {
            Collider[] entities = Physics.OverlapSphere(agent.transform.position, agent.InteractionRadius, agent.InteractableLayers);

            foreach (Collider entity in entities)
            {
                NestScaler nest = entity.GetComponentInParent <NestScaler>();

                if (nest != null)
                {
                    if (agent.Exhaustion < 50)
                    {
                        if (agent.Hunger > 0)
                        {
                            --agent.Hunger;
                        }

                        agent.Exhaustion += 5;

                        Debug.Log(agent.transform.name + " zzzzzzzz ...");
                    }
                    else if (agent.Hunger < 8)
                    {
                        agent.ChangeState(FindFoodState.Instance);
                    }
                    else
                    {
                        agent.ChangeState(FindCrystalState.Instance);
                    }

                    return;
                }
            }

            agent.ChangeState(ReturnToNestState.Instance);
        }