示例#1
0
    // Use this for initialization
    void Start()
    {
        //references
        //
        m_player = GameObject.Find("Player").GetComponent <PlayerScript>();

        //nav agent
        //
        m_navAgent     = GetComponent <NavMeshAgent>();
        m_anchor       = transform.position;
        m_target       = m_anchor;
        m_defaultSpeed = m_navAgent.speed;

        //viewbox
        //
        m_viewbox = GetComponent <BoxCollider>();

        //state controller
        //
        m_SC = new StateContoller(this);
        m_SC.transition(PASSIVE);

        //sounds
        //
        m_staticSource.Play();
    }
 public override void init()
 {
     base.init();
     m_SC = new StateContoller(this);
     m_SC.transition(OFF);
     m_canInteract = false;
 }
示例#3
0
    public override void init()
    {
        base.init();
        m_SC = new StateContoller(this);
        m_SC.transition(INACTIVE);

        m_player      = GameObject.Find("Player").GetComponent <PlayerScript>();
        m_activeLight = GetComponentInChildren <Light>();
        m_canInteract = false;

        lightMaterial = lightModel.GetComponent <MeshRenderer>().materials[1];
    }
    // Use this for initialization
    void Start()
    {
        //make sure the badboi doesn't spawn if the level isn't high enough
        if (GameManager.currentStage < m_minLevelToSpawn)
        {
            gameObject.SetActive(false);
            return;
        }

        m_player = GameObject.Find("Player").GetComponent <PlayerScript>();

        //nav agent
        //
        Debug.Assert(m_patrolPoints.Length > 1, "Need at least two patrol points!");
        m_navAgent = GetComponent <NavMeshAgent>();
        //for each point, align with navmesh...
        foreach (Transform t in m_patrolPoints)
        {
            NavMeshHit hit;
            if (NavMesh.SamplePosition(t.position, out hit, float.MaxValue, int.MaxValue))
            {
                t.position = hit.position;
            }
            else
            {
                Debug.Log("Cannot align patrol point with navmesh");
            }
        }
        m_dir              = -1;
        m_curTarget        = 0;
        transform.position = m_patrolPoints[0].position;
        m_defaultSpeed     = m_navAgent.speed;

        //viewbox
        //
        m_viewbox = GetComponent <BoxCollider>();

        //state controller
        //
        m_SC = new StateContoller(this);
        m_SC.transition(PATROL);

        //start patrol
        //
        setNextPatrolTarget();
    }