private void Start()
        {
            plAnimator = GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>();

            if (plAnimator)
            {
                if (dontFollowBone)
                {
                    followTransform = plAnimator.transform;
                }
                else
                {
                    followTransform = plAnimator.GetBoneTransform(followBone);
                }
                if (dontPositionToBone)
                {
                    positionFreeLookTransform = plAnimator.transform;
                }
                else
                {
                    positionFreeLookTransform = plAnimator.GetBoneTransform(positionFreeLookBone);
                }
            }

            userInput     = plAnimator.GetComponent <SetupAndUserInput>();
            player        = userInput.GetComponent <PlayerAtts>();
            plCapCollider = userInput.GetComponent <CapsuleCollider>();
            Cam           = transform.Find("Main Camera").GetComponent <Camera>();
            moveReference = transform.Find("Move Reference");

            if (!plAnimator || !followTransform || !userInput || !player || !plCapCollider || !Cam || !moveReference)
            {
                if (userInput)
                {
                    userInput.DisablePlayer("Needed reference not found on Player Camera script");
                }
                enabled = false;
            }

            currentTPModderParams = new ThirdPersonCameraParams();
            currentFPModderParams = new FirstPersonCameraParams();

            camPosShakers = new List <CameraShaker>();
            camRotShakers = new List <CameraShaker>();

            HorizontalRotation = startRotations.x;
            VerticalRotation   = startRotations.y;
        }
        private void Awake()
        {
            Animator animator = GetComponent <Animator>();

            if (!cameraRig || !animator)
            {
                string errorStr = "(in " + ToString() + ")Missing :";
                if (!cameraRig)
                {
                    errorStr += "Camera Rig | ";
                }
                if (!animator)
                {
                    errorStr += "Player Animator | ";
                }
                DisablePlayer(errorStr);
                return;
            }
#if MOBILE_INPUT
            player = GetComponent <PlayerAtts>();
#endif
        }
        private void Start()
        {
            defLocalPos = transform.localPosition;
            GameObject plGo = GameObject.FindGameObjectWithTag("Player");

            if (plGo)
            {
                plAtts = plGo.GetComponent <PlayerAtts>();
            }
            if (plAtts)
            {
                camTransform = plAtts.GetComponent <SetupAndUserInput>().cameraRig;
                fireRef      = transform.FindChild("Fire Reference");
                smbFire      = plAtts.SmbWeapon;
                smbLook      = plAtts.SmbLookIK;
            }

            if (!plGo || !plAtts || !smbFire || !smbLook || !fireRef)
            {
                Debug.Log("needed references not found on :" + ToString());
                Destroy(this);
                return;
            }
        }
Example #4
0
        private void Start()
        {
            toPrintThrowableCount = "00";
            toPrintCurrentClip    = "00";
            toPrintTotalAmmo      = "000";
            toPrintSecCurrentClip = "00";
            toPrintSecTotalAmmo   = "000";

            infoTexts      = new List <Small3dHudInfoText>();
            worldInfoTexts = new List <Small3dHudInfoText>();

            if (GameObject.FindGameObjectWithTag("Player"))
            {
                player    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAtts>();
                smbWeapon = player.SmbWeapon;
                smbWeapon.Events.onWeaponFire    += OnFire;
                smbWeapon.Events.onReloadDone    += OnReload;
                smbWeapon.Events.onWeaponPullOut += OnWeaponPullOut;
                smbWeapon.Events.onWeaponSwitch  += OnWeaponChange;
                smbWeapon.Events.onDropWeapon    += OnWeaponChange;
                smbWeapon.Events.onWeaponCollect += OnWeaponCollect;
                smbWeapon.Events.onSupplyCollect += SetAllCounts;

                player.SmbThrow.Events.onSwitch        += OnThrowableSwitch;
                player.SmbThrow.Events.onThrowableExit += OnThrowableExit;
            }

            if (!player)
            {
                Debug.Log("Needed reference not found..." + ToString());
                gameObject.SetActive(false);

                return;
            }
            playerCamera = player.GetComponent <SetupAndUserInput>().cameraRig.GetComponent <PlayerCamera>();

            foreach (var catcher in gameObject.GetComponentsInChildren <HudEventCatcher>())
            {
                catcher.onZeroAlphaTotalAmmo       += AnimEventOnTotalAmmoZeroAlpha;
                catcher.onZeroAlphaCurrentClipAmmo += AnimEventOnCurrentAmmoZeroAlpha;
            }

            foreach (var trns in transform.GetComponentsInChildren <Transform>())
            {
                if (trns.name == "Current Clip Capacity")
                {
                    cClipAnimator = trns.GetComponent <Animator>();
                }
                else if (trns.name == "Total Ammo")
                {
                    tAmmoAnimator = trns.GetComponent <Animator>();
                }
                else if (trns.name == "SecCurrent Clip Capacity")
                {
                    secCClipAnimator = trns.GetComponent <Animator>();
                }
                else if (trns.name == "SecTotal Ammo")
                {
                    secTAmmoAnimator = trns.GetComponent <Animator>();
                }
                else if (trns.name == "Weapon Image")
                {
                    weaponImage = trns.GetComponent <Image>();
                }
                else if (trns.name == "Weapon Name")
                {
                    weaponName = trns.GetComponent <Text>();
                }
                else if (trns.name == "Projectile Image")
                {
                    bulletImage = trns.GetComponent <Image>();
                }
                else if (trns.name == "Projectile Name")
                {
                    bulletName = trns.GetComponent <Text>();
                }
                else if (trns.name == "SecProjectile Image")
                {
                    secBulletImage = trns.GetComponent <Image>();
                }
                else if (trns.name == "SecProjectile Name")
                {
                    secBulletName = trns.GetComponent <Text>();
                }
                else if (trns.name == "Throwable Count")
                {
                    throwableCountAnimator = trns.GetComponent <Animator>();
                }
                else if (trns.name == "Throwable Name")
                {
                    throwableName = trns.GetComponent <Text>();
                }
                else if (trns.name == "Throwable Image")
                {
                    throwableImage = trns.GetComponent <Image>();
                }
                else if (trns.name == "InfoTextParentPanel")
                {
                    infoTextParentPanel = trns;
                }
            }

            foreach (var trns in cClipAnimator.GetComponentsInChildren <Transform>())
            {
                if (trns.name == "Text0")
                {
                    currentClipText0 = trns.GetComponent <Text>();
                }
                else if (trns.name == "Text1")
                {
                    currentClipText1 = trns.GetComponent <Text>();
                }
            }

            foreach (var trns in tAmmoAnimator.GetComponentsInChildren <Transform>())
            {
                if (trns.name == "Text0")
                {
                    totalAmmoText0 = trns.GetComponent <Text>();
                }
                else if (trns.name == "Text1")
                {
                    totalAmmoText1 = trns.GetComponent <Text>();
                }
                else if (trns.name == "Text2")
                {
                    totalAmmoText2 = trns.GetComponent <Text>();
                }
            }
            if (secCClipAnimator)
            {
                foreach (var trns in secCClipAnimator.GetComponentsInChildren <Transform>())
                {
                    if (trns.name == "Text0")
                    {
                        secCurrentClipText0 = trns.GetComponent <Text>();
                    }
                    else if (trns.name == "Text1")
                    {
                        secCurrentClipText1 = trns.GetComponent <Text>();
                    }
                }
            }
            if (secTAmmoAnimator)
            {
                foreach (var trns in secTAmmoAnimator.GetComponentsInChildren <Transform>())
                {
                    if (trns.name == "Text0")
                    {
                        secTotalAmmoText0 = trns.GetComponent <Text>();
                    }
                    else if (trns.name == "Text1")
                    {
                        secTotalAmmoText1 = trns.GetComponent <Text>();
                    }
                    else if (trns.name == "Text2")
                    {
                        secTotalAmmoText2 = trns.GetComponent <Text>();
                    }
                }
            }

            foreach (var trns in throwableCountAnimator.GetComponentsInChildren <Transform>())
            {
                if (trns.name == "Text0")
                {
                    throwableCountText0 = trns.GetComponent <Text>();
                }
                else if (trns.name == "Text1")
                {
                    throwableCountText1 = trns.GetComponent <Text>();
                }
            }

            currentClipText0.text = "0";
            currentClipText1.text = "0";

            totalAmmoText0.text = "0";
            totalAmmoText1.text = "0";
            totalAmmoText2.text = "0";

            if (secCurrentClipText0)
            {
                secCurrentClipText0.text = "0";
            }
            if (secCurrentClipText0)
            {
                secCurrentClipText1.text = "0";
            }

            if (secTotalAmmoText0)
            {
                secTotalAmmoText0.text = "0";
            }
            if (secTotalAmmoText1)
            {
                secTotalAmmoText1.text = "0";
            }
            if (secTotalAmmoText2)
            {
                secTotalAmmoText2.text = "0";
            }

            throwableCountText0.text = "0";
            throwableCountText1.text = "1";

            SetWeaponImage(player.SmbWeapon.GetCurrentWeaponSprite());
            SetWeaponName(player.SmbWeapon.GetCurrentWeaponName());
            SetBulletImage(player.SmbWeapon.GetCurrentBulletSprite());
            SetBulletnName(player.SmbWeapon.GetCurrentBulletName());
            SetSecBulletImage(player.SmbWeapon.GetSecCurrentBulletSprite());
            SetSecBulletnName(player.SmbWeapon.GetSecCurrentBulletName());

            CClipTexter(player.SmbWeapon.GetCurrentClip());
            TotalClipTexter(player.SmbWeapon.GetTotalAmmoCount());
            SecCClipTexter(player.SmbWeapon.GetSecCurrentClip());
            SecTotalClipTexter(player.SmbWeapon.GetSecTotalAmmoCount());

            SetThrowableImage(player.SmbThrow.GetThrowableSprite());
            SetThrowableName(player.SmbThrow.GetThrowableName());
            ThrowableCountTexter(player.SmbThrow.GetThrowableCount());

            followBone = player.GetComponent <Animator>().GetBoneTransform(bone);
        }
Example #5
0
 public PlayerPhysics(Rigidbody _rb, PlayerAtts _player)
 {
     AddJumpControlForce = false;
     rb     = _rb;
     player = _player;
 }