public virtual void TakeDamage(float damage, float goThroughShield, DamageType damageType, bool FromShield) { if (FromShield) { if (damageType != DamageType.damageOverTime) { SoundManager.explosion.Play(); } // Rock resist hull if (damageType == DamageType.rock) { damage *= ShipHull.RockResistance; } // Armor damage *= (float)(1 - (float)ShipHull.Armor / 100); if (ShipShield.Value > 0 && goThroughShield < 1) { float damageThroughShield = damage * goThroughShield; damage -= damageThroughShield; Health.Change(-damageThroughShield); Health.Change(ShipShield.Change(-damage)); } else if (ShipShield.Value <= 0 || goThroughShield >= 1) { Health.Change(-damage); } } else { ShipShield.Method(damage, goThroughShield, damageType, this, ShipShield); } }
public override void UpdateLevel(Level level) { base.UpdateLevel(level); DamageOverTime(); Animation(); Size = MathHelper.Lerp(Size, 1, 0.05f); ShipShield.Change(shieldRegeneration); // Weapons foreach (Weapon w in Weapons) { w.UpdateLevel(level); } // Move Vector2 move = new Vector2((int)ShipLocation * 100 + 200, Position.Y) - Position; Position += move * 0.05f; Position += new Vector2(0, KnockBack); KnockBack = MathHelper.Lerp(KnockBack, 0, 0.1f); // Ship tilt if (move.Length() > 10) { Direction += move.Length() * DirectionSpeed; } Direction = MathHelper.Lerp(Direction, StandardDirection, 0.1f); }
// Shield public void Power3() { // find the ship GameObject ship = GameObject.FindWithTag("Ship"); // get the script ShipShield shieldScript = ship.GetComponent <ShipShield> (); shieldScript.SpawnShield = true; }
public void DrawGameOver(SpriteBatch spriteBatch) { base.Draw(spriteBatch); spriteBatch.Draw(EngineAnimation, Position, new Rectangle(Frame * FrameWidth, 0, FrameWidth, FrameHeight), Color.White, Direction, new Vector2(Texture.Width / 2, Texture.Height / 2), Size, SpriteEffects.None, Depth - 0.1f); spriteBatch.DrawString(TextureManager.SpriteFont20, "Killer", new Vector2(500, 160), Color.White); ShipShield.DrawInventory(spriteBatch, new Vector2(564, 300)); ShipHull.DrawInventory(spriteBatch, new Vector2(628, 300)); Health.Draw(spriteBatch); for (int i = 0; i < Weapons.Count(); i++) { Weapons[i].DrawInventory(spriteBatch, new Vector2(692 + i * 64, 300)); } }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); spriteBatch.Draw(EngineAnimation, Position, new Rectangle(Frame * FrameWidth, 0, FrameWidth, FrameHeight), Color.White, Direction, new Vector2(Texture.Width / 2, Texture.Height / 2), Size, SpriteEffects.None, Depth - 0.1f); Health.Draw(spriteBatch); if (!(this is Boss)) { ShipShield.Draw(spriteBatch); } else { ShipShield.DrawBoss(spriteBatch); } ShipHull.Draw(spriteBatch); }
public void Action(int tilesMatched, TileType tileType, Level level, bool manuallyMatched) { if (tileType == TileType.cog) { Energy.Change(tilesMatched * 5 + (tilesMatched - 3) * 10); SoundManager.match.Play(); } else if (Energy.Value > 10 || !manuallyMatched) { SoundManager.match.Play(); if (manuallyMatched) { Energy.Change(-10); } if (tileType == TileType.shoot && Weapons[SelectedWeapon].Disabled < 0) { KnockBack = 3; Weapons[SelectedWeapon].Method(this, Weapons[SelectedWeapon], tilesMatched, level, false); } if (tileType == TileType.left && ShipLocation != Location.left) { MoveLeft += 20 * tilesMatched; } if (tileType == TileType.right && ShipLocation != Location.right) { MoveRight += 20 * tilesMatched; } if (tileType == TileType.shield && ShipShield.Value != ShipShield.Width) { ShipShield.Change((ShipShield.ShieldHeal / 3) * tilesMatched); } } else { level.CombatText("NOT ENOUGH ENERGY!"); SoundManager.notEnoughEnergy.Play(); } }
void RemovePowerup() { GameObject gameManager = GameObject.Find("GameManager"); LoadSettings script = gameManager.GetComponent <LoadSettings> (); switch (script.shipNumber) { case 1: ShipFire fireScript = Ship.GetComponent <ShipFire>(); fireScript.enabled = true; ShipDoubleShot doubleShotScript = Ship.GetComponent <ShipDoubleShot>(); doubleShotScript.enabled = false; break; case 2: ShipShield shieldScript = Ship.GetComponent <ShipShield>(); shieldScript.SpawnShield = false; break; } }
void OnTriggerEnter2D(Collider2D other) { // cant be destroyed from the ship or powerups and is on a timmer if (other.gameObject.tag != "Ship" && other.gameObject.tag != "PowerUp01" && other.gameObject.tag != "PowerUp02" && other.gameObject.tag != "PowerUp03" && other.gameObject.tag != "PowerUp04") { if (other.gameObject.tag != "Boss") { Destroy(other.gameObject); } if (canDestroy == true) { Destroy(gameObject); // toggle shield existing GameObject ship = GameObject.FindWithTag("Ship"); ShipShield script = ship.GetComponent <ShipShield>(); script.ShieldExists = false; } } }
private void InitReferences() { trans = transform; componentGridTrans = shipBP.Hull.ComponnentGridTrans; shieldEffectDisabler = trans.FindChild("ShieldEffect").GetComponent<DisableEffectAfterTime>(); #if FULL_DEBUG if (!shieldEffectDisabler) { Debug.LogError("No Shield effect found or shield effect has an incorrect or missing <DisableEffectAfterTime> Component"); } if(!componentGridTrans) { Debug.LogError("No Component Grid trans found"); } if (trans.FindChild("ComponentCamera") == null) { Debug.LogError("No Component camera found"); } #endif componentCamera = trans.FindChild("ComponentCamera").gameObject; componentCamera.SetActive(false); targetCamTrans = trans.FindChild("TargetingCamera"); #if FULL_DEBUG if (targetCamTrans == null) { Debug.LogError("No Targeting camera found"); } #endif defaultTargetCamEuler = targetCamTrans.eulerAngles; targetingCamera = targetCamTrans.gameObject; targetingCamera.SetActive(false); expolosionObject = trans.FindChild("Explosion").gameObject; shipShield = GetComponentInChildren<ShipShield>(); #if FULL_DEBUG if(!shipShield) { Debug.LogError("Ship shield not found"); } #endif shipShield.Init(this); }
public RechargeAbility(string dataAsset, ShipShield parentShield) : base(dataAsset, parentShield) { ShipShield = parentShield; }
static void Main(string[] args) { ShipShield shipShield = new ShipShield(); shipShield.Init(); }
public void DrawInventory(SpriteBatch spriteBatch) { // Health Health.Draw(spriteBatch); spriteBatch.DrawString(TextureManager.SpriteFont15, "Current Health:", new Vector2(Health.Position.X + 15, Health.Position.Y - 30), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); if (selectedItem != null) { spriteBatch.Draw(selectedItem.Texture, new Vector2(Globals.MState.X - 32, Globals.MState.Y - 32), null, selectedItem.Colour * 0.5f, 0f, Vector2.Zero, 1f, SpriteEffects.None, selectedItem.Depth); spriteBatch.Draw(selectedItem.TextureBackground, new Vector2(Globals.MState.X - 32, Globals.MState.Y - 32), null, Color.White * 0.5f, 0f, Vector2.Zero, 1f, SpriteEffects.None, selectedItem.Depth + 0.1f); } // Weapons spriteBatch.DrawString(TextureManager.SpriteFont20, "Weapons", new Vector2(40, 130), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); for (int i = 0; i < 3; i++) { Inventory[2 + i, 5].DrawInventory(spriteBatch, new Vector2(i * 64 + 32, 200)); spriteBatch.Draw(TextureManager.inventorySlot, new Vector2(i * 64 - 32 + 32, 200 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); } // Shield spriteBatch.DrawString(TextureManager.SpriteFont20, "Shield", new Vector2(60, 258), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); ShipShield.DrawInventory(spriteBatch, new Vector2(100, 328)); spriteBatch.Draw(TextureManager.inventorySlot, new Vector2(100 - 32, 328 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); // Hull spriteBatch.DrawString(TextureManager.SpriteFont20, "Hull", new Vector2(70, 386), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); ShipHull.DrawInventory(spriteBatch, new Vector2(100, 456)); spriteBatch.Draw(TextureManager.inventorySlot, new Vector2(100 - 32, 456 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); // Inventory spriteBatch.Draw(TextureManager.inventory, new Vector2(300 - 32, 200 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); spriteBatch.DrawString(TextureManager.SpriteFont20, "Inventory", new Vector2(360, 100), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); for (int i = 0; i < Inventory.GetLength(0); i++) { for (int j = 0; j < Inventory.GetLength(1) - 2; j++) { Inventory[i, j].DrawInventory(spriteBatch, new Vector2(i * 64 + 300, j * 64 + 200)); } } // Crafting spriteBatch.DrawString(TextureManager.SpriteFont20, "Crafting", new Vector2(805, 100), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); craft.Draw(spriteBatch); for (int i = 0; i < 3; i++) { if (currentlyCrafting > 0) { Vector2 target = new Vector2(864, 350); Inventory[i, 6].DrawInventory(spriteBatch, new Vector2(MathHelper.Lerp(i * 64 + 800, target.X, (float)(60 - currentlyCrafting) / 60), MathHelper.Lerp(200, target.Y, (float)(60 - currentlyCrafting) / 60))); } else { Inventory[i, 6].DrawInventory(spriteBatch, new Vector2(i * 64 + 800, 200)); } spriteBatch.Draw(TextureManager.inventorySlot, new Vector2(i * 64 + 800 - 32, 200 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); } spriteBatch.Draw(TextureManager.craftingArrow, new Vector2(832, 350 - 32 - 80), null, CanCraft() ? new Color(0, 255, 255) : Color.Gray, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); Inventory[3, 6].DrawInventory(spriteBatch, new Vector2(864, 350)); spriteBatch.Draw(TextureManager.inventorySlot, new Vector2(864 - 32, 350 - 32), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.01f); }