예제 #1
0
파일: AIBrain.cs 프로젝트: DrMikeCooper/RPG
        // Update is called once per frame
        void Update()
        {
            if (character.dead)
            {
                ai.SetTarget(null);
                return;
            }

            if (character.isHeld())
            {
                ai.SetTarget(null);
            }

            if (countDown > 0)
            {
                countDown -= Time.deltaTime;
                if (character.isHeld() == false && character.target)
                {
                    character.FaceTarget();
                }
                if (debugCountdown)
                {
                    debugCountdown.text = "" + countDown;
                }
            }
            else
            {
                if (character.isHeld())
                {
                    countDown = 1;
                }
                else
                {
                    UpdateEnemies();

                    if (showDebug)
                    {
                        //Debug.Log(RPGSettings.instance.GetHUD(character).debugText.text);
                        RPGSettings.instance.GetHUD(character).ClearDebugText();
                        foreach (Character enemy in enemies)
                        {
                            RPGSettings.instance.GetHUD(enemy).ClearDebugText();
                        }
                        foreach (Character ally in allies)
                        {
                            RPGSettings.instance.GetHUD(ally).ClearDebugText();
                        }
                    }
                    closingRange = 0;

                    //Debug.Log("THINKING...");
                    Power p = rootNode as Power;
                    if (p)
                    {
                        p.npcTarget = null;
                    }

                    AIAction node = rootNode ? rootNode.Execute(this): null;
                    //Debug.Log("...THINKING");
                    countDown = node == null ? 3 : node.GetDuration();
                }
            }

            if (character.activePower)
            {
                character.activePower.OnUpdate(character);
            }

            if (closingRange > 0 && Power.WithinRange(character, closingRange, true))
            {
                countDown = 0;
            }
        }
예제 #2
0
 public override float GetDuration()
 {
     return(bestBehaviour == null ? 3 : bestBehaviour.GetDuration());
 }