Esempio n. 1
0
    public void Start()
    {
        /* Set collision defaults. */
        wallHitSpeed.x = activeSpeed;

        jumpVelRatio = jumpVelocityMin / jumpVelocityMax; // Vxmax = (Vxmax * Vymin) / Vymin

        wallFrictionDown = 1;
        wallStickTime = 0;

        animController = (CAnimationController)FindObjectOfType(typeof(CAnimationController));
    }
    public void OnStart()
    {
        if (gameObject.transform.GetParent() != null)
        {
            gameObject.transform.SetParent(null);
        }

        speedX          = 0;
        speedZ          = 0;
        currSpeed       = speedNormal;
        speedWhenJumped = 0.0f;

        canJump = true;

        // playerBox is actually my own gameObject
        playerBox     = gameObject; // GameObject.GetGameObjectByName("PlayerBoxCollider");
        playerBoxMesh = playerBox.RequireComponent <CMeshRenderer>();
        playerBoxMesh.setEnabled(false);
        playerCamera    = Common.GetStealthPlayerCamera();
        playerCamScript = GetScript <FirstPersonCamera>(playerCamera);
        player          = Common.GetStealthPlayerMesh();
        anim            = player.RequireComponent <CAnimationController>();
        anim.mIsPlaying = true;

        playerPhysics = gameObject.RequireComponent <CPhysics>();
        playerPhysics.mColliderType = 1;

        idle   = new State(smc, State_Idle_Enter, State_Idle_Update, State_Idle_Exit);
        move   = new State(smc, State_Move_Enter, State_Move_Update, State_Move_Exit);
        jump   = new State(smc, State_Jump_Enter, State_Jump_Update, State_Jump_Exit);
        crouch = new State(smc, State_Crouch_Enter, State_Crouch_Update, State_Crouch_Exit);

        sprinting           = new State(smc, State_Sprinting_Enter, State_Sprinting_Update, State_Sprinting_Exit, 0.5f);
        sprinting.NextState = sprinting;
        notsprinting        = new State(smc, State_NotSprinting_Enter, State_NotSprinting_Update, State_NotSprinting_Exit);

        smc.SetState(idle);
        sprint_smc.SetState(notsprinting);

        footstepID = GetSoundComponent().GetUniqueEvent("P1_FOOTSTEPS.vente", 0);
    }