public static void AddEnemyHud(SpriteBatch sb, Display3D.CCamera cam) { foreach (CEnemy enemy in _enemyList) { enemy.AddEnemyHUD(sb, cam); } }
public static void Draw(GameTime gameTime, SpriteBatch spriteBatch, Display3D.CCamera cam) { for (int i = 0; i < _enemyList.Count; i++) { _enemyList[i].Draw(gameTime, spriteBatch, cam._view, cam._projection, (selectedBot == i)); } }
public static void Update(GameTime gameTime, Display3D.CCamera cam) { FixQueuedBots(); foreach (CEnemy enemy in _enemyList) { enemy.Update(gameTime, cam); } }
public void AddEnemyHUD(SpriteBatch sb, Display3D.CCamera cam) { Ray ray = new Ray(cam._cameraPos, _position - cam._cameraPos); int mdlid; if (Display3D.CModelManager.CheckRayIntersectsModel(ray, out mdlid) == null) { if (Vector3.Distance(cam._cameraPos, _position) < 50) { Vector3 Pos = Display2D.C2DEffect._graphicsDevice.Viewport.Project(new Vector3(_position.X, _position.Y + _height, _position.Z), cam._projection, cam._view, Matrix.Identity); sb.Begin(); if (Pos.Z < 1) { sb.DrawString(CEnemyManager._hudFont, _hudText, new Vector2(Pos.X - _hudTestSizeX, Pos.Y), Color.Red); } sb.End(); } } }
public void LoadContent(ContentManager content, Display3D.CCamera cam) { // We load the ennemy content _model.LoadContent(content); // We Create the forces application on the Ennemy _physicEngine = new CPhysics(); _physicEngine.LoadContent(0.2f, new bool[] { true, true }); _physicEngine._triangleList = cam._physicsMap._triangleList; _physicEngine._triangleNormalsList = cam._physicsMap._triangleNormalsList; _physicEngine._terrain = cam._physicsMap._terrain; _physicEngine._waterHeight = cam._physicsMap._waterHeight; _physicEngine.heightCorrection = 0.85f; GenerateHitBoxesTriangles(); if (!_isMultiPlayer) { _loaded = true; } }
public void UpdateMultiplayer(GameTime gameTime, Display3D.CCamera cam) { if (_isDead) { _position = _deathPosition; Matrix world = Matrix.CreateWorld(_position, Vector3.Right, Vector3.Up); _rotation = _deathRotation; _isMoving = false; _isWaitAnimPlaying = false; _isWalkAnimPlaying = false; } // He was playing the anim, now the character is really dead if (_isDyingAnimPlaying && _model.HasFinished()) { _position = _deathPosition; _rotation = _deathRotation; _isDead = true; _isMoving = false; } if (_model.animationController == null) { return; } // Interpolation if (_multiSpeed > 0) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; _position += _multiDirection * _multiSpeed * elapsedTime; } else if (_isFrozen && !_isFrozenAnimPlaying && !_isDyingAnimPlaying) { _model.ChangeAnimation("frozen", true, 0.8f); _isFrozenAnimPlaying = true; _isMoving = false; } // We update the character pos, rot... _rotation = Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY((rotationValue)); if ((_isJumping || _isSwitchingWeapon || _isReloading) && _model.HasFinished()) { if (_isCrouch) { _model.ChangeAnimSpeed(2.5f); _model.ChangeAnimation(CConsole._Weapon._weaponsArray[_selectedWeap].MultiType + "_walk-crouch", true, 0.5f); _isWaitAnimPlaying = false; _isWalkAnimPlaying = true; } else { _model.ChangeAnimSpeed(2.5f); _model.ChangeAnimation(CConsole._Weapon._weaponsArray[_selectedWeap].MultiType + "_walk", true, 0.5f); _isWaitAnimPlaying = false; _isWalkAnimPlaying = true; } _isMoving = true; _isJumping = false; _isReloading = false; _isSwitchingWeapon = false; } _model.Update(gameTime, _position, _rotation); _loaded = true; }
public void Update(GameTime gameTime, Display3D.CCamera cam) { if (!_isMultiPlayer) { if (_model.animationController == null) { return; } // We update the character pos, rot... _rotation = Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY((rotationValue)); _model.Update(gameTime, _position, _rotation); if (_isDead) { _position = _deathPosition; Matrix world = Matrix.CreateWorld(_position, Vector3.Right, Vector3.Up); _rotation = _deathRotation; _isMoving = false; _isWaitAnimPlaying = false; _isWalkAnimPlaying = false; } // Play Anims if (!_isFrozen && !_isDead) { _model.RotateBone(2, cam._pitch); // The character is waiting or running SetWalk(_isMoving, CConsole._Weapon._weaponsArray[_selectedWeap].MultiType); _isFrozenAnimPlaying = false; } else if (_isFrozen && !_isFrozenAnimPlaying) { _model.ChangeAnimation("frozen", true, 0.8f); _isFrozenAnimPlaying = true; } if (!_isDead && !_isFrozen) { // He was playing the anim, now the character is really dead if (_isDyingAnimPlaying && _model.HasFinished()) { _position = _deathPosition; _rotation = _deathRotation; _isDead = true; } if ((_isJumping || _isSwitchingWeapon || _isReloading) && !_isDyingAnimPlaying && _model.HasFinished()) { if (_isCrouch) { _model.ChangeAnimSpeed(2.5f); _model.ChangeAnimation(CConsole._Weapon._weaponsArray[_selectedWeap].MultiType + "_walk-crouch", true, 0.5f); } else { _model.ChangeAnimSpeed(2.5f); _model.ChangeAnimation(CConsole._Weapon._weaponsArray[_selectedWeap].MultiType + "_walk", true, 0.5f); } _isJumping = false; _isReloading = false; _isSwitchingWeapon = false; } // new target is the camera position if (_isFollowingPlayer && !_isDyingAnimPlaying) { _targetPos = cam._cameraPos; } if (!_isFrozen && !_isDyingAnimPlaying && Vector3.DistanceSquared(_position, _targetPos) > 10.0f) { Vector3 translation = Vector3.Transform(Vector3.Backward, Matrix.CreateRotationY(rotationValue)); translation.Normalize(); rotationValue = (float)Math.Atan2(_targetPos.X - _position.X, _targetPos.Z - _position.Z); translation = _runningVelocity * translation; _position = _physicEngine.GetNewPosition(gameTime, _position, translation, false); _isMoving = true; } else { _isMoving = false; } // Attack AttackPlayer(Vector3.DistanceSquared(_position, CConsole._Camera._cameraPos)); } } else { UpdateMultiplayer(gameTime, cam); } }
public static void AddEnemy(ContentManager content, Display3D.CCamera cam, CEnemy enemy) { enemiesToAddQueue.Add(enemy); enemy.LoadContent(content, cam); }
public static void drawThrownProjectiles(GameTime gameTime, Matrix view, Matrix projection, Display3D.CCamera cam) { foreach (Display3D.CProjectile projectile in _thrownProjectiles) { projectile.Draw(view, projection, cam._cameraPos); } }