public Weapon(Game1 game,Player player, Model model, Unit unit) : base(game, unit, new CModel(game, model)) { this.player = player; Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); }
public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < monsters.Count; ++j) { if (monsters[j].unit.alive && unit.collideWith(monsters[j].unit)) { monsters[j].health -= myGame.difficultyConstants.MONSTER_HEALTH_PER_BULLET; hpBillBoardSystem.setTexture(j); if (monsters[j].health <= 0) { monsters[j].Die(); monsters[j].unit.alive = false; myGame.mediator.fireEvent(MyEvent.M_DIE); } else { monsters[j].TakeDamage(); ((MonsterUnit)monsters[j].unit).moving = true; } return true; } } return false; }
public CDrawableComponent(Game1 game,Unit unit, CModel model) : base(game) { myGame = game; this.unit = unit; this.cModel = model; unit.BoundingSphere = cModel.buildBoundingSphere(); }
public Monster(Game1 game, SkinnedModel skinnedModel, Unit unit) : base(game, unit, new MonsterModel(game, skinnedModel)) { monsterModel = ((MonsterModel)cModel); monsterUnit = ((MonsterUnit)unit); foreach (ModelMesh mesh in skinnedModel.Model.Meshes) foreach (SkinnedEffect effect in mesh.Effects) effect.EnableDefaultLighting(); }
public bool checkCollisionWithBullet(Unit unit) { // If shot is still in play, check for collisions for (int j = 0; j < firstAidKits.Count; ++j) { if (unit.collideWith(firstAidKits[j].unit)) { addHealth(j); return true; } } return false; }
public Player(Game1 game, SkinnedModel skinnedModel, Unit unit) : base(game, unit, new PlayerModel(game, skinnedModel)) { foreach (ModelMesh mesh in skinnedModel.Model.Meshes) foreach (SkinnedEffect effect in mesh.Effects) effect.EnableDefaultLighting(); spriteBatch = new SpriteBatch(game.GraphicsDevice); crossHairTex = game.Content.Load<Texture2D>("crosshair"); delayedAction = new DelayedAction(800); //run at first to show to the character otherwise the character dont show playerRun(); }
public Water(MyGame game, Model model, Unit unit) : base(game,unit,new CModel(game, model)) { waterEffect = game.Content.Load<Effect>("WaterEffect"); cModel.SetModelEffect(waterEffect, false); waterEffect.Parameters["viewportWidth"].SetValue( game.GraphicsDevice.Viewport.Width); waterEffect.Parameters["viewportHeight"].SetValue( game.GraphicsDevice.Viewport.Height); waterEffect.Parameters["WaterNormalMap"].SetValue( game.Content.Load<Texture2D>("water_normal")); ((WaterUnit)unit).waterEffect = waterEffect; }
public bool collideWith(Unit otherUnit) { //return (BoundingSphere.Contains(otherUnit.BoundingSphere) != ContainmentType.Disjoint); return (BoundingBox.Contains(otherUnit.BoundingBox) != ContainmentType.Disjoint); }
public bool checkCollisionWithTrees(Unit unit,int offset) { foreach (CDrawableComponent comp in trees) if (Math.Abs(comp.unit.position.X - unit.position.X) < offset && Math.Abs(comp.unit.position.Z - unit.position.Z) < offset) return true; return false; //return (monsters.checkCollisionWithBullet(unit) || firstAidManger.checkCollisionWithBullet(unit)); }
public bool checkCollisionWithBullet(Unit unit) { return (monsters.checkCollisionWithBullet(unit) || firstAidManger.checkCollisionWithBullet(unit)); }
public Tree(MyGame game, Model model, Unit unit, Texture2D Texture) : base(game,unit,new CModel(game, model)) { }
public Bullet(Game1 game, Model model, Unit unit) : base(game, unit,new CModel(game, model)) { }
//methods for units to use public Unit GetUnitInRange(Unit checkingUnit, double range) { Unit closestUnit = new Unit(); double closestRange = -1; foreach (Unit currentUnit in units) { if ((currentUnit != checkingUnit) && (currentUnit.State != "dead")) { double currentRange = checkingUnit.Location.DistanceTo(currentUnit.Location); if (currentRange < range) { if ((closestRange == -1) || (currentRange < closestRange)) { closestRange = currentRange; closestUnit = currentUnit; } } } } if (closestRange == -1) { return null; } else { return closestUnit; } }
public FirstAid(Game1 game, Model model, Unit unit) : base(game, unit, new CModel(game,model)) { }
public void Shoot(Unit target) { target.Kill(); report.KillUnit(time, target.ID); Console.WriteLine("unit killed!"); }
public Monster(MyGame game, CModel model, Unit unit) : base(game, unit, model) { monsterModel = ((MonsterModel)cModel); monsterUnit = ((MonsterUnit)unit); }
public SkyCube(MyGame game, Model model, Unit unit, TextureCube Texture) : base(game,unit,new SkyCubeModel(game, model,Texture)) { }
//adds units public void AddType(Unit unit) { types.Add(unit); }
//methods for units to add to the battlereport public void AddMoveOrder(Unit unit, Point destination) { report.MoveOrder(time, unit.ID, Convert.ToInt32(destination.X), Convert.ToInt32(destination.X)); }
private void addFirstAidKit() { float y = Constants.TERRAIN_HEIGHT; float x = 0, z = 0; while (y > .7 * Constants.TERRAIN_HEIGHT) { x = (float)(rnd.NextDouble() * 4700 - Constants.FIELD_MAX_X_Z); z = (float)(rnd.NextDouble() * 4700 - Constants.FIELD_MAX_X_Z); y = myGame.GetHeightAtPosition(x, z); } Vector3 pos = new Vector3(x, y + 30, z); Unit unit = new Unit(myGame, pos, Vector3.Zero, Constants.MEDKIT_SCALE); FirstAid firstAid = new FirstAid(myGame, myGame.Content.Load<Model>(@"model/First Aid Kit2"), unit); firstAidKits.Add(firstAid); }
public Sky(Game1 game, Model model, Unit unit, TextureCube Texture) : base(game,unit,new SkyModel(game, model,Texture)) { }