示例#1
0
        //-------------------------WEAPON ON HAND------------------------------------
        public void PutWeaponInHand(WeaponConfig weapon)
        {
            GameObject weaponPrefab = weapon.GetWeaponPrefab();
            GameObject powerAttackParticlePrefab = weapon.GetWeaponPowerAttackGlowPrefab();

            currentWeaponInUse = weapon;
            Destroy(instantiatedWeapon);
            Transform weaponHandT = RequestDominantHand();

            instantiatedWeapon = Instantiate(weaponPrefab, weaponHandT);
            instantiatedWeapon.transform.localPosition = currentWeaponInUse.weaponGrip.localPosition;
            instantiatedWeapon.transform.localRotation = currentWeaponInUse.weaponGrip.localRotation;

            if (powerAttackParticlePrefab != null)
            {
                GameObject powerAttackParticleObj = Instantiate(powerAttackParticlePrefab, instantiatedWeapon.transform);
                powerAttackParticleObj.transform.localRotation = currentWeaponInUse.particleGrip.localRotation;
                powerAttackParticleObj.transform.localPosition = currentWeaponInUse.particleGrip.localPosition;
                particleEffectToUse = powerAttackParticleObj.GetComponent <ParticleSystem>();
            }


            //print("Put the " + weapon + " in " + gameObject + "'s hand");

            WeaponDependantAnimation();
        }
示例#2
0
        private void InstantiateWeapon()
        {
            var weapon = weaponConfig.GetWeaponPrefab();

            weapon.transform.position = Vector3.zero;
            Instantiate(weapon, gameObject.transform);
        }
示例#3
0
        // Start is called before the first frame update
        void Start()
        {
            weaponSystem = GameObject.FindWithTag(Constants.PLAYER_TAG).GetComponent <WeaponSystem>();
            audioSource  = GetComponent <AudioSource>();

            var weaponPrefab     = weaponConfig.GetWeaponPrefab();
            var weaponGameObject = Instantiate(weaponPrefab, transform.position, transform.rotation);

            weaponGameObject.transform.parent = transform;
        }
示例#4
0
        public void PutWeaponInHand(WeaponConfig weaponToUse)
        {
            currentWeaponConfig = weaponToUse;
            var weaponPrefab = weaponToUse.GetWeaponPrefab();

            Destroy(weaponObject); // empty hands
            weaponObject = Instantiate(weaponPrefab, weaponSocket.transform);
            weaponObject.transform.localPosition = currentWeaponConfig.gripTransform.localPosition;
            weaponObject.transform.localRotation = currentWeaponConfig.gripTransform.localRotation;
        }
示例#5
0
        public void PutWeaponInHand(WeaponConfig weaponToUse)
        {
            currentWeaponConfig = weaponToUse;
            var        weaponPrefab = weaponToUse.GetWeaponPrefab();
            GameObject dominantHand = RequestDominantHand();

            Destroy(weaponObject);
            weaponObject = Instantiate(weaponPrefab, dominantHand.transform);
            weaponObject.transform.localPosition = currentWeaponConfig.grip.localPosition;
            weaponObject.transform.localRotation = currentWeaponConfig.grip.localRotation;
        }
示例#6
0
        public void EquipWeapon(WeaponConfig weaponConfig)
        {
            Assert.IsNotNull(weaponConfig, "Please assign a weapon to the player");
            currentWeaponConfig = weaponConfig;
            var        weaponPrefab = weaponConfig.GetWeaponPrefab();
            GameObject dominantHand = RequestDominantHand();

            Destroy(weaponObject); // empty hands
            weaponObject = Instantiate(weaponPrefab);
            weaponObject.transform.SetParent(dominantHand.transform, true);
            weaponObject.transform.localPosition = currentWeaponConfig.weaponGrip.transform.position;
            weaponObject.transform.localRotation = currentWeaponConfig.weaponGrip.transform.rotation;
        }
示例#7
0
        public void PutWeaponInHand(WeaponConfig weaponToUse)
        {
            currentWeaponConfig = weaponToUse;
            // get default weapon
            var        weaponPrefab = weaponToUse.GetWeaponPrefab();
            GameObject dominantHand = RequestDominantHand();

            Destroy(weaponObject); // emprty hands
            // set the weapon postion based on weaponGrip
            weaponObject = Instantiate(weaponPrefab, dominantHand.transform);
            weaponObject.transform.localPosition = currentWeaponConfig.gripTransform.localPosition;
            weaponObject.transform.localRotation = currentWeaponConfig.gripTransform.localRotation;
        }
示例#8
0
        public void PutWeaponInHand(WeaponConfig weaponConfig)
        {
            currentWeaponConfig = weaponConfig;
            var        weaponPrefab = weaponConfig.GetWeaponPrefab();
            GameObject weaponSocket = RequestDominantHand();

            if (weaponGameObject != null)
            {
                Destroy(weaponGameObject);
            }
            weaponGameObject = Instantiate(weaponPrefab, weaponSocket.transform);
            weaponGameObject.transform.localPosition = currentWeaponConfig.weaponTransform.localPosition;
            weaponGameObject.transform.localRotation = currentWeaponConfig.weaponTransform.localRotation;
        }
示例#9
0
        public void PutWeaponInHand(WeaponConfig weaponToUse)
        {
            //TODO: refactor weapon and equipment. Make a manager component.

            GameObject weaponSocket = RequestDominantHand();

            currentWeaponConfig = weaponToUse;

            // check if a weapon is already in hand
            RemoveEquippedWeapon(weaponObject);

            var weaponPrefab = currentWeaponConfig.GetWeaponPrefab();

            weaponObject = Instantiate(weaponPrefab, weaponSocket.transform);
            weaponObject.transform.localPosition = currentWeaponConfig.gripTransform.localPosition;
            weaponObject.transform.localRotation = currentWeaponConfig.gripTransform.localRotation;
        }