示例#1
0
    protected GameManager gameManager;          // Game manager reference
    #endregion

    #region Main Methods
    public virtual void AwakeBehaviour(CameraLogic cameraLogic)
    {
        // Get references
        gameManager = GameManager.Instance;

        // Initialize values
        health           = MaxHealth;
        stamina          = MaxStamina;
        timeScale        = 1f;
        desiredTimeScale = timeScale;
        canRecover       = true;
        canInteract      = true;

        if (useRagdoll)
        {
            // Search all rigidbodies in skeleton game object childs
            Rigidbody[] tempRbs = skeletonRoot.GetComponentsInChildren <Rigidbody>();

            // Initialize ragdoll rigidbodies lists
            ragdollRbs = new List <Rigidbody>();

            for (int i = 0; i < tempRbs.Length; i++)
            {
                if (tempRbs[i].gameObject.layer == LayerMask.NameToLayer("Shatters"))
                {
                    ragdollRbs.Add(tempRbs[i]);
                }
            }

            // Disable all ragdoll rigidbodies
            for (int i = 0; i < ragdollRbs.Count; i++)
            {
                ragdollRbs[i].isKinematic = true;
            }
        }

        // Awake character movement
        if (handleMovement)
        {
            movement.AwakeBehaviour();
        }

        if (handleFeedback)
        {
            feedback.AwakeBehaviour();
        }

        // Awake character actions
        if (actions)
        {
            actions.AwakeBehaviour();
        }

        // Awake all character combats
        for (int i = 0; i < combats.Length; i++)
        {
            combats[i].AwakeBehaviour(cameraLogic);
        }
    }