Exemple #1
0
        private void Start()
        {
            if (GameObject.FindGameObjectWithTag("Player"))
            {
                if (GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAtts>())
                {
                    smb = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAtts>().SmbWeapon;
                }
            }

            if (smb == null)
            {
                gameObject.SetActive(false);
                Debug.Log("Needed reference not found on:" + ToString());
                return;
            }

            smb.Events.onWeaponFire    += OnWeaponFire;
            smb.Events.onWeaponPullOut += OnWeaponPullOut;
            smb.Events.onWeaponHolster += OnWeaponHolster;
            smb.Events.onDropWeapon    += OnWeaponDrop;
            smb.Events.onWeaponAim     += OnWeaponAim;
            smb.Events.onWeaponUnAim   += OnWeaponUnAim;

            cCrosshairCount = defaultCrosshairCount;

            images = new List <Image>();

            if (cCrosshairCount <= 1)
            {
                additionalFireSpace = 0;
            }
        }
        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;
            }
        }
Exemple #3
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);
        }