public GameObject BuildObject(GameInstance g, int nb_players) { GameObject o = null; Vector2 p = new Vector2(0, 0); Type type = Type.GetType(type_str); if (type == typeof(Bomb)) { o = new Bomb(p); } if (type == typeof(Coin)) { o = new Coin(p); } if (type == typeof(Fireball)) { o = new Fireball(p); } if (type == typeof(FireGreen)) { o = new FireGreen(p); } if (type == typeof(FirePoison)) { o = new FirePoison(p); } if (type == typeof(FirePink)) { o = new FirePink(p); } if (type == typeof(Food)) { o = new Food(p); } if (type == typeof(Monstar)) { o = new Monstar(p, g, Controller.Direction.RIGHT); } if (type == typeof(Player)) { o = new Player(p, g.GetNewScorePosition(nb_players), g, -1); } return(o); }
public void Update(float elapsed) { if (!game.Level.Current.StopFalling) { time += elapsed; while (time > interval) { Controller.Direction dir; Vector2 vec = new Vector2(0f, 0f); if (random.Next(0, 2) == 0) // p = 1/2 to be on the right or on the left { dir = Controller.Direction.LEFT; vec.X = TimGame.GAME_WIDTH; } else { dir = Controller.Direction.RIGHT; vec.X = 0f; } Monstar m = new Monstar(vec, game, dir); EnemiesList.Add(m); time -= interval; } } // Delete enemies that are out of bounds EnemiesList.RemoveAll((e => e.IsOutOfBounds())); // Moving foreach (Monstar m in EnemiesList) { m.Move(elapsed); } // Delete enemies that are dead EnemiesList.RemoveAll((e => e.Dead)); }