public Unit(string typeCode, Map map) { TypeCode = typeCode; Map = map; Health = Type.HealthMax; State = 1; Impulse = Vector3.Zero; Scales = Vector3.One; if (Workarea.Current.Game!=null) _basicEffect = new BasicEffect(Workarea.Current.Game.GraphicsDevice) { VertexColorEnabled = true }; }
private static void CreateMapCemetery(Workarea workarea) { Map map = new Map(workarea) { Name = "Кладбище", Sizes = new Vector3(50f,50f,50f), Gravity = new Vector3(0f, -5f, 0f), FogEnabled = true, ForStart = 1f, FogEnd = 50f, FogColor = Color.Black.ToVector3(), //FogColor = Color.CornflowerBlue.ToVector3(), //EnableDefaultLighting = true LightingEnabled = true, DirectionalLight0 = new MapLight { DiffuseColor = Color.Red.ToVector3(), Direction = Vector3.One, Enabled = true, SpecularColor = Color.Red.ToVector3() } }; map.Heightmap = new float[(int)(map.Sizes.X + 1) * (int)(map.Sizes.Y + 1)]; Random r = new Random(); for (int i = 0; i < (map.Sizes.X + 1) * (map.Sizes.Y + 1); i++) { map.Heightmap[i] = r.Next(3) / 10.0f; } //map.PickUpLandscape((int)map.Width / 2, (int)map.Height / 2, 5f); //map.Units.Add(new Unit("PLANE1", map) //{ // Name = "Самолет1", // Fraction = 2, // Position = new Vector3(7f, 2.0f, 9f), // Angles = new Vector3(0f, 0f, 0f), // //Scales = new Vector3(10f,10f,10f) //}); map.Units.Add(new Unit("HOUSE1", map) { Name = "Дом1", Fraction = 0, Position = new Vector3(7f, 0f, 5f), Angles = Vector3.Zero }); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { map.Units.Add(new Unit("GRAVE1", map) { Name = "Могила" + (i * 5 + j).ToString("G"), Fraction = 0, Position = new Vector3(15f + i * 5, 0f, 15f + j * 5), Angles = new Vector3((float)r.NextDouble() / 5 - 0.1f, (float)r.NextDouble() / 5 - 0.1f - (float)Math.PI / 2f, (float)r.NextDouble() / 5 - 0.1f), Scales = new Vector3((float)r.NextDouble() + 0.5f, (float)r.NextDouble() + 0.5f, (float)r.NextDouble() + 0.5f) }); } } for (int i = 0; i < 10; i++) { map.Units.Add(new Unit("GHOST"+r.Next(1,3), map) { Name = "Призрак"+i, Fraction = 2, Position = new Vector3((float)r.NextDouble() * map.Sizes.X, (float)r.NextDouble() * 5f, (float)r.NextDouble() * map.Sizes.Y) }); } map.Save(Path.Combine(OutPath, "Maps\\Cemetery.xml")); }
private static void CreateMapCity(Workarea workarea) { Map map = new Map(workarea) { Name = "Город", Sizes = new Vector3(50f,50f,50f), Gravity = new Vector3(0f, -9.8f, 0f), FogEnabled = true, ForStart = 5f, FogEnd = 50f, FogColor = new Vector3(0.5f, 0.5f, 0.5f), EnableDefaultLighting = true }; map.Heightmap = new float[(int)(map.Sizes.X + 1) * (int)(map.Sizes.Y + 1)]; Random r = new Random(); for (int i = 0; i < (map.Sizes.X + 1) * (map.Sizes.Y + 1); i++) { map.Heightmap[i] = r.Next(3) / 10.0f; } map.PickUpLandscape(map.Sizes/2, 2f); map.Units.Add(new Unit("PLANE1", map) { Name = "Самолет1", Fraction = 2, Position = new Vector3(7f, 2.0f, 9f), Angles = new Vector3(0f, 0f, 0f), }); map.Units.Add(new Unit("HOUSE1", map) { Name = "Дом1", Fraction = 0, Position = new Vector3(7f, 0f, 5f), Angles = Vector3.Zero }); map.Save(Path.Combine(OutPath, "Maps\\City.xml")); }
public Player(string typeCode, Map map) : base(typeCode,map) { //_boundingSphere = new BoundingSphere(Position, 0.1f); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { settings = Settings.Load("Settings.xml"); workarea = Workarea.Load("Workarea.xml", Content); workarea.Settings = settings; workarea.Game = this; map = Map.Load("Maps\\City.xml", workarea); //map = Map.Load("Maps\\Cemetery.xml", workarea); gameMap=new GameMap(this, map); gameMap.LoadContent(Content); player = new Player("PLAYER", map){ Fraction = 1, Position = new Vector3(10f,0f,15f), Angles = Vector3.Zero}; map.Units.Add(player); camera = new FirstPersonCamera(this, player); workarea.Camera = camera; Interface = new Interface(this, player, fpsCounter); Components.Add(Interface); //axies=new Axies(this); IsFixedTimeStep = settings.IsFixedTimeStep; graphics.SynchronizeWithVerticalRetrace = settings.SynchronizeWithVerticalRetrace; graphics.PreferredBackBufferWidth = settings.ScreenWidth; graphics.PreferredBackBufferHeight = settings.ScreenHeight; graphics.ApplyChanges(); }