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();
        }
Example #7
0
        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;
        }
Example #8
0
 public bool collideWith(Unit otherUnit)
 {
     //return (BoundingSphere.Contains(otherUnit.BoundingSphere) != ContainmentType.Disjoint);
     return (BoundingBox.Contains(otherUnit.BoundingBox) != ContainmentType.Disjoint);
 }
Example #9
0
 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));
 }
Example #10
0
 public bool checkCollisionWithBullet(Unit unit)
 {
     return (monsters.checkCollisionWithBullet(unit) || firstAidManger.checkCollisionWithBullet(unit));
 }
Example #11
0
 public Tree(MyGame game, Model model, Unit unit, Texture2D Texture)
     : base(game,unit,new CModel(game, model))
 {
 }
Example #12
0
 public Bullet(Game1 game, Model model, Unit unit)
     : base(game, unit,new CModel(game, model))
 {
 }
Example #13
0
 //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))
 {
 }
Example #15
0
 public void Shoot(Unit target)
 {
     target.Kill();
     report.KillUnit(time, target.ID);
     Console.WriteLine("unit killed!");
 }
Example #16
0
 public Monster(MyGame game, CModel model, Unit unit)
     : base(game, unit, model)
 {
     monsterModel = ((MonsterModel)cModel);
     monsterUnit = ((MonsterUnit)unit);
 }
Example #17
0
 public SkyCube(MyGame game, Model model, Unit unit, TextureCube Texture)
     : base(game,unit,new SkyCubeModel(game, model,Texture))
 {
 }
Example #18
0
 //adds units
 public void AddType(Unit unit)
 {
     types.Add(unit);
 }
Example #19
0
 //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);
        }
Example #21
0
 public Sky(Game1 game, Model model, Unit unit, TextureCube Texture)
     : base(game,unit,new SkyModel(game, model,Texture))
 {
 }