public void Update(GameTime time) { world.Update(time); scoretext.Text = Manager.UserData.GameState.Score.ToString(); healthbar.Progress = (float)Manager.UserData.GameState.Health / Player.MaxHealth; scoretext.Position = new Vector2(Screen.ViewWidth - scoretext.Width, 0); NPCCoordinator.GetInstance().UpdateEnemies(time); main.Update(time); }
public void OnActivated(params object[] args) { Manager.GameSettings.MusicVolume = 0.05f; SoundManager.StopAllLoops(); SoundManager.PlaySound(DataHandler.Sounds[SoundType.Loop], SoundCategory.Music, true); gameover = won = false; // Specifications of the world short cameradistance = 40; // Create world world.FloorWidth = cellspr; world.FloorHeight = cellspr; world.Clear(); world.ActiveCam = new OrbitCamera(cameradistance); world.CreateTerrain(); #region TestCode //world.Add(new StarBox(new Vector3(50, 0, 100))); //world.Add(new FirstAidBag(new Vector3(50, 0, 100))); //world.Add(new LandMine(new Vector3(50, 0, 100))); //world.Add(new Dagger(player.Position, player.Rotation)); //world.Add(new BrickWall(new Vector3(-Wall.WallLowAnchor.X, 0, -Wall.WallLowAnchor.Z), 0)); //world.Add(new BrickWall(new Vector3(-Wall.WallLowAnchor.Z, 0, -Wall.WallLowAnchor.X), 1)); #endregion int d = 6; currentmap = new Map(cellspr, cellspr, new Rectangle(cellspr / 2 - d / 2, cellspr / 2 - d / 2, d, d)); currentmap.BuildMaze(); player = new Player(new Vector3((cellspr / 2 + d / 4) * Map.Celld, 0, cellspr / 2 * Map.Celld), Vector3.Zero, 0.02f); player.Rotation = new Vector3(0, -MathHelper.PiOver2, 0); esc = new EscapeDrone(new Vector3((cellspr / 2 - d / 4) * Map.Celld, 0, cellspr / 2 * Map.Celld)); world.Add(player); world.Add(esc); //player.Position += new Vector3(-300, 0, 0); //player.Position = esc.Position; /* * Model testmodel = Manager.Game.Content.Load<Model>("Models\\Fence\\model"); * Object3D obj = new Object3D(testmodel, Vector3.Zero, Vector3.Zero, Vector3.Zero, Vector3.Zero, 2); * obj.Position = player.Position + new Vector3(50,0,50); * world.Add(obj); */ new NPCCoordinator(currentmap); var coord = NPCCoordinator.GetInstance(); PopulateMap(); BuildGUI(); #if !DEBUG Manager.Game.IsMouseVisible = false; world.ActiveCam.LockMouse = true; #endif }
public void ShowYouWon() { SoundManager.PlaySound(DataHandler.Sounds[SoundType.Flyaway], SoundCategory.SFX); sign = new UICell(DataHandler.UIObjectsTextureMap[UIObjectType.YouWon], ""); sign.setSizeRelative(0.4f, Orientation.Portrait); sign.Position = new Vector2((Screen.ViewWidth - sign.Width) / 2, Screen.ViewHeight / 2); won = true; Manager.Game.IsMouseVisible = true; world.Destroy(player); esc.Path = new NodedPath(new Vector3[] { esc.Position + new Vector3(10000, 200, 10000), esc.Position + new Vector3(0, 200, 0), esc.Position }); NPCCoordinator.GetInstance().Register(esc); world.ActiveCam.LockMouse = false; }
public override void OnFinishedPlayingAnimation() { if (Dying) { NPCCoordinator.GetInstance().UnRegister(this); World.GetInstance().Destroy(this); return; } base.OnFinishedPlayingAnimation(); if (IsIdle) { Model = IdleModel; } else { Model = WalkingModel; } Rotation = lrot; StartAnimation(DefaultClip); attacking = false; }
private void PopulateMap() { int minp = 10, maxp = 20; Factory <INPC> enfac = SuperFactory.GetFactory <INPC>(); Factory <Collectible> clfac = SuperFactory.GetFactory <Collectible>(); var coord = NPCCoordinator.GetInstance(); coord.Reset(); for (int i = 0; i < noenemies; i++) { var e = enfac.CreateNew((byte)ran.Next(0, enfac.AvailableTypes), Vector3.Zero, coord.GenerateRandomPath(ran.Next(minp, maxp))); coord.Register(e); world.Add(e); } float offset = -Map.Celld / 4; byte[,] used = new byte[cellspr, cellspr]; for (int i = 0; i < nocol; i++) { int x = ran.Next(0, cellspr); int z = ran.Next(0, cellspr); int yoff = used[x, z]; float fx = x * Map.Celld + offset; float fz = z * Map.Celld + offset; var c = clfac.CreateNew((byte)ran.Next(0, clfac.AvailableTypes), new Vector3(fx, yoff, fz)); used[x, z] += (byte)(c.HighAnchor.Y - c.LowAnchor.Y); world.Add(c); // Place mine x = ran.Next(0, cellspr); z = ran.Next(0, cellspr); yoff = used[x, z]; if (yoff == 0) { fx = x * Map.Celld + offset; fz = z * Map.Celld + offset; world.Add(new LandMine(new Vector3(fx, 0, fz))); } } }
public NPCCoordinator(Map map) { this.map = map; instance = this; }