internal static WeaponStats FromSerializable(SerializableWeapon weapon) { var stats = weapon.weaponStats; stats.sprite = Resources.Load <Sprite>("Sprites/" + stats.type.ToString()); return(stats); }
public Weapon(SerializableWeapon weapon, Database database) { ItemId = new ItemId <Weapon>(weapon.Id, weapon.FileName); WeaponClass = weapon.WeaponClass; FireRate = new NumericValue <float>(weapon.FireRate, 0, 1000); Spread = new NumericValue <float>(weapon.Spread, 0, 180); Magazine = new NumericValue <int>(weapon.Magazine, 0, 1000); ActivationType = weapon.ActivationType; ShotSound = weapon.ShotSound; ChargeSound = weapon.ChargeSound; ShotEffectPrefab = weapon.ShotEffectPrefab; ControlButtonIcon = weapon.ControlButtonIcon; }
public void Save(SerializableWeapon serializable) { serializable.WeaponClass = WeaponClass; serializable.FireRate = FireRate.Value; serializable.Spread = Spread.Value; serializable.Magazine = Magazine.Value; serializable.ActivationType = ActivationType; serializable.ShotSound = ShotSound; serializable.ChargeSound = ChargeSound; serializable.ShotEffectPrefab = ShotEffectPrefab; serializable.ControlButtonIcon = ControlButtonIcon; }
public void FromSerializable(SerializableWeapon weapon, PlayerStats parent) { Stats = WeaponStats.FromSerializable(weapon); AssignAudioAndAnimation(); playerStats = parent; var index = weapon.index; var ui = Instantiate(weaponUIPrefab); Renderer = new WeaponRenderer(ui, Stats, weapon.keyCode, index); //equipmentBar.transform.GetChild(index + 2).GetComponent<Image>().sprite = Stats.sprite; numHalvedFor = 0; Multipliers = new List <float>(2); MultiplierCooldowns = new List <float>(2); for (int itemIndex = 0; itemIndex < playerStats.items.Count; ++itemIndex) { playerStats.items[itemIndex].applyItemEffect(this); } }
public SerializablePlayerStats ToSerializable() { var serializableWeapons = new SerializableWeapon[weapons.Length]; for (int i = 0; i < serializableWeapons.Length; i++) { serializableWeapons[i] = weapons[i].ToSerializable(i); } return(new SerializablePlayerStats { currentHealth = CurrentHealth, maxHealth = maxHealth, enemiesKilled = EnemiesKilled, tilNextSlot = TilNextSlot, weapons = serializableWeapons, weaponSlots = WeaponSlots, items = items.Select(i => i.ToSerializable()).ToList(), gold = gold, currentLevel = GameStateMachine.CurrentLevel }); }
private Weapon createWeapon(SerializableWeapon weapon) { return(new Weapon(Array.IndexOf(differentWeapons, weapon), game.Content, weapon.modelPath, "Models\\Objects\\" + weapon.modelPath, weapon.weaponType, weapon.projectileType, weapon.weaponDamage, weapon.fireRate, weapon.loadedAmmo, weapon.totalAmmo)); }