Exemple #1
0
    // Use this for initialization
    void Start()
    {
        // Set up the helper classes for each state
        C_moveGround = new MoveGround(this);
        C_moveCliff  = new MoveCliff(this);
        C_moveJump   = new MoveJump(this);
        C_moveFly    = new MoveFly(this);

        C_animLink = new MoveAnimationLink(this);

        MCglobals.v3_grav = Physics.gravity;
        MCglobals.rigid   = GetComponent <Rigidbody>();
        MCglobals.rigid.maxAngularVelocity = 20f;
        MCglobals.t_cameraTrans            = Camera.main.transform;

        // Set up terrain detection system
        MCglobals.v3list_localTerrainDetectDown = new Vector3[i_TERRAINNUMS];
        Vector3 groundDetectFwd   = Vector3.forward * MCglobals.f_groundDetectFwdBack * transform.lossyScale.x;
        Vector3 groundDetectRight = Vector3.right * MCglobals.f_groundDetectLeftRight * transform.lossyScale.x;

        MCglobals.v3list_localTerrainDetectDown[0] = groundDetectFwd + groundDetectRight;  // Right arm
        MCglobals.v3list_localTerrainDetectDown[1] = groundDetectFwd - groundDetectRight;  // Left arm
        MCglobals.v3list_localTerrainDetectDown[2] = -groundDetectFwd - groundDetectRight; // Left leg
        MCglobals.v3list_localTerrainDetectDown[3] = -groundDetectFwd + groundDetectRight; // Right leg

        MCglobals.v3list_localTerrainDetectDir = new Vector3[i_TERRAINNUMS];
        for (int i = 0; i < i_TERRAINNUMS; i++)
        {
            MCglobals.v3list_localTerrainDetectDir[i] = Vector3.down * MCglobals.f_vertHeightCheck;
        }

        MCglobals.v3list_terrainPoint   = new Vector3[i_TERRAINNUMS];
        MCglobals.fList_terrainDistance = new float[i_TERRAINNUMS];


        MCglobals.v3list_rotateTo    = new Vector3[2];
        MCglobals.v3list_rotateTo[0] = Vector3.forward;

        // Set capsule height
        MCglobals.f_capsuleLength = GetComponent <CapsuleCollider>().height * 0.5f * transform.lossyScale.z;

        MCglobals.f_desiredHeight *= transform.lossyScale.y;

        MCglobals.v3_terrainNormAvg = Vector3.up;
        MCglobals.v3_wallNormal     = Vector3.up;

#if UNITY_IOS
        joystick  = FindObjectOfType <Joystick>();
        joyButton = FindObjectOfType <JoyButton>();
#endif

        SpawnOnGround();
    }
Exemple #2
0
 public void IsJumping()
 {
     MoveJump.Invoke();
 }