Ejemplo n.º 1
0
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            var currentWeapon = weapon.SpawnWeapon(rightHandTransfom, leftHandTransform, GetComponent <Animator>());

            onHit.AddListener(currentWeapon.OnHit);
            return(currentWeapon);
        }
Ejemplo n.º 2
0
        public void RestoreState(object state)
        {
            string       weaponName = (string)state;
            WeaponConfig weapon     = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attachs the weapon to the character
        /// </summary>
        /// <param name="weapon"></param>
        /// <returns></returns>
        private Weapon AttachWeaponToCharacter(WeaponConfig weapon)
        {
            //Spawn the weapon
            Animator animator = GetComponent <Animator>();

            return(weapon.Spawn(m_WeaponRightHandTransform, m_WeaponLeftHandTransform, animator));
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     animator            = GetComponent <Animator>();
     mover               = GetComponent <Mover>();
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(GetInitialWeapon);
 }
Ejemplo n.º 5
0
        public void RestoreState(object state)
        {
            string       weaponName = (string)state;
            WeaponConfig weapon     = Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon, GetComponent <Animator>());
        }
Ejemplo n.º 6
0
        void ISaveable.RestoreState(object state)
        {
            string       weaponName   = (string)state;
            WeaponConfig weaponConfig = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weaponConfig);
        }
Ejemplo n.º 7
0
 private void Awake()
 {
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
     animator            = GetComponent <Animator>();
     mover = GetComponent <Mover>();
 }
Ejemplo n.º 8
0
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            Animator animator = GetComponent <Animator>();

            GetWeaponStats(weapon);
            return(weapon.Spawn(rightHandTransform, leftHandTransform, animator));
        }
Ejemplo n.º 9
0
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            Animator animator = GetComponent <Animator>();

            //This takes an animation that will be passed in a seralized field and uses it to override our current animation.
            //This now returns a weapon
            return(weapon.Spawn(rightHandTransform, leftHandTransform, animator));
        }
        public Weapon EquipWeapon(WeaponConfig weaponConfig)
        {
            currentWeaponConfig = weaponConfig;
            Weapon weapon = weaponConfig.SpawnWeapon(animator, rightHandTransform, leftHandTransform);

            currentWeapon = weapon;
            return(weapon);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Restore state of combat component
        /// </summary>
        /// <param name="state"></param>
        public void RestoreState(object state)
        {
            //Look for weapon types in the resources folder with the name equal to m_defaultWeaponName.
            string       weaponName = (string)state;
            WeaponConfig weapon     = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon);
        }
        private void Awake()
        {
            mover          = GetComponent <Mover>();
            animator       = GetComponent <Animator>();
            actionSheduler = GetComponent <ActionSheduler>();
            equipment      = GetComponent <Equipment>();

            currentWeaponConfig = defaultWeaponConfig;
        }
Ejemplo n.º 13
0
 private void Awake()
 {
     mover               = GetComponent <Mover>();
     actionScheduler     = GetComponent <ActionScheduler>();
     animator            = GetComponent <Animator>();
     baseStats           = GetComponent <BaseStats>();
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
 }
Ejemplo n.º 14
0
        void AttachWeapon(WeaponConfig weapon)
        {
            if (!weapon || !leftHand || !rightHand)
            {
                return;
            }

            currentWeaponPrefab = weapon.SpawnWeapon(leftHand, rightHand, GetComponent <Animator>());
        }
Ejemplo n.º 15
0
 public void EquipWeapon(WeaponConfig weapon)
 {
     if (weapon == null)
     {
         return;
     }
     currentWeaponConfig = weapon;
     currentWeapon.value = AttachWeapon(weapon);
 }
Ejemplo n.º 16
0
        private void Awake()
        {
            m_actionScheduler = GetComponent <ActionScheduler>();
            m_animator        = GetComponent <Animator>();
            m_mover           = GetComponent <Mover>();

            m_currentWeaponConfig = defaultWeaponConfig;
            m_currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
        }
Ejemplo n.º 17
0
        private void Awake()
        {
            _animator        = GetComponent <Animator>();
            _actionScheduler = GetComponent <ActionScheduler>();
            _mover           = GetComponent <Mover>();

            _currentWeaponConfig = defaultWeaponConfig;
            _currentWeapon       = new LazyValue <Weapon>(() => AttachWeapon(_currentWeaponConfig));
        }
Ejemplo n.º 18
0
        private void UpdateWeapon()
        {
            WeaponConfig weapon = equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig;

            if (weapon == null)
            {
                weapon = defaultWeapon;
            }
            EquipWeapon(weapon);
        }
Ejemplo n.º 19
0
        private Weapon AttachWeapon(WeaponConfig weaponConfig)
        {
            // if(gameObject.tag=="Player"&&equipment.GetItemInSlot(EquipLocation.Weapon)==null){
            //     equipment.AddItem(EquipLocation.Weapon,weaponConfig);
            // }
            Animator animator = anim;
            Weapon   weapon   = weaponConfig.Spawn(rightHandTransform, leftHandTransform, animator);

            return(weapon);
        }
Ejemplo n.º 20
0
 private void Awake()
 {
     currentWeaponConfig = defaultWeaponConfig;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
     equipment           = GetComponent <Equipment>();
     if (equipment)
     {
         equipment.equipmentUpdated += UpdateWeapon;
     }
 }
Ejemplo n.º 21
0
        public void EquipWeapon(WeaponConfig weapon, Animator animator)
        {
            if (_currentWeaponConfig.value)
            {
                _currentWeaponConfig.value.DestroyWeapon();
            }

            _currentWeaponConfig.value = weapon;
            AttachWeapon(weapon, animator);
        }
Ejemplo n.º 22
0
        //This takes the captured weapon, casts it to a state, goes into resources and grabs that weapon scriptable object
        //and based on the name returns us the correct weapon. We then equip that weapon.
        public void RestoreState(object state)
        {
            string weaponName = (string)state;
            //Unity is smart enough to have scrits just for folders named Resources. This line is
            //looking in the resources folder for a weapon scriptable object and trying to find the defaultWeaponName
            //and the scriptable object belonging to that name it was given.
            WeaponConfig weapon = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon);
        }
Ejemplo n.º 23
0
        public void EquipWeapon(WeaponConfig weaponConfig)
        {
            if (equippedWeaponConfig != null)
            {
                equippedWeaponConfig.DespawEquippedWeapon();
            }
            Animator anim = GetComponent <Animator>();

            equippedWeaponConfig = weaponConfig;
            currentWeapon        = weaponConfig.Spawn(rightHandTransform, leftHandTransform, anim);
        }
Ejemplo n.º 24
0
        public void RestoreState(object state)
        {
            // get the object and cast it to a string
            string restoredWeaponName = state as string;

            // create weapon object loaded from the Resources folder
            WeaponConfig restoredWeapon = UnityEngine.Resources.Load <WeaponConfig>(restoredWeaponName);

            // equip it to the character this script is attached to
            EquipWeapon(restoredWeapon);
        }
Ejemplo n.º 25
0
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            Animator anim        = GetComponent <Animator>();
            Weapon   spawnWeapon = weapon.Spawn(rightHandTransform, leftHandTransform, anim);

            range = weapon.GetRange();
            timeBetweenAttacks = weapon.GetTimeBetweenAttacks();
            weaponDamage       = weapon.GetDamage();

            return(spawnWeapon);
        }
Ejemplo n.º 26
0
 private void Awake()
 {
     m_Mover                    = GetComponent <Mover>();
     m_Animator                 = GetComponent <Animator>();
     m_ActionScheduler          = GetComponent <ActionScheduler>();
     m_CharacterBehaviour       = GetComponent <CharacterBehaviour>();
     m_Animator                 = GetComponent <Animator>();
     m_BaseStats                = GetComponent <BaseStats>();
     m_CurrentWeaponConfig      = defaultWeapon;
     m_CurrentWeapon            = new LazyValue <Weapon>(SetupDefaultWeapon);
     m_CinematicControlRemovers = FindObjectsOfType <CinematicControlRemover>();
 }
Ejemplo n.º 27
0
 public void EquipWeapon(WeaponConfig weapon)
 {
     currentWeaponConfig = weapon;
     currentWeapon.value = AttachWeapon(weapon);
     if (weapon.IsDual())
     {
         currentSubWeapon.value = weapon.GetSubWeapon();
     }
     if (GetComponent <IKController>() != null)
     {
         GetComponent <IKController>().SetGrabObj(currentWeapon.value.GetGrabObj());
     }
 }
Ejemplo n.º 28
0
        private void UpdateWeapon()
        {
            WeaponConfig weapon = _equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig;

            if (weapon)
            {
                EquipWeapon(weapon);
            }
            else
            {
                EquipWeapon(_defaultWeaponConfig);
            }
        }
Ejemplo n.º 29
0
        ////IModifierProvider
        ///// <summary>
        ///// Returns additive stat modifiers
        ///// </summary>
        ///// <param name="reqStat"></param>
        ///// <returns></returns>
        //public IEnumerable<float> GetStatAdditiveModifiers(StatType reqStat)
        //{
        //    //This is an example.  Combat will not return any stat modifiers for damage
        //    if (reqStat == StatType.PhysicalDamage)
        //    {
        //        yield return 0;
        //    }
        //}

        ///// <summary>
        ///// Returns multiplicative stat modifiers
        ///// </summary>
        ///// <param name="reqStat"></param>
        ///// <returns></returns>
        //public IEnumerable<float> GetStatPercentageModifiers(StatType reqStat)
        //{
        //    //This is an example.  Combat will not return any stat modifiers for damage
        //    if (reqStat == StatType.PhysicalDamage)
        //    {
        //        yield return 0;
        //    }
        //}

        ///////////////////////////// PRIVATE METHODS ////////////////////////////////////////////


        private void Awake()
        {
            m_Mover           = GetComponent <CharacterMovement>();
            m_ActionScheduler = GetComponent <ActionScheduler>();
            m_Animator        = GetComponent <Animator>();

            m_currentWeaponConfig = m_defaultWeapon;
            m_currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
            m_Equipment           = GetComponent <Equipment>();

            //Check if character has an equipment component.  If so, register for updates.
            if (m_Equipment)
            {
                m_Equipment.equipmentUpdated += UpdateWeapon;
            }
        }
Ejemplo n.º 30
0
        private void Awake()
        {
            animator        = GetComponent <Animator>();
            mover           = GetComponent <Mover>();
            actionScheduler = GetComponent <ActionScheduler>();
            baseStats       = GetComponent <BaseStats>();

            currentWeaponConfig = defaultWeapon;
            currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);

            equipment = GetComponent <Equipment>();
            if (equipment)
            {
                equipment.equipmentUpdated += UpdateWeapon;
            }
        }