예제 #1
0
 void Start()
 {
     waterSurfaceHeight = waterBody.transform.position.y;
     moctopusTarget     = getoctopusTarget();
     mOctopusState      = octopusState.Move;
     idleCount          = octopus_idleCount;
 }
예제 #2
0
 void GlobalMessage(string message)
 {
     Debug.Log("GlobalMessage :" + message);
     if (message == "pause")
     {
         moctopusPrevState = mOctopusState;
         mOctopusState     = octopusState.Pause;
     }
     else if (message == "play")
     {
         if (mOctopusState == octopusState.Pause)
         {
             mOctopusState = moctopusPrevState;
         }
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log("Move : mOctopusState " + mOctopusState + " for " + tag);         //+ " test_move_count" + test_move_count);
        //test_move_count++;
        if (mOctopusState == octopusState.Pause)
        {
            //Dont move .
        }
        else if (mOctopusState == octopusState.Idle)
        {
            if (my_wound_count > 0)
            {
                mOctopusState = octopusState.Attack;
            }

            idleCount--;

            if (idleCount <= 0)
            {
                moctopusTarget = getoctopusTarget();
                mOctopusState  = octopusState.Move;
            }
        }
        else if (mOctopusState == octopusState.Move)
        {
            distance = Vector3.Distance(moctopusTarget, transform.position);
            if (distance <= 1f)
            {
                idleCount     = octopus_idleCount;
                mOctopusState = octopusState.Idle;
            }
            else if (distance > octopus_swim_radius_x)
            {
                moctopusTarget = getoctopusTarget();
            }

            Vector3 relativePos = moctopusTarget - transform.position;
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(relativePos), Time.deltaTime * angularVelocity);
            transform.Translate(Vector3.forward * Time.deltaTime * MobCurrentSpeed);
            if (my_wound_count > 0)
            {
                mOctopusState = octopusState.Attack;
            }
        }
        else if (mOctopusState == octopusState.Attack)
        {
            Vector3 scaling = new Vector3(0.5F, 0.5f, 0.5f);
            transform.localScale += scaling;

            if (my_wound_count > 3)
            {
                mOctopusState = octopusState.JumpStart;
            }

            growCount++;
            if (growCount > growCountMax)
            {
                mOctopusState = octopusState.JumpStart;
                growCount     = 0;
            }
        }
        else if (mOctopusState == octopusState.JumpStart)
        {
            MobCurrentSpeed = 20f;

            moctopusTarget = new Vector3(ArcoreCamera.transform.position.x,
                                         ArcoreCamera.transform.position.y + 1,
                                         ArcoreCamera.transform.position.z);
            Vector3 relativePos = moctopusTarget - transform.position;
            distance           = Vector3.Distance(moctopusTarget, transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(relativePos), Time.deltaTime * 50);
            // octopus translate in forward direction.
            transform.Translate(Vector3.forward * Time.deltaTime * MobCurrentSpeed);



            if (distance <= 1f)
            {
                mOctopusState = octopusState.Dead;
            }
        }


        else if (mOctopusState == octopusState.Dead)
        {
            deadCount++;
            if (deadCount > deadCountMax)
            {
                moctopusTarget = new Vector3(10f,
                                             waterSurfaceHeight,
                                             10f);

                transform.Translate(moctopusTarget);
                mOctopusState  = octopusState.Move;
                my_wound_count = 0;
                health         = 100;
            }
        }
    }