Exemplo n.º 1
0
    void DidReachedMaxJumpHeight()
    {
        //Debug.Log("Reached Max Height");
        //Time to check we are diving in water!

        if (m_Room != null)
        {
            RoomEx.RoomType type = m_Room.GetRoomType();
            //Debug.Log("Are we diving in :" + type);

            if (type == RoomEx.RoomType.DeepWater)
            {
                //change animation state dive
                if (m_AnimStatePlayer != null)
                {
                    m_AnimStatePlayer.Dive();
                }
            }
        }
    }
Exemplo n.º 2
0
    /*function OnCollisionEnter(collision : Collision) {
     *          // Debug-draw all contact points and normals
     *          for (var contact : ContactPoint in collision.contacts)
     *                  Debug.DrawRay(contact.point, contact.normal, Color.white);
     *
     *          // Play a sound if the coliding objects had a big impact.
     *          if (collision.relativeVelocity.magnitude > 2)
     *                  audio.Play();
     *  }
     *
     *
     *  function OnTriggerEnter (other : Collider) {
     *          Destroy(other.gameObject);
     *  }*/


    public void SetSwimState(RoomEx room)
    {
        //return;
        if (IsAvoidingFall() && /*bugfix: except jump*/ (m_bJumping == false)) //dont pull into swimming state when trying to getout of water
        {
            if (m_SwimState == SwimmingState.InWaterSurface)
            {
                //Debug.Log("Getting outof water");
            }
            return;
        }

        if (room == null)
        {
            return;
        }

        if (room != null)
        {
            float surface = room.GetCenterPoint().y;
            if (surface < m_WaterLevel)
            {
                m_WaterLevel = surface;
                SetSwimStateNone();
                Debug.Log("Water Level Changed");
                return;
            }
        }

        if (room != null && (m_bFreeFall || m_bJumping) && (m_SwimState == SwimmingState.None || m_SwimState == SwimmingState.Diving))          //set initial swim state (works only when current room type is Land, not water
        {
            RoomEx.RoomType type = room.GetRoomType();
            m_WaterLevel = room.GetCenterPoint().y;
            //Debug.Log("Room Type:" + type);
            Vector3 heappos = GetHipPosition();

            Bounds room_bound      = room.GetBound();
            float  min_fall_height = room_bound.min.y + room_bound.size.y * 0.1f;

            if ((m_Transform.position.y < (m_WaterLevel - m_Height * 0.3f)) && (type == RoomEx.RoomType.DeepWater))              //enter swimming state machine
            {
                if (m_AnimStatePlayer != null)
                {
                    m_AnimStatePlayer.PlayDiveSFX();
                }
                SetSwimStateDeepWater();
                StopImmediate(null);
            }
            else if ((m_Transform.position.y < min_fall_height) && (type == RoomEx.RoomType.ShalloWater))
            {
                if (heappos.y < m_WaterLevel) //hip is inside water
                {
                    if (m_AnimStatePlayer != null)
                    {
                        m_AnimStatePlayer.PlayDiveSFX();
                    }

                    SetSwimStateShallowWater();
                    StopImmediate(null);
                }
                else
                {
                }
            }
        }



        if (room != null && ((room.Flags & 1) == 1))
        {
            /*if(m_SwimState != SwimmingState.InShallowWater)
             *          {
             *              SetSwimStateShallowWater();
             *          }*/

            float surface = room.GetCenterPoint().y;

            //if ((surface - transform.position.y) > 0.1f && (m_SwimState == SwimmingState.InWaterSurface))
            //{
            //SetSwimStateDeepWater();
            //}

            if (m_SwimState == SwimmingState.InDeepWater)
            {
                if (transform.position.y >= (surface - 0.05f))
                {
                    SetSwimStateSurfaceWater();
                }
            }

            /*if((surface - m_Transform.position.y) >  0.35f  && (m_SwimState == SwimmingState.None))
             *          {
             *                  SetSwimStateShallowWater();
             *          }*/

            if (m_SwimState == SwimmingState.InWaterSurface)
            {
                //Grab ledge and get outof water
                if (m_bStandingUp || m_bPullingUp)
                {
                    //m_SwimState = SwimmingState.None;
                }
            }

            //define shallow water analyzing tub depth


            //Debug.Log("room.m_Tr2Room.info.yTop " + (-room.m_Tr2Room.info.yTop * Settings.SceneScaling));
            //Debug.Log("room.m_Tr2Room.info.yBottom " + (-room.m_Tr2Room.info.yBottom * Settings.SceneScaling));
        }
        else
        {
            //SetSwimStateNone();
            //StopImmediate();
        }


        /*
         * [from state jumping/diving]
         *
         * dive in shallow water ->
         *
         * dive in deep water - >
         *
         * */

        /*
         *
         * [from state in shallow water]
         *
         * Jump->
         * trytorun->
         *
         * */


        /*
         *
         * [from state deep water]
         *
         * swim->
         * swim to shallow water->
         * move to surface->
         *
         * */


        /*
         *
         * [from state surface]
         *
         * move-> grab platform -> pull up
         *
         * */

        //Debug.Log("Swimm State:" + m_SwimState);
    }