Exemple #1
0
    IEnumerator MoveLoop()
    {
        if (mPlayer == null)
        {
            mDirection = Vector3.zero;
        }
        else
        {
            mDirection = mPlayer.transform.position - transform.position;
        }

        if (!tracker.isTimerPause() && !tracker.isTimesUp())
        {
            // 怪物移動方式分四步驟,蹲下、起立以及跳躍、墜落
            yield return(StartCoroutine(CrouchDown()));

            yield return(StartCoroutine(CrouchUp()));

            yield return(StartCoroutine(JumpUp()));

            yield return(StartCoroutine(JumpDown()));

            // 若怪物踩到地洞,則死亡
            GameObject floorCube = mCubes[mMonsterFloorCubeIndex];
            if (floorCube.CompareTag(GameBehaviour.TAG_HOLE))
            {
                Destroy(gameObject);
            }
        }
        // 怪物每次移動後的時間間隔
        yield return(StartCoroutine(Delay()));

        StartCoroutine(MoveLoop());
    }
Exemple #2
0
    void FixedUpdate()
    {
        if (!tracker.isTimerPause() && !tracker.isTimesUp())
        {
            // 發射砲彈
            if (mBombInstance == null && Time.time >= mNextFire)
            {
                mBombInstance = Instantiate(mBomb) as GameObject;
                mBombInstance.transform.parent   = transform;
                mBombInstance.transform.position = mStar.position;
                mBombInstance.GetComponent <Rigidbody> ().AddForce(mBombDirection * mFireForce);

                if (mBombDirection.x > 0f)
                {
                    mBombInstance.GetComponent <BombAI> ().SetDirection(GameBehaviour.Direction.RIGHT);
                }
                else if (mBombDirection.x < 0f)
                {
                    mBombInstance.GetComponent <BombAI> ().SetDirection(GameBehaviour.Direction.LEFT);
                }
                else if (mBombDirection.z > 0f)
                {
                    mBombInstance.GetComponent <BombAI> ().SetDirection(GameBehaviour.Direction.FORWARD);
                }
                else if (mBombDirection.z < 0f)
                {
                    mBombInstance.GetComponent <BombAI> ().SetDirection(GameBehaviour.Direction.BACKWARD);
                }


                mNextFire = Time.time + mFireRate;
            }
        }
    }
Exemple #3
0
    IEnumerator MoveLoop()
    {
        if (!tracker.isTimerPause() && !tracker.isTimesUp())
        {
            yield return(StartCoroutine(Go()));

            yield return(StartCoroutine(Delay()));

            yield return(StartCoroutine(Back()));
        }

        yield return(StartCoroutine(Delay()));

        GameObject nextFloorCube = mCubes[mChessFloorCubeIndex + (int)mDirX + (int)mDirZ * 12 - 1];

        if (!nextFloorCube.CompareTag(GameBehaviour.TAG_HOLE))
        {
            StartCoroutine(MoveLoop());
        }
    }