コード例 #1
0
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            var currentWeapon = weapon.SpawnWeapon(rightHandTransfom, leftHandTransform, GetComponent <Animator>());

            onHit.AddListener(currentWeapon.OnHit);
            return(currentWeapon);
        }
コード例 #2
0
ファイル: Fighter.cs プロジェクト: GDanielf/RPG-Unity
        public void RestoreState(object state)
        {
            string       weaponName = (string)state;
            WeaponConfig weapon     = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon);
        }
コード例 #3
0
ファイル: CharacterCombat.cs プロジェクト: wjansen23/Relic
        /// <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));
        }
コード例 #4
0
 private void Awake()
 {
     animator            = GetComponent <Animator>();
     mover               = GetComponent <Mover>();
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(GetInitialWeapon);
 }
コード例 #5
0
        public void RestoreState(object state)
        {
            string       weaponName = (string)state;
            WeaponConfig weapon     = Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weapon, GetComponent <Animator>());
        }
コード例 #6
0
        void ISaveable.RestoreState(object state)
        {
            string       weaponName   = (string)state;
            WeaponConfig weaponConfig = UnityEngine.Resources.Load <WeaponConfig>(weaponName);

            EquipWeapon(weaponConfig);
        }
コード例 #7
0
 private void Awake()
 {
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
     animator            = GetComponent <Animator>();
     mover = GetComponent <Mover>();
 }
コード例 #8
0
ファイル: Fighter.cs プロジェクト: TheCHead/RPG-Study-Project
        private Weapon AttachWeapon(WeaponConfig weapon)
        {
            Animator animator = GetComponent <Animator>();

            GetWeaponStats(weapon);
            return(weapon.Spawn(rightHandTransform, leftHandTransform, animator));
        }
コード例 #9
0
ファイル: Fighter.cs プロジェクト: chazr88/RPG-Tutorial
        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));
        }
コード例 #10
0
        public Weapon EquipWeapon(WeaponConfig weaponConfig)
        {
            currentWeaponConfig = weaponConfig;
            Weapon weapon = weaponConfig.SpawnWeapon(animator, rightHandTransform, leftHandTransform);

            currentWeapon = weapon;
            return(weapon);
        }
コード例 #11
0
ファイル: CharacterCombat.cs プロジェクト: wjansen23/Relic
        /// <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);
        }
コード例 #12
0
        private void Awake()
        {
            mover          = GetComponent <Mover>();
            animator       = GetComponent <Animator>();
            actionSheduler = GetComponent <ActionSheduler>();
            equipment      = GetComponent <Equipment>();

            currentWeaponConfig = defaultWeaponConfig;
        }
コード例 #13
0
ファイル: Fighter.cs プロジェクト: chaserra/RPG-Course
 private void Awake()
 {
     mover               = GetComponent <Mover>();
     actionScheduler     = GetComponent <ActionScheduler>();
     animator            = GetComponent <Animator>();
     baseStats           = GetComponent <BaseStats>();
     currentWeaponConfig = defaultWeapon;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
 }
コード例 #14
0
ファイル: Fighter.cs プロジェクト: Kakarhot/Unity-RPG-Project
        void AttachWeapon(WeaponConfig weapon)
        {
            if (!weapon || !leftHand || !rightHand)
            {
                return;
            }

            currentWeaponPrefab = weapon.SpawnWeapon(leftHand, rightHand, GetComponent <Animator>());
        }
コード例 #15
0
 public void EquipWeapon(WeaponConfig weapon)
 {
     if (weapon == null)
     {
         return;
     }
     currentWeaponConfig = weapon;
     currentWeapon.value = AttachWeapon(weapon);
 }
コード例 #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);
        }
コード例 #17
0
        private void Awake()
        {
            _animator        = GetComponent <Animator>();
            _actionScheduler = GetComponent <ActionScheduler>();
            _mover           = GetComponent <Mover>();

            _currentWeaponConfig = defaultWeaponConfig;
            _currentWeapon       = new LazyValue <Weapon>(() => AttachWeapon(_currentWeaponConfig));
        }
コード例 #18
0
        private void UpdateWeapon()
        {
            WeaponConfig weapon = equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig;

            if (weapon == null)
            {
                weapon = defaultWeapon;
            }
            EquipWeapon(weapon);
        }
コード例 #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);
        }
コード例 #20
0
 private void Awake()
 {
     currentWeaponConfig = defaultWeaponConfig;
     currentWeapon       = new LazyValue <Weapon>(SetupDefaultWeapon);
     equipment           = GetComponent <Equipment>();
     if (equipment)
     {
         equipment.equipmentUpdated += UpdateWeapon;
     }
 }
コード例 #21
0
        public void EquipWeapon(WeaponConfig weapon, Animator animator)
        {
            if (_currentWeaponConfig.value)
            {
                _currentWeaponConfig.value.DestroyWeapon();
            }

            _currentWeaponConfig.value = weapon;
            AttachWeapon(weapon, animator);
        }
コード例 #22
0
ファイル: Fighter.cs プロジェクト: chazr88/RPG-Tutorial
        //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);
        }
コード例 #23
0
        public void EquipWeapon(WeaponConfig weaponConfig)
        {
            if (equippedWeaponConfig != null)
            {
                equippedWeaponConfig.DespawEquippedWeapon();
            }
            Animator anim = GetComponent <Animator>();

            equippedWeaponConfig = weaponConfig;
            currentWeapon        = weaponConfig.Spawn(rightHandTransform, leftHandTransform, anim);
        }
コード例 #24
0
ファイル: Fighter.cs プロジェクト: leozhang1/FirstRPG
        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);
        }
コード例 #25
0
ファイル: Fighter.cs プロジェクト: svetliaka92/UnityRPG
        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);
        }
コード例 #26
0
ファイル: Fighter.cs プロジェクト: sdi1982/Unity-RPG-Scripts
 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>();
 }
コード例 #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());
     }
 }
コード例 #28
0
        private void UpdateWeapon()
        {
            WeaponConfig weapon = _equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig;

            if (weapon)
            {
                EquipWeapon(weapon);
            }
            else
            {
                EquipWeapon(_defaultWeaponConfig);
            }
        }
コード例 #29
0
ファイル: CharacterCombat.cs プロジェクト: wjansen23/Relic
        ////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;
            }
        }
コード例 #30
0
ファイル: Fighter.cs プロジェクト: svetliaka92/UnityRPG
        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;
            }
        }