private void ReplaceWeapon(Weapon oldWeapon, Weapon newWeapon) { DropWeapon(oldWeapon.WeaponData.SystemName); Weapons.Remove(oldWeapon); Weapons.Add(newWeapon); }
/// <summary> /// Equips a new weapon. /// </summary> public void EquipWeapon(Weapon newWeapon) { //Already have a weapon of this type so replace the old one. if (Weapons.Contains(newWeapon.WeaponData.WeaponType)) ReplaceWeapon(Weapons[newWeapon.WeaponData.WeaponType], newWeapon); //Full of weapons, so drop your currently equipped one. else if (Weapons.Count() >= Capacity) ReplaceWeapon(Weapons[CurrentWeapon.WeaponData.WeaponType], newWeapon); //Regular, just add it. else Weapons.Add(newWeapon); _CurrentWeaponIndex = Weapons.Count() - 1; }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency<AttributesComponent>(); //_Weapons = new WeaponCollection(); if(string.IsNullOrEmpty(DefaultWeaponName)) return; if (Weapons.Count != 0) return; _CurrentWeaponIndex = 0; //Creates the weapon from a blueprint. var weapon = CorvEngine.Components.Blueprints.EntityBlueprint.GetBlueprint(DefaultWeaponName).CreateEntity(); var attri = weapon.GetComponent<AttributesComponent>(); var props = weapon.GetComponent<CombatPropertiesComponent>(); var data = weapon.GetComponent<WeaponPropertiesComponent>(); var effect = weapon.GetComponent<StatusEffectPropertiesComponent>(); _DefaultWeapon = new Weapon(data.WeaponData, props.CombatProperties, attri.Attributes, effect.StatusEffectAttributes); Weapons.Add(_DefaultWeapon); weapon.Dispose(); }