Example #1
0
 public void Update(AiController aiController)
 {
     if (stateStack.Peek() != null)
     {
         stateStack.Peek().Invoke(this, aiController);
     }
 }
Example #2
0
 private void DoActions(AiController controller)
 {
     for (int i = 0; i < actions.Length; i++)
     {
         actions[i].Act(controller);
     }
 }
Example #3
0
    public override bool perform(AiController controller)
    {
        if (_startTime == 0)
        {
            //Debug.Log("Starting to un equip weapon.");
            _startTime = Time.time;

            controller.iKControl.enableHandIk = false;

            controller.animator.SetTrigger("PutAwayWeapon");
            controller.animator.SetBool("HasWeaponEquiped", false);

            //controller.weaponEquiped = controller.aiInventory.GetBestWeaponFromInventory();
        }

        if ((Time.time - _startTime > controller.animator.GetCurrentAnimatorStateInfo(2).length)) //wait til animation is over
        {
            //Debug.Log("Finished un equipping weapon.");

            controller.weaponHolder.ToggleActiveWeapon(controller.rangedWeaponEquiped, false);
            controller.rangedWeaponEquiped = null;

            _completed = true;
        }

        return(true);
    }
    public override bool perform(AiController controller)
    {
        Debug.Log(controller.animator.GetCurrentAnimatorStateInfo(1).length);
        if (_startTime == 0)
        {
            _targetItem = target.GetComponent <Item>();

            //Debug.Log("Starting to pick up item.");

            _startTime = Time.time;
            controller.animator.SetTrigger(pickUpItem);
        }

        if ((Time.time - _startTime > controller.animator.GetCurrentAnimatorStateInfo(1).length + extraWaitTime)) //wait til animation is over
        {
            //Debug.Log("Picked up item.");

            controller.inventory.AddItemToInventory(_targetItem);

            controller.pickUpAvailable = false; //reset
            _completed = true;
        }

        return(true);
    }
    public override void Tick()
    {
        if (HasLostInterest())
        {
            AiController.Patrol(2.0f);
            return;
        }

        if (LineOfSight.CanSeePlayer)
        {
            OnPlayerSeen(Player.Get.Position);

            // Attack player if possible, or continue pursuing
            if (_attackExecutor.CanHitPlayer())
            {
                _attackExecutor.AttackPlayer();
            }
            else
            {
                PursuePlayer();
            }
        }
        else if (PathFinder.HasPath)
        {
            FollowPath();
        }
        else if (!PathFinder.IsSearchingForPath)
        {
            FindPlayer();
        }
    }
Example #6
0
 public Form1()
 {
     InitializeComponent();
     nodeController = new NodeController();
     aiController   = new AiController();
     PopulateUI();
 }
    internal void Prepare(Player humanPlayer, Player enemyPlayer, MinigameParameters minigameParameters)
    {
        GameTickListeners.Clear();
        MinigameParameters = minigameParameters;

        PanelMageBottom.GetComponent <PanelMage>().Prepare(humanPlayer, this);
        PanelMageTop.GetComponent <PanelMage>().Prepare(enemyPlayer, this);

        LeftCollider.center = new Vector3(Game.Me.W / 2, 0);
        LeftCollider.size   = new Vector3(0, Game.Me.H, 1);

        RightCollider.center = new Vector3(-Game.Me.W / 2, 0);
        RightCollider.size   = new Vector3(0, Game.Me.H);

        TopCollider.center    = new Vector3(0, -Game.Me.H / 2);
        TopCollider.size      = new Vector3(Game.Me.W, 0);
        BottomCollider.center = new Vector3(0, Game.Me.H / 2);
        BottomCollider.size   = new Vector3(Game.Me.W, 0);


        board = new Board(GameObject.FindWithTag("MagImage").GetComponent <Collider>(), GetComponent <RectTransform>(), null, null);
        humanPlayer.Mage.board = board;
        enemyPlayer.Mage.board = board;
        AiController aic = new AiController(board);

        aic.PrepareFight(enemyPlayer.Mage, enemyPlayer.Ai, PanelMageTop.GetComponent <PanelMage>(), PanelMageBottom.GetComponent <PanelMage>());
        GameTickListeners.Add(aic);
    }
Example #8
0
        public override bool perform(AiController controller)
        {
            //if (controller.target || controller.aiVitals.isDead) return false;

            if (_elapsedTime == 0 && !controller.navAgent.hasPath)
            {
                //Debug.Log("Starting to wander.");

                //Debug.Log("Path Calculated for " + controller.name);

                //Debug.Log("Path Set for " + agent.name);
            }
            if (controller.distanceFromTarget <= controller.navAgent.stoppingDistance)
            {
                //Debug.Log("Started waiting.");
                _elapsedTime += Time.deltaTime;

                if (_elapsedTime >= _tempWaitTime)
                {
                    //Debug.Log("Finished waiting.");
                    _completed = true;
                }
            }

            return(true);
        }
Example #9
0
    // After all objects are initialized, Awake is called when the script
    // is being loaded. This occurs before any Start calls.
    // Use Awake instead of the constructor for initialization.
    public void Awake()
    {
        steerings = GetComponents <Steering>();

        if (steerings == null || steerings.Length == 0)
        {
            Debug.Log("No Steering Behaviours");
        }

        motor = GetComponent <Motor>();
        if (motor == null)
        {
            Debug.Log("No Motor");
        }

        movingEntity = GetComponent <MovingEntity>();        // optional
        aiController = GetComponent <AiController>();        // optional

        GameObject mainCamera = GameObject.Find("Main Camera");

        if (mainCamera != null)
        {
            targetedCameras = mainCamera.GetComponents <TargetedCamera>();
        }

        targetRowsPerColumn    = Mathf.Max(3, targetRowsPerColumn);
        behaviourRowsPerColumn = Mathf.Max(1, behaviourRowsPerColumn);
    }
Example #10
0
    bool Look(AiController controller)
    {
        Vector3[] targets = new Vector3[2] {
            controller.GetPlayerPosition(), controller.GetBunkerPosition()
        };

        if (controller.PlayerInFov)
        {
            foreach (Vector3 target in targets)
            {
                var   inDirection = target - controller.Shooting.Muzzle.position;
                float angle       = Vector3.Angle(target - controller.Shooting.Muzzle.position, controller.Shooting.Muzzle.forward);
                if (angle > -(viewAngle / 2) && angle < viewAngle / 2)
                {
                    if (Physics.Raycast(controller.Shooting.Muzzle.position, inDirection, out RaycastHit hit, 999, layerMask))
                    {
                        if (hit.transform.tag == "Player")
                        {
                            controller.chaseTarget = hit.transform.gameObject;
                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }
Example #11
0
    public void spawnEnemies()
    {
        int enemyCount    = GameManager.Instance.m_AiList.Count;
        int enemyCountMax = 9;

        if (enemyCount < enemyCountMax)
        {
            int nbEnemies = Random.Range(3, Mathf.Min(4, enemyCountMax - enemyCount));
            for (int iter = 0; iter < nbEnemies; iter++)
            {
                int        rand      = Random.Range(0, m_SpawnPointList.Count);
                Vector3    randomPos = m_SpawnPointList [rand].position + Random.insideUnitSphere * 3;
                NavMeshHit hit;
                NavMesh.SamplePosition(randomPos, out hit, 4, NavMesh.AllAreas);
                string       key           = m_EnemyKeys [Random.Range(0, 4)];
                GameObject   prefab        = ResourceLoader.Instance.getPrefab(key);
                GameObject   enemyInstance = Instantiate(prefab, hit.position, Quaternion.identity) as GameObject;
                AiController controller    = enemyInstance.GetComponent <AiController> ();
                GameManager.Instance.m_AiList.Add(controller);
                enemyInstance.transform.SetParent(m_EnemyParent);
                enemyInstance.name = "Enemy" + m_EnemyID.ToString();
                m_EnemyID++;
            }
        }
    }
Example #12
0
    public override bool perform(AiController controller)
    {
        if (controller.pickUpAvailable || controller.target || controller.aiVitals.isDead)
        {
            return(false);
        }

        if (_elapsedTime == 0 && !controller.navAgent.hasPath)
        {
            //Debug.Log("Starting to wander.");

            _path = new NavMeshPath();

            NavMesh.CalculatePath(controller.navAgent.transform.position, controller.GetRandomRadialPos(wanderRadius), NavMesh.AllAreas, _path);
            //Debug.Log("Path Calculated for " + agent.name);

            controller.navAgent.SetPath(_path);
            //Debug.Log("Path Set for " + agent.name);
        }
        if (controller.navAgent.remainingDistance <= controller.navAgent.stoppingDistance)
        {
            //Debug.Log("Started waiting.");
            _elapsedTime += Time.deltaTime;

            if (_elapsedTime >= _tempWaitTime)
            {
                //Debug.Log("Finished waiting.");
                controller.navAgent.ResetPath();
                _completed = true;
            }
        }

        return(true);
    }
Example #13
0
        public bool Update(float deltaTime)
        {
            AiController.Update(deltaTime);
            HaveReachedLastWayPoint = AiController.HaveReachedLastWayPoint;

            return(Health <= 0);
        }
Example #14
0
    private IEnumerator CriticalHitRoutine()
    {
        WerewolfAnimator.ReceiveHitMedium();
        WerewolfSoundBank.PlayCriticalHitSound(Random.Range(0.8f, 1.0f));

        AiController.Wait(1.0f);

        yield return(new WaitForSeconds(0.5f));

        _protectiveMode = true;
        WerewolfAnimator.StartProtecting();

        var wasRunning = Motor.IsRunning;

        if (wasRunning)
        {
            Motor.Walk();
        }

        yield return(new WaitForSeconds(4.0f));

        WerewolfAnimator.StopProtecting();
        _protectiveMode = false;

        if (wasRunning)
        {
            Motor.Run();
        }
    }
Example #15
0
 public RequestData(AiController controller, float minRange, float maxRange, RequestCallbackDelegate callback)
 {
     this.controller = controller;
     this.minRange   = minRange;
     this.maxRange   = maxRange;
     this.callback   = callback;
 }
Example #16
0
 public void Awake()
 {
     TraversalMargin = 3;
     movingEntity    = GetComponent <MovingEntity>();
     aiController    = GetComponent <AiController>();
     seek            = GetComponent <Seek>();
     arrive          = GetComponent <Arrive>();
 }
Example #17
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        aiConctroller = animator.gameObject.GetComponent <AiController>();
        agent         = animator.gameObject.GetComponent <NavMeshAgent>();

        agent.destination = aiConctroller.LastTargetLocation;
        doOnce            = false;
    }
Example #18
0
 public BirdBrain(int genome, AiController aiController, Bird bird, Birds birds)
 {
     _genome       = genome;
     _aiController = aiController;
     _bird         = bird;
     _birds        = birds;
     Score         = 0.0f;
 }
Example #19
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        aiConctroller = animator.gameObject.GetComponent <AiController>();
        aiTransform   = animator.transform;
        agent         = animator.gameObject.GetComponent <NavMeshAgent>();

        agent.destination = aiConctroller.Target.transform.position;
    }
Example #20
0
 public Command(AiController aiController, Command parent)
 {
     if (parent != null)
     {
         Parent = parent;
     }
     controller = aiController;
 }
Example #21
0
 private void InitAiControllers()
 {
     {
         TurretAi     ai       = new TurretAi(null);
         AiController turretAi = new AiController(ai);
         AiControllers.Add("TurretAi", turretAi);
     }
 }
    public override bool checkProceduralPrecondition(AiController controller)
    {
        // if(!controller.target || controller.aiVitals.isDead) return false;
        //
        // target = controller.target;

        return(true);
    }
    public void AddAiToColony(AiController ai)
    {
        AddColonistToList(ai);
        ai.playerOwned = true;

        UI_Controller.Instance.colonistPanel.UpdateColonistPanel(ai);
        //add colonist button to UI
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        aiController = animator.gameObject.GetComponent <AiController>();
        agent        = animator.gameObject.GetComponent <NavMeshAgent>();

        agent.destination = aiController.StartingLocation;

        animator.SetBool("CanWander", false);
    }
Example #25
0
        public void RemoveAiController(AiController aiControllerToRemove)
        {
            if (aiControllerToRemove == null)
            {
                return;
            }

            aiControllers.Remove(aiControllerToRemove);
        }
Example #26
0
    public AIPattern(GameObject m, Transform p, Vector3 t, NavMeshAgent n)
    {
        me   = m;
        ctrl = me.GetComponent <AiController>();

        player = p;
        target = t;
        agent  = n;
    }
Example #27
0
        public void addNormalAttack(bool _useAi)
        {
            AiController.SetAi(_useAi);
            var vo = new ActionVo {
                ActionType = Actions.ATTACK
            };

            AttackController.AddAttackList(vo);
        }
    void Start()
    {
        lineRenderer         = GetComponent <LineRenderer>();
        lineRenderer.enabled = false;
        lineRenderer.SetVertexCount(2);

        robot = GameManager.gameManager.Robot;
        ai    = GameManager.gameManager.AI;
    }
    public Threat NewThreatFromTimeEvent(AiController ai)
    {
        TimeEvent timeEvent = manager.GetGameData().timeEventList.FirstOrDefault(x => x.threat.aiController == ai);

        //Debug.Log("NewThreatFromTimeEvent " + timeEvent.threat);

        Threat threat = timeEvent?.threat;

        return(threat);
    }
Example #30
0
    public override void Initialise(Transform[] transforms = null, PairTargets[] pteroGround = null, Transform[] pteroAir = null, Weapon[] weapons = null)
    {
        base.Initialise(transforms, pteroGround, pteroAir);

        agent      = GetComponent <PathFindingAgent>();
        controller = GetComponent <AiController>();
        agent.Init(FindObjectOfType <PathFindingGrid>());
        animator.SetBool("CanAttack", true);
        Destroy(rigidbody);
        targets = transforms;
    }
Example #31
0
    void Awake()
    {
        m_Instance = this;
        m_Body = (GameObject)Instantiate(Resources.Load<GameObject>("Prefabs/AI/AiBody"), new Vector3(2.0f, 2.0f, -1.0f), Quaternion.AngleAxis(0.0f, Vector3.forward));
        m_BodyAi = m_Body.GetComponent<AiBody>();
        m_BodyAi.m_Parent = this;

        m_Head = (GameObject)Instantiate(Resources.Load<GameObject>("Prefabs/AI/AiHead"));
        m_HeadAi = m_Head.GetComponent<AiHead>();
        m_HeadAi.parent = this;
    }
Example #32
0
    static bool Proc_Murder(AiController ai)
    {
        ai.m_Target_Interest -= Time.deltaTime;

        // Handle timeout and/or end event.
        if (ai.m_Target_Interest <= 0.0f || ai.m_Event == EEvent.endMurder)
        {
            ai.m_Event = EEvent.endMurder;
            ai.m_State = EState.none;
            return true;
        }

        return false;
    }
Example #33
0
    static bool Proc_LookAt(AiController ai)
    {
        switch(ai.m_Event)
        {
            case EEvent.none:
                ai.m_Target_Interest -= Time.deltaTime;
                if (ai.m_Target_Interest <= 0.0f)
                {
                    ai.m_Event = EEvent.transition_NewPointOfInterest;
                    ai.m_State = EState.none;
                    GameObject hairGo = GameObject.Find("crosshair") as GameObject;
                    if (hairGo != null)
                    {
                        hairGo.GetComponent<crosshair>().CalmDown();
                    }
                }
                else if (ai.m_HeadAi.lookingAtTarget)    // Wait until the target is being looked at...
                {
                    // Check if the target is in view. If not, invoke seek behaviour.
                    Vector3 direction = ai.m_HeadAi.lookTarget - ai.m_Head.transform.position;
                    float distance = direction.magnitude;
                    // @ JADE >>>>>>>>> COMMECTED THIS OUT SO SHE IS MORE AGGRESSIVE
                    //if (Physics.Raycast(ai.m_Head.transform.position, direction, distance))
                    //{
                    //    // Todo: Analyse the disturbance.
                    //}
                    //else
                    {
                        ai.m_State = EState.none;
                        ai.m_Event = EEvent.transition_Goto;    // Target not in view - go to the target.
                    }
                }
                break;

            default:
                ai.m_State = EState.none;
                return true;
        }

        return false;
    }
Example #34
0
    static bool Proc_Idle(AiController ai)
    {
        switch(ai.m_Event)
        {
            case EEvent.none:
                // Check out something random.
                ai.m_HeadAi.lookTarget = ai.m_BodyAi.moveTarget = new Vector3(Random.Range(-4.5f, 4.5f), Random.Range(1.0f, 2.0f), Random.Range(-4.5f, 4.5f));
                ai.m_Target_Interest = Random.Range(1.0f, 3.0f);

                GameObject hairGo = GameObject.Find("crosshair") as GameObject;
                if (hairGo != null)
                {
                    hairGo.GetComponent<crosshair>().CalmDown();
                }

                ai.m_Event = EEvent.transition_LookAt;
                ai.m_State = EState.none;
                break;

            default:
                ai.m_State = EState.none;
                return true;
        }

        return false;
    }
Example #35
0
    static bool Proc_Goto(AiController ai)
    {
        switch(ai.m_Event)
        {
            case EEvent.none:
                ai.m_Target_Interest -= Time.deltaTime * (ai.m_BodyAi.movedToTarget ? 0.75f : 0.2f);
                if (ai.m_Target_Interest <= 0.0f)
                {
                    ai.m_State = EState.none;
                    GameObject hairGo = GameObject.Find("crosshair") as GameObject;
                    if (hairGo != null)
                    {
                        hairGo.GetComponent<crosshair>().CalmDown();
                    }
                }
                break;

            default:
                ai.m_State = EState.none;
                return true;
        }

        return false;
    }
Example #36
0
    static bool Init_NewPointOfInterest(AiController ai)
    {
        if (ai.m_State != EState.none) Debug.LogError("State is non-null upon switching to new state!");
        ai.m_Event = EEvent.none;   // Consume event.

        if (ai.m_PointOfInterest != null)
        {
            ai.m_HeadAi.lookTarget = ai.m_BodyAi.moveTarget = ai.m_PointOfInterest.m_WorldPoint;
            ai.m_Target_Interest = ai.m_PointOfInterest.m_DisturbanceInSeconds;
            ai.m_PointOfInterest = null;

            //GameObject.Find("crosshair").GetComponent<crosshair>().Chase(ai.m_Target_Look);

            ai.m_Event = EEvent.transition_LookAt;
            return true;
        }

        return false;
    }
Example #37
0
    static bool Init_Murder(AiController ai)
    {
        if (ai.m_State != EState.none) Debug.LogError("State is non-null upon switching to new state!");

        switch (ai.m_Event)
        {
            case EEvent.beginMurder:
                ai.m_Target_Interest = 5.0f;    // Used as a timeout in case the murder does not end.
                ai.m_State = EState.murdering;

                // Disable character controllers.
                foreach (PlayerController player in CGame.Singleton.players)
                {
                    if(player)
                        player.GetComponent<CharacterController>().enabled = false;
                }

                break;

            case EEvent.endMurder:
                ai.m_State = EState.none;
                // Enable character controllers.
                foreach (PlayerController player in CGame.Singleton.players)
                {
                    if(player)
                        player.GetComponent<CharacterController>().enabled = true;
                }

                break;
        }

        ai.m_Event = EEvent.none;   // Consume event.

        ai.m_HeadAi.lookEnable = true;
        ai.m_BodyAi.moveEnable = false;

        return true;
    }
Example #38
0
    static bool Init_LookAt(AiController ai)
    {
        if (ai.m_State != EState.none) Debug.LogError("State is non-null upon switching to new state!");
        ai.m_Event = EEvent.none;   // Consume event.

        ai.m_HeadAi.lookEnable = true;
        ai.m_BodyAi.moveEnable = false;

        ai.m_State = EState.lookingAt;

        return true;
    }
Example #39
0
    // This creates the GUI inside the window.
    // It requires the id of the window it's currently making GUI for.
    private void WindowFunction(int windowID)
    {
        // Draw any Controls inside the window here.

        if (steerings == null || steerings.Length == 0)
        {
            Debug.Log("Getting Steering Behaviours");
            steerings = GetComponents<Steering>();
        }

        if (steerings == null || steerings.Length == 0)
        {
            Debug.Log("No Steering Behaviours");
        }

        if (motor == null)
        {
            Debug.Log("Getting Motor");
            motor = GetComponent<Motor>();
        }

        if (motor == null)
        {
            Debug.Log("No Motor");
            return;
        }

        if (movingEntity == null)
        {
            movingEntity = GetComponent<MovingEntity>(); // optional
        }

        if (aiController == null)
        {
            aiController = GetComponent<AiController>(); // optional
        }

        if (aiController != null)
        {
            if (movingEntity != null && movingEntity.enabled)
            {
                aiController.SetSteering(null);
            }
            else
            {
                aiController.SetSteering(activeSteering);
            }
        }

        if (centeredLabelStyle == null)
        {
            centeredLabelStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
            centeredLabelStyle.alignment = TextAnchor.MiddleCenter;
        }

        GUILayout.BeginHorizontal();

        GUILayout.Label(name, centeredLabelStyle);

        if (GUILayout.Button(motor.isAiControlled ? "is an AI" : "is a Player"))
        {
            motor.isAiControlled = !motor.isAiControlled;
        }

        if (targetedCameras != null && GUILayout.Button("Watch"))
        {
            foreach (TargetedCamera targetedCamera in targetedCameras)
            {
                targetedCamera.target = transform;
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        int behaviourIndex = 0;

        while (behaviourIndex < steerings.Length)
        {
            GUILayout.BeginVertical();

            int behaviourRow = 0;

            while (behaviourRow < behaviourRowsPerColumn && behaviourIndex < steerings.Length)
            {
                if (GUILayout.Button(steerings[behaviourIndex].GetType().Name))
                {
                    foreach (Steering steering in steerings)
                    {
                        if (steering != steerings[behaviourIndex])
                        {
                            steering.enabled = steering.isOn = false;
                        }
                    }

                    steerings[behaviourIndex].enabled = steerings[behaviourIndex].isOn = true;
                    activeSteering = steerings[behaviourIndex];
                    if (aiController != null)
                    {
                        if (movingEntity != null && movingEntity.enabled)
                        {
                            aiController.SetSteering(null);
                        }
                        else
                        {
                            aiController.SetSteering(activeSteering);
                        }
                    }
                }

                behaviourRow++;
                behaviourIndex++;
            }

            GUILayout.EndVertical();
        }

        GUILayout.EndHorizontal();

        int targetRow;
        int targetIndex = 0;

        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical();

        if (GUILayout.Button("None") && activeSteering != null)
        {
            activeSteering.targetObject = null;
            activeSteering.targetPosition = transform.position;
        }

        if (GUILayout.Button("Origin") && activeSteering != null)
        {
            activeSteering.targetObject = null;
            activeSteering.targetPosition = Vector3.zero;
        }

        if (GUILayout.Button("Random") && activeSteering != null)
        {
            activeSteering.targetObject = null;
            activeSteering.targetPosition = Random.insideUnitSphere * 50;
        }

        targetRow = 3;

        while (targetRow < targetRowsPerColumn && targetIndex < targets.Length)
        {
            if (GUILayout.Button(targets[targetIndex].name) && activeSteering != null)
            {
                activeSteering.targetObject = targets[targetIndex];
            }

            targetRow++;
            targetIndex++;
        }

        GUILayout.EndVertical();

        while (targetIndex < targets.Length)
        {
            GUILayout.BeginVertical();

            targetRow = 0;

            while (targetRow < targetRowsPerColumn && targetIndex < targets.Length)
            {
                if (GUILayout.Button(targets[targetIndex].name) && activeSteering != null)
                {
                    activeSteering.targetObject = targets[targetIndex];
                }

                targetRow++;
                targetIndex++;
            }

            GUILayout.EndVertical();
        }

        GUILayout.EndHorizontal();

        // Make the windows be draggable.
        GUI.DragWindow();
    }
Example #40
0
 void OnDestroy()
 {
     m_Instance = null;
 }
Example #41
0
 public void Awake()
 {
     TraversalMargin = 3;
     movingEntity = GetComponent<MovingEntity>();
     aiController = GetComponent<AiController>();
     seek = GetComponent<Seek>();
     arrive = GetComponent<Arrive>();
 }
Example #42
0
    // After all objects are initialized, Awake is called when the script
    // is being loaded. This occurs before any Start calls.
    // Use Awake instead of the constructor for initialization.
    public void Awake()
    {
        steerings = GetComponents<Steering>();

        if (steerings == null || steerings.Length == 0)
        {
            Debug.Log("No Steering Behaviours");
        }

        motor = GetComponent<Motor>();
        if (motor == null)
        {
            Debug.Log("No Motor");
        }

        movingEntity = GetComponent<MovingEntity>(); // optional
        aiController = GetComponent<AiController>(); // optional

        GameObject mainCamera = GameObject.Find("Main Camera");
        if (mainCamera != null)
        {
            targetedCameras = mainCamera.GetComponents<TargetedCamera>();
        }

        targetRowsPerColumn = Mathf.Max(3, targetRowsPerColumn);
        behaviourRowsPerColumn = Mathf.Max(1, behaviourRowsPerColumn);
    }
Example #43
0
    static bool Init_Disturbance(AiController ai)
    {
        if (ai.m_State != EState.none) Debug.LogError("State is non-null upon switching to new state!");

        switch (ai.m_Event)
        {
            case EEvent.heardDisturbance:
                // Todo: Say "What was that?"
                break;

            case EEvent.sawDisturbance:
                // Todo: Say "That's odd..."
                break;
        }

        ai.m_Event = EEvent.transition_NewPointOfInterest;

        return true;
    }