/// <summary> /// Loads the ship data and sets up it's stats /// </summary> public override void LoadContent() { CheckShouldLoad(); ShipData = Data as ShipData; DebugUtils.AssertNotNull(ShipData); ShipDeathExplosionSFX = new CustomSoundEffect(ShipData.ExplosionSFXAsset); DamageModule = AddModule(new DamageableObjectModule(ShipData.Defence)); DamageModule.CalculateDamage += GetCardObjectPair <CardShipPair>().ShipCard.CalculateDamageDoneToThis; // Add engine UI from our data Engines = new Engine[ShipData.EngineHardpoints.Count]; Debug.Assert(ShipData.EngineHardpoints.Count > 0); for (int i = 0; i < ShipData.EngineHardpoints.Count; ++i) { Engines[i] = AddChild(new Engine(ShipData.Speed, ShipData.EngineHardpoints[i])); } Debug.Assert(ShipData.Defence > 0); Debug.Assert(ShipData.DamageHardpoints.Count >= ShipData.Defence - 1); DamageUI = new DamageUI[ShipData.Defence - 1]; for (int i = 0; i < ShipData.Defence - 1; i++) { DamageUI damageUI = AddChild(new DamageUI(ShipData.DamageHardpoints[i])); damageUI.Hide(); // Initially hide all the damage UI DamageUI[i] = damageUI; } base.LoadContent(); }
public bool Use(Creature self, Creature opponent) { if (!this.IsAllowedToUse(self, opponent)) { return(false); } if (this._soundPrefab == null || this.SoundFx == null) { LogHelper.LogWarning(typeof(Ability), $"{this.Name} has no sound prefab or FX"); } else { CustomSoundEffect sfx = GameObject.Instantiate(this._soundPrefab); sfx.GetComponent <AudioSource>().clip = this.SoundFx; sfx.Play(); } if (UnityEngine.Random.Range(0f, 1f) < this.Accuracy) { this.Execute(self, opponent); } else { LogHelper.Log(typeof(Ability), $"{this.Name} missed!"); } return(true); }
/// <summary> /// Loads the engine data and sets up it's stats /// </summary> public override void LoadContent() { CheckShouldLoad(); EngineData = Data as EngineData; DebugUtils.AssertNotNull(EngineData); EngineSFX = new CustomSoundEffect("Engines\\Engine"); EngineBlaze = AddChild(new EngineBlaze(Vector2.Zero)); base.LoadContent(); }
/// <summary> /// Get our firing sfx /// </summary> public override void LoadContent() { CheckShouldLoad(); Debug.Assert(Data is ProjectileData); ProjectileData projectileData = Data as ProjectileData; FiringSFX = new CustomSoundEffect(projectileData.FiringSFXAsset); ExplosionSFX = new CustomSoundEffect(projectileData.ExplosionSFXAsset); base.LoadContent(); }
/// <summary> /// Loads the shield data and sets up it's stats /// </summary> public override void LoadContent() { CheckShouldLoad(); ShieldData = Data as ShieldData; DebugUtils.AssertNotNull(ShieldData); ShieldExplosionSFX = new CustomSoundEffect("Explosions\\ShieldExplosion"); DamageModule = AddModule(new DamageableObjectModule(ShieldData.MaxShieldStrength)); FlashingModule = AddModule(new FlashingObjectModule(0.15f, 1, 1)); base.LoadContent(); }