public TestScreen(IGameScreenManager screenManager) : base(screenManager) { //objectManager.AddObject(new NormalPlant()); TouchPanel.EnabledGestures = GestureType.Tap | GestureType.Hold; // Init game data initSpriteBank(); gameBoard = new PZBoard(9, 5); gameBoard.Board = new int[,]{ {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0} }; // Gen object for (int i = 0; i < 5; i++) for (int j = 0; j < 9; j++) { int type = gameBoard.Board[i, j]; if (type == 1) { objectManager.AddObject(PZObjectFactory.Instance.createPlant(gameBoard.GetPositonAt(i, j))); } else if (type == 2) { objectManager.AddObject(PZObjectFactory.Instance.createIcePlant(gameBoard.GetPositonAt(i, j))); } } }
public void Update(PZBoard board, GameTime gameTime) { if (_numberZombie == 0) { _numberZombie = GRandom.RandomInt(NumberFrom, NumberTo);//rand.Next(NumberFrom, NumberTo); } if (_currentState == WaveState.WAVING) { if (_nextZombieTime == TimeSpan.Zero) { _nextZombieTime = TimeSpan.FromSeconds(GRandom.RandomDouble(TimeNextZombieFrom, TimeNextZombieTo)); // Calc time to drop zombie //Debug.WriteLine("WAVE: Tha ZOMBIE trong {0} giay", _nextZombieTime); } if (_currentTime >= _nextZombieTime) // Tha zombie { string zombieString = Zombies[GRandom.RandomInt(Zombies.Count)];//rand.Next(0, Zombies.Count)]; ObjectEntity obj = GameObjectCenter.Instance.CreateObject(zombieString); int row = GRandom.RandomInt(4); //Debug.WriteLine("LEVEL: Tha ZOMBIE at row {0}", row); board.AddObjectAt(obj, row, 10); _currentTime = TimeSpan.Zero; _nextZombieTime = TimeSpan.Zero; if (IsFirstZombie && Owner.IsFirstZombie) { SCSServices.Instance.AudioManager.PlaySound(_soundFirst, false, true); Owner.IsFirstZombie = false; IsFirstZombie = false; } _currentZombie++; } else _currentTime += gameTime.ElapsedGameTime; // Kiem tra da tha het zombie chua if (_currentZombie >= _numberZombie) _currentState = WaveState.END; } }