private Weapon AttachWeapon(WeaponConfig weapon) { var currentWeapon = weapon.SpawnWeapon(rightHandTransfom, leftHandTransform, GetComponent <Animator>()); onHit.AddListener(currentWeapon.OnHit); return(currentWeapon); }
public void RestoreState(object state) { string weaponName = (string)state; WeaponConfig weapon = UnityEngine.Resources.Load <WeaponConfig>(weaponName); EquipWeapon(weapon); }
/// <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)); }
private void Awake() { animator = GetComponent <Animator>(); mover = GetComponent <Mover>(); currentWeaponConfig = defaultWeapon; currentWeapon = new LazyValue <Weapon>(GetInitialWeapon); }
public void RestoreState(object state) { string weaponName = (string)state; WeaponConfig weapon = Resources.Load <WeaponConfig>(weaponName); EquipWeapon(weapon, GetComponent <Animator>()); }
void ISaveable.RestoreState(object state) { string weaponName = (string)state; WeaponConfig weaponConfig = UnityEngine.Resources.Load <WeaponConfig>(weaponName); EquipWeapon(weaponConfig); }
private void Awake() { currentWeaponConfig = defaultWeapon; currentWeapon = new LazyValue <Weapon>(SetupDefaultWeapon); animator = GetComponent <Animator>(); mover = GetComponent <Mover>(); }
private Weapon AttachWeapon(WeaponConfig weapon) { Animator animator = GetComponent <Animator>(); GetWeaponStats(weapon); return(weapon.Spawn(rightHandTransform, leftHandTransform, animator)); }
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); }
/// <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; }
private void Awake() { mover = GetComponent <Mover>(); actionScheduler = GetComponent <ActionScheduler>(); animator = GetComponent <Animator>(); baseStats = GetComponent <BaseStats>(); currentWeaponConfig = defaultWeapon; currentWeapon = new LazyValue <Weapon>(SetupDefaultWeapon); }
void AttachWeapon(WeaponConfig weapon) { if (!weapon || !leftHand || !rightHand) { return; } currentWeaponPrefab = weapon.SpawnWeapon(leftHand, rightHand, GetComponent <Animator>()); }
public void EquipWeapon(WeaponConfig weapon) { if (weapon == null) { return; } currentWeaponConfig = weapon; currentWeapon.value = AttachWeapon(weapon); }
private void Awake() { m_actionScheduler = GetComponent <ActionScheduler>(); m_animator = GetComponent <Animator>(); m_mover = GetComponent <Mover>(); m_currentWeaponConfig = defaultWeaponConfig; m_currentWeapon = new LazyValue <Weapon>(SetupDefaultWeapon); }
private void Awake() { _animator = GetComponent <Animator>(); _actionScheduler = GetComponent <ActionScheduler>(); _mover = GetComponent <Mover>(); _currentWeaponConfig = defaultWeaponConfig; _currentWeapon = new LazyValue <Weapon>(() => AttachWeapon(_currentWeaponConfig)); }
private void UpdateWeapon() { WeaponConfig weapon = equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig; if (weapon == null) { weapon = defaultWeapon; } EquipWeapon(weapon); }
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); }
private void Awake() { currentWeaponConfig = defaultWeaponConfig; currentWeapon = new LazyValue <Weapon>(SetupDefaultWeapon); equipment = GetComponent <Equipment>(); if (equipment) { equipment.equipmentUpdated += UpdateWeapon; } }
public void EquipWeapon(WeaponConfig weapon, Animator animator) { if (_currentWeaponConfig.value) { _currentWeaponConfig.value.DestroyWeapon(); } _currentWeaponConfig.value = weapon; AttachWeapon(weapon, animator); }
//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); }
public void EquipWeapon(WeaponConfig weaponConfig) { if (equippedWeaponConfig != null) { equippedWeaponConfig.DespawEquippedWeapon(); } Animator anim = GetComponent <Animator>(); equippedWeaponConfig = weaponConfig; currentWeapon = weaponConfig.Spawn(rightHandTransform, leftHandTransform, anim); }
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); }
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); }
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>(); }
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()); } }
private void UpdateWeapon() { WeaponConfig weapon = _equipment.GetItemInSlot(EquipLocation.Weapon) as WeaponConfig; if (weapon) { EquipWeapon(weapon); } else { EquipWeapon(_defaultWeaponConfig); } }
////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; } }
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; } }