Esempio n. 1
0
    private void InitGravity()
    {
        float num1 = GameUtility.CalcDistance2D(Vector3.op_Subtraction(this.GoalPosition, this.mStartPosition));

        this.TopHeight = Mathf.Max(this.TopHeight, Mathf.Max((float)(this.mStartPosition.y + 0.100000001490116), (float)(this.GoalPosition.y + 0.100000001490116)));
        float num2 = this.TopHeight - (float)this.GoalPosition.y;
        float num3 = (float)(this.mStartPosition.y - this.GoalPosition.y);
        float num4 = (float)(2.0 * (double)this.G * ((double)num2 - (double)num3));
        float num5 = 2f * this.G * num2;
        float num6 = (double)num4 <= 0.0 ? 0.0f : Mathf.Sqrt(num4);
        float num7 = (double)num5 <= 0.0 ? 0.0f : Mathf.Sqrt(num5);

        this.mMoveTime = (num6 + num7) / this.G;
        float num8 = Mathf.Sin(Mathf.Atan(this.mMoveTime * num6 / num1));

        this.mStartSpeed  = Mathf.Sqrt(Mathf.Pow(num1 / this.mMoveTime, 2f) + (float)(2.0 * (double)this.G * ((double)num2 - (double)num3)));
        this.mStartSpeed *= num8;
    }
        protected bool UpdateMove()
        {
            bool flag = true;

            if (!UnityEngine.Object.op_Implicit((UnityEngine.Object) this.mController))
            {
                return(false);
            }
            if (this.m_WayPoints.Length > this.mMoveIndex)
            {
                Vector3 position  = ((Component)this.mController).get_transform().get_position();
                Vector3 vector3_1 = Vector3.op_Subtraction(this.m_WayPoints[this.mMoveIndex], position);
                // ISSUE: explicit reference operation
                if ((double)((Vector3)@vector3_1).get_sqrMagnitude() < 9.99999974737875E-05)
                {
                    if (++this.mMoveIndex >= this.m_WayPoints.Length)
                    {
                        if (!this.LockMotion)
                        {
                            this.mController.StopRunning();
                        }
                        flag = false;
                    }
                }
                else
                {
                    // ISSUE: explicit reference operation
                    ((Vector3)@vector3_1).Normalize();
                    Vector3 a = Vector3.op_Addition(position, Vector3.op_Multiply(Vector3.op_Multiply(vector3_1, this.RunSpeed), Time.get_deltaTime()));
                    ((Component)this.mController).get_transform().set_position(a);
                    if (!this.LockRotation)
                    {
                        float num1 = GameUtility.CalcDistance2D(a, this.m_WayPoints[this.mMoveIndex]);
                        if ((double)num1 < 0.5 && this.mMoveIndex < this.m_WayPoints.Length - 1)
                        {
                            Vector3 vector3_2 = Vector3.op_Subtraction(this.m_WayPoints[this.mMoveIndex + 1], this.m_WayPoints[this.mMoveIndex]);
                            vector3_2.y = (__Null)0.0;
                            // ISSUE: explicit reference operation
                            ((Vector3)@vector3_2).Normalize();
                            float num2 = (float)((1.0 - (double)num1 / 0.5) * 0.5);
                            ((Component)this.mController).get_transform().set_rotation(Quaternion.Slerp(Quaternion.LookRotation(vector3_1), Quaternion.LookRotation(vector3_2), num2));
                        }
                        else if (this.mMoveIndex > 1)
                        {
                            float num2 = GameUtility.CalcDistance2D(a, this.m_WayPoints[this.mMoveIndex - 1]);
                            if ((double)num2 < 0.5)
                            {
                                Vector3 vector3_2 = Vector3.op_Subtraction(this.m_WayPoints[this.mMoveIndex - 1], this.m_WayPoints[this.mMoveIndex - 2]);
                                vector3_2.y = (__Null)0.0;
                                // ISSUE: explicit reference operation
                                ((Vector3)@vector3_2).Normalize();
                                float num3 = (float)(0.5 + (double)num2 / 0.5 * 0.5);
                                ((Component)this.mController).get_transform().set_rotation(Quaternion.Slerp(Quaternion.LookRotation(vector3_2), Quaternion.LookRotation(vector3_1), num3));
                            }
                            else
                            {
                                ((Component)this.mController).get_transform().set_rotation(Quaternion.LookRotation(vector3_1));
                            }
                        }
                        else
                        {
                            ((Component)this.mController).get_transform().set_rotation(Quaternion.LookRotation(vector3_1));
                        }
                    }
                }
            }
            return(flag);
        }
 protected void StartMove()
 {
     if (this.GotoRealPosition && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.mController, (UnityEngine.Object)null) && this.mController.Unit != null)
     {
         Array.Resize <Vector3>(ref this.m_WayPoints, this.m_WayPoints.Length + 1);
         this.m_WayPoints[this.m_WayPoints.Length - 1] = new Vector3((float)this.mController.Unit.x, 0.0f, (float)this.mController.Unit.y);
     }
     else
     {
         this.GotoRealPosition = false;
     }
     if (this.m_WayPoints.Length == 1)
     {
         this.timeAtPointList.Add(0.0f);
     }
     else
     {
         for (int index = 0; index < this.m_WayPoints.Length - 1; ++index)
         {
             this.distanceList.Add(!this.GroundSnap ? Vector3.Distance(this.m_WayPoints[index], this.m_WayPoints[index + 1]) : GameUtility.CalcDistance2D(this.m_WayPoints[index], this.m_WayPoints[index + 1]));
         }
         float num1 = 0.0f;
         for (int index = 0; index < this.distanceList.Count; ++index)
         {
             num1 += this.distanceList[index];
         }
         float num2 = this.RunType != EventAction_MoveActorWithAnime2.RunTypes.Time ? num1 / this.RunSpeed : this.RunTime;
         float num3 = 0.0f;
         for (int index = 0; index < this.m_WayPoints.Length; ++index)
         {
             if (index > 0)
             {
                 num3 += this.distanceList[index - 1];
             }
             this.timeAtPointList.Add(num3 / num1 * num2);
         }
         if (this.LockMotion)
         {
             return;
         }
         this.mController.StartRunning();
     }
 }