private void Awake() { CreatureSO data = this._creatures.Creatures.ElementAt( UnityEngine.Random.Range(0, this._creatures.Creatures.Count())); this.Setup(data); }
private static void CreateCreatureAsset() { CreatureSO data = ScriptableObject.CreateInstance <CreatureSO>(); const string prefix = "_Creature"; string name = prefix; int nr = 0; while (AssetDatabase.FindAssets(name, new[] { _CREATURES_ASSETS_PATH }).Length > 0) { name = prefix + ++nr; } AssetDatabase.CreateAsset(data, $"{_CREATURES_ASSETS_PATH }/{name}.asset"); }
public void Setup(CreatureSO data) { if (this.Creature != null) { this.Creature.OnDamage -= this.HealthSystemOnDamage; this.Creature.OnHealing -= this.HealthSystemOnDamage; } this._image.sprite = data.Sprite; this.Creature = new Creature(data.name, data.Health) { Abilities = new Ability[data.Abilities.Length] }; for (int i = 0; i < data.Abilities.Length; i++) { this.Creature.Abilities[i] = data.Abilities[i]; } this.Creature.OnDamage += this.HealthSystemOnDamage; this.Creature.OnHealing += this.HealthSystemOnDamage; }