public Cell GenerateCellAt(int x, int y) { int health = (int)CellHealthFromNoise(x, y); Cell c = cells[new Point(x, y)] = new Cell(x, y, 32, 32, health, offset); c.Initialize(); if (!c.IsHealthy) { HollowCells.Add(c); if (health < 30 && health > 20) { GameObjects.Add(ItemFactory.Build("grass", c.Position)); } } return(c); }
public static void Update(GameTime gameTime) { if (EnemyCount >= 5) { return; } nextSpawnCooldownMs -= gameTime.ElapsedGameTime.Milliseconds; if (nextSpawnCooldownMs <= 0f) { Enemy enemy = new Enemy(GameWorld.Current.Map.RandomHollowCell().Position); Weapon wp = Weapons.Build("sniper_rifle"); enemy.TakeWeapon(wp); GameObjects.Add(enemy, true); GameObjects.Add(wp, true); nextSpawnCooldownMs = 10000f; EnemyCount += 1; } }
public void Fire(Vector2 target) { if (remainingCooldownTime > 0) { return; } else { remainingCooldownTime = CooldownTime; } Bullet b = new Bullet(Owner, Position, target); GameObjects.Add(b, true); string shotSound = $"bullet0{Randomizer.Random.Next(1, 4)}"; Sounds.PlayEffect(shotSound, 25); }
public bool TakeDamage(int damage, GameObject source) { if (source is Bullet) { GameObject shooter = ((Bullet)source).Shooter; if (shooter is Player) { Target = shooter; } } Health.Decrease(damage); if (Health.Value <= 0f) { Weapon.Owner = null; Map.Current.World.RemoveBody(PhysicsBody()); Destroy(); } motionState.TakeDamage(damage, source); weaponState.TakeDamage(damage, source); GameObjects.Add(new BloodSplat(Position)); AddComponent(new PawnBlood()); return(true); }
public static void Write( Vector2 position, string text, Color color, float lifetimeMillis, float initialScale) { GameObjects.Add(new TempText(position, text, color, lifetimeMillis, initialScale), true); }
public void Update(GameTime gameTime) { GameWorld.Current.Map.Update(gameTime); EnemySpawn.Update(gameTime); GameObjects.Update(gameTime); }
public void Destroy() { GameObjects.Destroy(this); }