public void AddBots(Camera camera, int number) { for (int i = 0; i < number; i++) { AddBot(camera); } }
public AiPlayer(WarZGame game, Camera camera, Tank tank, Terrain terrain, int id) : base(game, camera, tank, terrain) { WZGame = game; Behaviors = new List<AiPlayerBehavior>(MAX_BEHAVIORS); MaxSpeed = 5f; this.id = id; }
public void AddBot(Camera camera, Vector3 Position) { AiPlayer newAi = new AiPlayer(WZGame, camera, _defaultTank, WZGame.Terrain, idCount++) { Position = Position }; //newAi.AddBehavior(new ChaseBehavior(WZGame, newAi, WZGame.Player1)); newAi.AddBehavior(new GoingForwardBehavior(WZGame, newAi)); //newAi.AddBehavior(new WanderBehavior(WZGame, newAi)); AiPlayers.Add(newAi); }
public Player(WarZGame game, Camera camera, Tank tank, Terrain terrain) : base(game) { WZGame = game; _mesh = tank; _terrain = terrain; ChangeCamera(camera); _canonManager = new CanonManager(game); _soundFire = WZGame.Content.Load<SoundEffect>("Sounds/tank - shoot"); _soundTankGo = WZGame.Content.Load<SoundEffect>("Sounds/tank - go"); _soundTankGoInstance = _soundTankGo.CreateInstance(); _soundTankGoInstance.IsLooped = true; // _camera.HorizontalOffset = 4f; }
public void AddBot(Camera camera) { AddBot(camera, Vector3.Forward * Vector3.Right); }
public Axis(Game game, Camera camera) : base(game) { _camera = camera; // TODO: Construct any child components here }
private void ChangeCamera(Camera camera) { _camera = camera; if (_camera != null) { if (_camera is TopViewCamera) _camera.Offset = _topViewCameraOffset; else if (_camera is ChaseCamera) _camera.Offset = _chaseCameraOffset; else _camera.Offset = _fpsCameraOffset; } }
public virtual void DrawModel(Camera camera) { }
public override void DrawModel(Camera camera) { Prepare3DRenderer.PrepareGraphicsDevice(); // Set the world matrix as the root transform of the model. //_model.Root.Transform = Matrix.CreateScale(_scale) * _orientation * Matrix.CreateTranslation(Position); leftBackWheelBone.Transform = _wheelRollMatrix * leftBackWheelTransform; rightBackWheelBone.Transform = _wheelRollMatrix * rightBackWheelTransform; leftFrontWheelBone.Transform = _wheelRollMatrix * leftFrontWheelTransform; rightFrontWheelBone.Transform = _wheelRollMatrix * rightFrontWheelTransform; _model.CopyAbsoluteBoneTransformsTo(_boneTransforms); Matrix worldMatrix = _orientation * Matrix.CreateTranslation(Position); Matrix turretMatrix = _turretOrientation * Matrix.CreateTranslation(Position); Matrix canonMatrix = Matrix.CreateScale(_scale) * _canonOrientation * Matrix.CreateTranslation(Position); _model.CopyAbsoluteBoneTransformsTo(_boneTransforms); WZGame.GraphicsDevice.BlendState = BlendState.AlphaBlend; foreach (ModelMesh mesh in _model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { switch (mesh.Name) { case "canon_geo": //effect.World = _boneTransforms[mesh.ParentBone.Index] * canonMatrix; effect.World = _boneTransforms[mesh.ParentBone.Index] * turretMatrix; break; case "hatch_geo": case "turret_geo": effect.World = _boneTransforms[mesh.ParentBone.Index] * turretMatrix; break; default: effect.World = _boneTransforms[mesh.ParentBone.Index] * worldMatrix; break; } //effect.World = _boneTransforms[mesh.ParentBone.Index]; effect.View = camera.View; effect.Projection = camera.Projection; effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; if (IsGhost) effect.Alpha = 0.5f; else effect.Alpha = 1f; if (isAiEnemy) effect.SpecularColor = _specularColor_red; else effect.SpecularColor = _specularColor_original; } mesh.Draw(); } WZGame.GraphicsDevice.BlendState = BlendState.Opaque; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Window.Title = "WarZ v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Prepare3DRenderer.Initialize(this); Song mainTheme = Content.Load<Song>(@"Music/main1"); MediaPlayer.Play(mainTheme); MediaPlayer.Volume *= 0.7f; _fpsCamera = new FPSCamera(this, new Vector3(0, 10, 3), Vector3.Zero, Vector3.Up); _topViewCamera = new TopViewCamera(this, new Vector3(0, 10, 0), Vector3.Zero, Vector3.Forward); // _chaseCamera = new ChaseCamera(this, new Vector3(0, 10, 3), Vector3.Zero, Vector3.Up); SimpleCamera simpleCam = new SimpleCamera(this, Vector3.Zero, Vector3.Forward, Vector3.Up); _aiCamera = new SimpleCamera(this, Vector3.Backward, Vector3.Zero, Vector3.Up); GodViewCamera godView = new GodViewCamera(this, Vector3.Up * 50, Vector3.Forward * 62.5f + Vector3.Right * 62.5f, Vector3.Up); _cameras = new Camera[3]; _cameras[0] = _fpsCamera; _cameras[1] = _topViewCamera; _cameras[2] = godView; cameraNumber = 0; _activeCamera = _fpsCamera; _3DAxis = new Axis(this, _activeCamera); _GUI = new GUIManager(this); _GUI.CrossairVisible = true; Terrain = new Terrain(this, _activeCamera); _skybox = new Skybox(this, _activeCamera); Tank tank = new Tank(this, Content.Load<Model>(@"Models\Tank\DXTank")); Player1 = new Player(this, _activeCamera, tank, Terrain); _aiPlayerManager = new AiPlayerManager(this, tank); _collisionSystem = new CollisionSystem(this, _player1, _aiPlayerManager); _particlesManager = new ParticlesManager(this); Components.Add(_skybox); //Components.Add(_activeCamera); Components.Add(Player1); Components.Add(_3DAxis); Components.Add(Terrain); Components.Add(_aiPlayerManager); Components.Add(_collisionSystem); Components.Add(_particlesManager); Components.Add(_GUI); _aiPlayerManager.AddBot(_aiCamera, Vector3.Backward * 10 + Vector3.Right * 20); _aiPlayerManager.AddBot(_aiCamera, Vector3.Backward * 10 + Vector3.Right * 10); _aiPlayerManager.AddBot(_aiCamera, Vector3.Backward * 10 + Vector3.Right * 10); _aiPlayerManager.AddBot(_aiCamera, Vector3.Backward * 10 + Vector3.Right * 10); _aiPlayerManager.AddBot(_aiCamera, Vector3.Backward * 10 + Vector3.Right * 10); base.Initialize(); }
//TODO:CHANGE the Matrix.World of the Draw, this should be scale * rotation * position public void DrawModel(Camera camera) { _model.Draw(Matrix.CreateTranslation(camera.Position), camera.View, camera.Projection); }
public Terrain(Game game, Camera camera) : base(game) { _camera = camera; }