Ejemplo n.º 1
0
        public void Update(TileSet tiles, float deltaTime)
        {
            Cleanup();
            AddNewBullets();
            AddNewParticles();

            foreach (Particle p in particles)
            {
                p.Update(deltaTime);
                if (!p.Alive)
                {
                    toRemoveP.Add(p);
                }
            }

            foreach (Bullet b in bullets)
            {
                b.Update(deltaTime);

                foreach (Tile t in tiles.GetTilesNear((int)b.Position.X, (int)b.Position.Y))
                {
                    if (t.Type == TileType.wall)
                    {
                        if (b is Grenade)
                        {

                            if (t.Rect.Intersects(b.Rect))
                            {
                                if (Math.Abs(b.Rect.Center.Y - t.Rect.Center.Y) >
                                    Math.Abs(b.Rect.Center.X - t.Rect.Center.X))
                                {
                                    if (b.Rect.Top < t.Rect.Bottom ||
                                        b.Rect.Bottom > t.Rect.Top)
                                    {
                                        b.FlipY();
                                    }
                                }
                                else
                                {
                                    if (b.Rect.Left < t.Rect.Right ||
                                        b.Rect.Right > t.Rect.Left)
                                    {
                                        b.FlipX();
                                    }
                                }

                            }
                        }
                        else
                        {
                            if (t.Rect.Intersects(b.Rect))
                            {
                                if (b is Rocket)
                                {
                                    HandleExplosion(b.Position, b);
                                    AddExplosionParticles(b.Position);
                                }
                                Remove(b);
                            }
                        }
                    }
                }

                if (b is Grenade)
                {
                    Grenade g = (Grenade)b;
                    if (g.Exploded)
                    {
                        AddExplosionParticles(g.Position);
                        HandleExplosion(g.Position, g);
                        toRemove.Add(b);

                    }
                }

                if (b is Flame)
                {
                    Flame f = (Flame)b;
                    if(!f.Alive)
                    {
                        toRemove.Add(b);
                    }
                }
            }

            CollisionTest();
        }
Ejemplo n.º 2
0
        public static void Init(GraphicsDeviceManager g, ContentManager c, Game1 g1)
        {
            game = g1;
            map = new TileSet();
            cam = new Camera(g);
            menuManager = new MenuManager(game);
            content = c;

            InitEndgameStruct();
        }
Ejemplo n.º 3
0
        public static void Init(TileSet ts)
        {
            tiles = ts;
            map = new Location[ts.Width, ts.Height];

            for (int x = 0; x < tiles.WidthIndex; x++)
            {
                for (int y = 0; y < tiles.HeightIndex; y++)
                {
                    map[x, y] = Location.unknown;
                }
            }
            initialized = true;
        }