// Start is always called after any Awake functions.
    void Start()
    {
        muzzleFlash = GameObject.Find("GameController").transform.GetChild(2).GetChild(0).gameObject;
        shot        = GameObject.Find("GameController").transform.GetChild(2).GetChild(1).gameObject;
        sparks      = GameObject.Find("GameController").transform.GetChild(2).GetChild(2).gameObject;


        // Set up the references.
        weaponTypeInt       = Animator.StringToHash("Weapon");
        aimBool             = Animator.StringToHash("Aim");
        coveringBool        = Animator.StringToHash("Cover");
        blockedAimBool      = Animator.StringToHash("BlockedAim");
        changeWeaponTrigger = Animator.StringToHash("ChangeWeapon");
        shootingTrigger     = Animator.StringToHash("Shooting");
        reloadBool          = Animator.StringToHash("Reload");
        weapons             = new List <InteractiveWeapon>(new InteractiveWeapon[3]);
        aimBehaviour        = this.GetComponent <AimBehaviour>();
        bulletHoles         = new List <GameObject>();

        // Hide shot effects on scene.
        muzzleFlash.SetActive(false);
        shot.SetActive(false);
        sparks.SetActive(false);

        // Create weapon slots. Different weapon types can be added in the same slot - ex.: (LONG_SPECIAL, 2) for a rocket launcher.
        slotMap = new Dictionary <InteractiveWeapon.WeaponType, int>
        {
            { InteractiveWeapon.WeaponType.SHORT, 1 },
            { InteractiveWeapon.WeaponType.LONG, 2 }
        };

        // Get player's avatar bone transforms for IK.
        Transform neck = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Neck);

        if (!neck)
        {
            neck = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Head).parent;
        }
        hips      = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Hips);
        spine     = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Spine);
        chest     = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.Chest);
        rightHand = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.RightHand);
        leftArm   = behaviourManager.GetAnim.GetBoneTransform(HumanBodyBones.LeftUpperArm);

        // Set default values.
        initialRootRotation  = hips.parent.localEulerAngles;
        initialHipsRotation  = hips.localEulerAngles;
        initialSpineRotation = spine.localEulerAngles;
        initialChestRotation = chest.localEulerAngles;
        originalCrosshair    = aimBehaviour.crosshair;
        shotDecay            = originalShotDecay;
        castRelativeOrigin   = neck.position - this.transform.position;
        distToHand           = (rightHand.position - neck.position).magnitude * 1.5f;
    }
    private bool isShotAlive      = false; // 아직 남아있는 총알이 있는가
    #endregion Variable


    #region Method
    private void Start()
    {
        weaponType          = Animator.StringToHash(FC.AnimatorKey.Weapon);
        aimBool             = Animator.StringToHash(FC.AnimatorKey.Aim);
        blockedAimBool      = Animator.StringToHash(FC.AnimatorKey.BlockedAim);
        changeWeaponTrigger = Animator.StringToHash(FC.AnimatorKey.ChangeWeapon);
        shootingTrigger     = Animator.StringToHash(FC.AnimatorKey.Shooting);
        reloadBool          = Animator.StringToHash(FC.AnimatorKey.Reload);
        weapons             = new List <InteractiveWeapon>(new InteractiveWeapon[3]);
        aimBehaviour        = GetComponent <AimBehaviour>();
        bulletHoles         = new List <GameObject>();

        muzzleFlash.SetActive(false);
        shot.SetActive(false);
        spark.SetActive(false);

        slotMap = new Dictionary <InteractiveWeapon.WeaponType, int>
        {
            { InteractiveWeapon.WeaponType.SHORT, 1 },
            { InteractiveWeapon.WeaponType.LONG, 2 }
        };

        Transform neck = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.Neck);

        if (!neck) // neck 은 가끔 없는 경우가 있다
        {
            neck = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.Head).parent;
        }

        hips      = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.Hips);
        spine     = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.Spine);
        chest     = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.Chest);
        rightHand = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.RightHand);
        leftArm   = this.behaviourController.GetAnimator.GetBoneTransform(HumanBodyBones.LeftUpperArm);

        initialRootRotation  = (hips.parent == transform) ? Vector3.zero : hips.parent.localEulerAngles;
        initialHipsRotation  = hips.localEulerAngles;
        initialSpineRotation = spine.localEulerAngles;
        initialChestRotation = chest.localEulerAngles;
        originalCorssHair    = aimBehaviour.crossHair;
        shotInterval         = originalShotInterval;
        castRelativeOrigin   = neck.position - transform.position;                    //
        distToHand           = (rightHand.position - neck.position).magnitude * 1.5f; //
    }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     aimBehaviourScript = GetComponent <AimBehaviour>();
 }