Exemplo n.º 1
0
        public override void Update()
        {
            m_MissionSteps--;

            if (m_MissionSteps <= 0)
            {
                /*if ((m_MissionType & RUN) > 0)
                    m_Pose.m_MaxSpd /= 1.5f;*/
                switch (Core.Singleton.Rand.Next() % 10)
                {
                    case 0:
                    case 1:
                    case 2:
                        m_MissionSteps = Core.Singleton.Rand.Next(5, 10);
                        if (Core.Singleton.Rand.Next() % 2 == 0)
                            m_MissionType = GO_LEFT;
                        else
                            m_MissionType = GO_RIGHT;
                        if (Core.Singleton.Rand.Next() % 2 == 0)
                            m_MissionType += GO_AHEAD;
                        break;
                    case 3:
                    case 4:
                    case 5:
                        m_MissionSteps = Core.Singleton.Rand.Next(20, 60);
                        m_MissionType = GO_AHEAD;
                        break;
                    case 6:
                        m_MissionSteps = Core.Singleton.Rand.Next(30, 120);
                        m_MissionType = RUN;
                        //m_Pose.m_MaxSpd *= 1.5f;
                        break;
                    default:
                        m_MissionSteps = Core.Singleton.Rand.Next(20, 60);
                        m_MissionType = 0;
                        break;
                }
            }

            //m_GoTo = m_LookingAt;
            bool activateidle = true;

            if ((m_MissionType & GO_AHEAD) > 0)
            {
                m_Pose.willForward();
                activateidle = false;
            }
            if ((m_MissionType & RUN) > 0)
            {
                m_Pose.willForward();
                activateidle = false;
            }
            if ((m_MissionType & GO_LEFT) > 0)
            {
                m_Pose.willTurnLeft();
            }
            if ((m_MissionType & GO_RIGHT) > 0)
            {
                m_Pose.willTurnRight();
            }

            if (activateidle == true && m_Pose == m_myPoses["normal"])
            {
                if (!m_MainBody.Velocity.IsZeroLength)
                {//nie zatrzymal sie jeszcze to go zatrzymujemy
                    Mogre.Vector3 xyVector = new Mogre.Vector3(0, 0, 1);
                    Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1);
                    Mogre.Quaternion ForceDirection = xyVector.GetRotationTo(velocityxy);
                    Mogre.Vector3 StoppingForce = -ForceDirection * Mogre.Vector3.UNIT_Z * m_MainBody.Mass * 6;
                    m_MainBody.AddForce(-StoppingForce);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void BodyForceCallback(MogreNewt.Body body, float timeStep, int threadIndex)
        {
            //calling each physics iteration

            //testuje jak dawno dotykal gruntu jezeli wartosc przekracza 5 lub 10 iteracji fiyzki
            //zmienia pozycje na lot
            if (m_Onground < 10)
                m_Onground++;
            else//jest w locie - zmieniamy mu stan
                ChangePoseTo("fly");

            if (m_jumpLimit > 0)
                m_jumpLimit--;

            //obnizanie poziomu adrenaliny o staly czynnik
            if (m_adrenaline > 1)
                m_adrenaline -= 0.01f * timeStep;
            else
                m_adrenaline = 1;

            Update();

            //trying to stop body in one position
            if (!m_bBackward && !m_bForward && !m_bLeft && !m_bRight)
            {
                if (!m_MainBody.Velocity.IsZeroLength)
                {//nie zatrzymal sie jeszcze to go zatrzymujemy
                    //dla bardzo malych predksoci dac cos w stylu velocity 0 ... albo wprowadzic
                    //punkt zatrzymania (x,y,z) dla velocity < 0.00001
                    Mogre.Vector3 xyVector = new Mogre.Vector3(0, 0, 1);
                    Mogre.Vector3 velocityxy = m_MainBody.Velocity * new Mogre.Vector3(1, 0, 1);
                    Mogre.Quaternion ForceDirection = xyVector.GetRotationTo(velocityxy);
                    Mogre.Vector3 StoppingForce = -ForceDirection * Mogre.Vector3.UNIT_Z * m_MainBody.Mass * m_Pose.m_ForceStop;
                    m_MainBody.AddForce(-StoppingForce);
                }
            }
        }