Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        lvl1_GB.WorldBoundStatus status =
            mGameManager.ObjectCollideWorldBound(GetComponent <Renderer>().bounds);

        if (status != lvl1_GB.WorldBoundStatus.Inside)
        {
            Destroy(this.gameObject);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        transform.position += (mSpeed * transform.up * Time.smoothDeltaTime);
        lvl1_GB.WorldBoundStatus status =
            mGameManager.ObjectCollideWorldBound(GetComponent <Renderer>().bounds);

        if (status != lvl1_GB.WorldBoundStatus.Inside)
        {
            mGameManager.subtractEggCount();
            Destroy(this.gameObject);
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        // Clamp
        lvl1_GB.WorldBoundStatus status =
            mGameManager.ObjectCollideWorldBound(GetComponent <Renderer>().bounds);
        if (status != lvl1_GB.WorldBoundStatus.Inside)
        {
            NewDirection();
        }

        //State Change
        #region State Change
        Vector3 toHero = transform.position - mHero.transform.position;
        float   dot    = Vector3.Dot(toHero, mHero.transform.up);
        if (mState == EnemyState.Stunned && Time.realtimeSinceStartup - mTimeStunned < kStunnedDuration)
        {
            mState = EnemyState.Stunned;
            if (null != mRenderder)
            {
                mRenderder.sprite = Resources.Load("Textures/stunned_student", typeof(Sprite)) as Sprite;
            }
        }
        else
        {
            if (toHero.magnitude <= 30.0f && dot > 0) // RUN
            {
                if (mState != EnemyState.Run)
                {
                    var         source = GetComponents <AudioSource>();
                    AudioSource no     = source[1];
                    no.Play();
                }

                mState = EnemyState.Run;
                if (null != mRenderder)
                {
                    mRenderder.sprite = Resources.Load("Textures/running_student", typeof(Sprite)) as Sprite;
                }
            }
            else if (mState == EnemyState.Scary || wasScary)
            {
                mState = EnemyState.Scary;
                if (null != mRenderder)
                {
                    mRenderder.sprite = Resources.Load("Textures/scary_student", typeof(Sprite)) as Sprite;
                }
            }
            else // Normal
            {
                mState = EnemyState.Normal;
                if (null != mRenderder)
                {
                    mRenderder.sprite = Resources.Load("Textures/student", typeof(Sprite)) as Sprite;
                }
            }
        }
        #endregion


        // Movement
        #region movements
        if (mState == EnemyState.Normal || mState == EnemyState.Scary)
        {
            Move();
        }
        else if (mState == EnemyState.Run)
        {
            RunAway();
        }
        else
        {
            Rotate();
        }
        #endregion
    }