Beispiel #1
0
 public void drop()
 {
     if (Support.random.Next(0, 10) < 2)
     {
         AmmoItem a = new AmmoItem(this.Position);
         Game.Instance.ammoList.Add(a);
         Game.Instance.World.AddChild(a);
     }
 }
Beispiel #2
0
        public void initGame()
        {
            cameraHeight = (float)Convert.ToDouble(Support.GameParameters["StartingCameraHeight"]);

            //set view close to the scene
            this.Camera2D.SetViewFromHeightAndCenter(cameraHeight, Sce.PlayStation.HighLevel.GameEngine2D.Base.Math._00);



            //add all sprites loaded from the map
            foreach (SpriteList sl in MapManager.Instance.currentMap.spriteList)
            {
                Background.AddChild(sl);
            }

            //load the fire texture for the bullet
            Bullet.fireTexture = new Texture2D("/Application/data/tiles/fire.png", false);

            //texture for the points marker
            pointMarker.texture = new Texture2D("/Application/data/points100.png", false);

            //texture for the ammo marker
            ammoMarker.texture = new Texture2D("/Application/data/plusammo.png", false);

            Player.Instance = new Player();
            Foreground.AddChild(Player.Instance);

            //create the list for bullets
            bulletList = new List <Bullet>();

            //create ammo packs
            ammoList = new List <AmmoItem>();
            List <MapTile> list = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);

            //add a specified number of ammo packs
            for (int i = 0; i < AmmoItem.noOfAmmoToGenerate; i++)
            {
                AmmoItem a = new AmmoItem(list[Support.random.Next(0, list.Count - 1)].position);
                ammoList.Add(a);
                World.AddChild(a);
            }

            //create the quad tree
            quadTree = new QuadTree(new Vector2(MapManager.Instance.currentMap.width / 2.0f, MapManager.Instance.currentMap.height / 2.0f), new Vector2(MapManager.Instance.currentMap.width / 2.0f, MapManager.Instance.currentMap.height / 2.0f));

            //create enemies
            var tex = new Texture2D("/Application/data/tiles/enemy_sword2.png", false);

            tex.SetFilter(TextureFilterMode.Disabled);
            tex.SetWrap(TextureWrapMode.ClampToEdge);
            var texture = new TextureInfo(tex, new Vector2i(25, 1));

            //spritelist for the enemies
            enemySpriteList = new SpriteList(texture)
            {
                BlendMode = BlendMode.Normal
            };
            //spriteList.EnableLocalTransform = true;


            enemyList = new List <Enemy>();
            list      = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);

            //generate a given number of enemies
            for (int i = 0; i < BasicEnemy.noOfEnemiesToGenerate; i++)
            {
                Enemy e = new BasicEnemy(list[Support.random.Next(0, list.Count - 1)].position, texture);
                enemyList.Add(e);
                enemySpriteList.AddChild(((BasicEnemy)e).sprite);
                EffectsLayer.AddChild(e);
                quadTree.insert(e);
            }


            Foreground.AddChild(enemySpriteList);

            ui = new UI();
            Interface.AddChild(ui);


            //add an enemy spawner every second
            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(this, (dt) => {
                list = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);
                EnemySpawnPoint esp = new EnemySpawnPoint(list[Support.random.Next(0, list.Count - 1)].position);
                World.AddChild(esp);


                ;
            }, 1.0f, false, -1);
        }
Beispiel #3
0
        /*
         *  checks collisions with AmmoPacks
         * shit method, fix to use a QuadTree instead, otherwise creates a performance hit
         * */
        public static bool checkAmmoPackCollisions(GameEntity ge, List <AmmoItem> list, out AmmoItem ai)
        {
            //temp bounds
            Bounds2 tempBounds1 = new Bounds2(ge.Position + ge.bounds.Min, ge.Position + ge.bounds.Max);



            foreach (AmmoItem a in list)
            {
                //for the ammo pack
                Bounds2 tempBounds2 = new Bounds2(a.Position + a.bounds.Min, a.Position + a.bounds.Max);

                if (tempBounds1.Overlaps(tempBounds2))
                {
                    ai = a;
                    return(true);
                }
            }


            ai = null;
            return(false);
        }