Ejemplo n.º 1
0
    IEnumerator Go()
    {
        mCubes[mChessFloorCubeIndex - 1].tag = GameBehaviour.TAG_UNTAGGED;
        mChessFloorCubeIndex += (int)mDirX + (int)mDirZ * 12;

        mCubes[mChessFloorCubeIndex - 1].tag = GameBehaviour.TAG_OBSTACLE;

        for (int i = 0; i < 10; i++)
        {
            transform.Translate(mDirX * 0.1f, 0f, mDirZ * 0.1f);
            yield return(null);
        }

        mDirX *= -1;
        mDirZ *= -1;

        if (mDirection == 0)
        {
            mStepDirection = GameBehaviour.Direction.LEFT;
        }
        else if (mDirection == 1)
        {
            mStepDirection = GameBehaviour.Direction.RIGHT;
        }
        else if (mDirection == 2)
        {
            mStepDirection = GameBehaviour.Direction.BACKWARD;
        }
        else if (mDirection == 3)
        {
            mStepDirection = GameBehaviour.Direction.FORWARD;
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        GameBehaviour.ICubesHandler ich = transform.parent.GetComponent <FloorControl>();

        mCubes = new GameObject[144];

        for (int i = 0; i < 144; i++)
        {
            mCubes[i] = ich.getFloorCube(i + 1);
        }

        while (true)
        {
            mDirection = Random.Range(0, 4);
            if (mOkDirection [mDirection])
            {
                break;
            }
        }

        if (mDirection == 0)
        {
            mDirX          = 1f;
            mStepDirection = GameBehaviour.Direction.RIGHT;
        }
        else if (mDirection == 1)
        {
            mDirX          = -1f;
            mStepDirection = GameBehaviour.Direction.LEFT;
        }
        else if (mDirection == 2)
        {
            mDirZ          = 1f;
            mStepDirection = GameBehaviour.Direction.FORWARD;
        }
        else if (mDirection == 3)
        {
            mDirZ          = -1f;
            mStepDirection = GameBehaviour.Direction.BACKWARD;
        }

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

        if (!nextFloorCube.CompareTag(GameBehaviour.TAG_HOLE))
        {
            StartCoroutine(MoveLoop());
        }
    }
Ejemplo n.º 3
0
 public void SetDirection(GameBehaviour.Direction d)
 {
     mDirection = d;
 }
Ejemplo n.º 4
0
 // 墜落動畫
 IEnumerator JumpDown()
 {
     if (Mathf.Abs((int)mDirection.x) >= Mathf.Abs((int)mDirection.z) && ((int)mDirection.x != 0 || (int)mDirection.z != 0))
     {
         if ((int)mDirection.x >= 0)
         {
             GameObject floorCube = mCubes[mMonsterFloorCubeIndex + 1];
             if (!floorCube.CompareTag(GameBehaviour.TAG_OBSTACLE))
             {
                 for (int i = 0; i < mMonsterSpeed; i++)
                 {
                     transform.position   = new Vector3(transform.position.x + 0.5f / mMonsterSpeed, transform.position.y - 3f / mMonsterSpeed, transform.position.z);
                     transform.localScale = new Vector3(transform.localScale.x + 0.5f / mMonsterSpeed, transform.localScale.y - 0.2f / mMonsterSpeed, transform.localScale.z + 0.5f / mMonsterSpeed);
                     yield return(null);
                 }
                 mMonsterFloorCubeIndex += 1;
                 mStepDirection          = GameBehaviour.Direction.RIGHT;
             }
         }
         else
         {
             GameObject floorCube = mCubes[mMonsterFloorCubeIndex - 1];
             if (!floorCube.CompareTag(GameBehaviour.TAG_OBSTACLE))
             {
                 for (int i = 0; i < mMonsterSpeed; i++)
                 {
                     transform.position   = new Vector3(transform.position.x - 0.5f / mMonsterSpeed, transform.position.y - 3f / mMonsterSpeed, transform.position.z);
                     transform.localScale = new Vector3(transform.localScale.x + 0.5f / mMonsterSpeed, transform.localScale.y - 0.2f / mMonsterSpeed, transform.localScale.z + 0.5f / mMonsterSpeed);
                     yield return(null);
                 }
                 mMonsterFloorCubeIndex -= 1;
                 mStepDirection          = GameBehaviour.Direction.LEFT;
             }
         }
     }
     else if (Mathf.Abs((int)mDirection.x) < Mathf.Abs((int)mDirection.z))
     {
         if ((int)mDirection.z >= 0)
         {
             GameObject floorCube = mCubes[mMonsterFloorCubeIndex + 12];
             if (!floorCube.CompareTag(GameBehaviour.TAG_OBSTACLE))
             {
                 for (int i = 0; i < mMonsterSpeed; i++)
                 {
                     transform.position   = new Vector3(transform.position.x, transform.position.y - 3f / mMonsterSpeed, transform.position.z + 0.5f / mMonsterSpeed);
                     transform.localScale = new Vector3(transform.localScale.x + 0.5f / mMonsterSpeed, transform.localScale.y - 0.2f / mMonsterSpeed, transform.localScale.z + 0.5f / mMonsterSpeed);
                     yield return(null);
                 }
                 mMonsterFloorCubeIndex += 12;
                 mStepDirection          = GameBehaviour.Direction.FORWARD;
             }
         }
         else
         {
             GameObject floorCube = mCubes[mMonsterFloorCubeIndex - 12];
             if (!floorCube.CompareTag(GameBehaviour.TAG_OBSTACLE))
             {
                 for (int i = 0; i < mMonsterSpeed; i++)
                 {
                     transform.position   = new Vector3(transform.position.x, transform.position.y - 3f / mMonsterSpeed, transform.position.z - 0.5f / mMonsterSpeed);
                     transform.localScale = new Vector3(transform.localScale.x + 0.5f / mMonsterSpeed, transform.localScale.y - 0.2f / mMonsterSpeed, transform.localScale.z + 0.5f / mMonsterSpeed);
                     yield return(null);
                 }
                 mMonsterFloorCubeIndex -= 12;
                 mStepDirection          = GameBehaviour.Direction.BACKWARD;
             }
         }
     }
     else
     {
         for (int i = 0; i < mMonsterSpeed; i++)
         {
             transform.position   = new Vector3(transform.position.x, transform.position.y - 3f / mMonsterSpeed, transform.position.z);
             transform.localScale = new Vector3(transform.localScale.x + 0.5f / mMonsterSpeed, transform.localScale.y - 0.2f / mMonsterSpeed, transform.localScale.z + 0.5f / mMonsterSpeed);
             yield return(null);
         }
     }
 }