Exemplo n.º 1
0
 public static void ClearAll()
 {
     player = null;
     staticEntities.Clear();
     dynamicEntities.Clear();
     matrix = new MatrixSpacePartition<Entity>();
     //foreach (var item in GetBigList())
     //{
     //    rectangleTree.Remove(item);
     //}
     rectangleTree = null;
 }
Exemplo n.º 2
0
        public static void AddDynamicEntity(Entity e)
        {
            dynamicEntities.Add(e);
            if(rectangleTree != null)
                rectangleTree.Add(e);

            //TODO
            //FIxa snyggare kanske
            if (e.GetName() == "Player")
            {
                player = (Player)e;
                camera.SetFollow(player);
            }
        }
Exemplo n.º 3
0
        private void loadMap(Map map)
        {
            foreach (var layer in map.Layers)
            {
                switch (layer.Key)
                {
                    case "Blocks":
                        int x = -1;
                        int y = 0;
                        foreach (var tile in map.Layers["Blocks"].Tiles)
                        {
                            ++x;
                            if (x >= map.Layers["Blocks"].Width)
                            {
                                x = 0;
                                ++y;
                            }

                            switch (tile)
                            {
                                case 1:
                                    Block block = new Block(x * Runtime.CurrentLevel.TileSize, y * Runtime.CurrentLevel.TileSize);
                                    EntityManager.AddStaticEntity(x, y, block);
                                break;
                                case 2:
                                Finish finish = new Finish(x * Runtime.CurrentLevel.TileSize, y * Runtime.CurrentLevel.TileSize);
                                    EntityManager.AddStaticEntity(x, y, finish);
                                break;
                                case 3:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SmallSpike"));
                                break;
                                case 4:
                                   	EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SmallSpikeLeft"));
                                break;
                                case 5:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SmallSpikeRight"));
                                break;
                                case 6:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SmallSpikeTop"));
                                break;
                                case 7:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "Spike"));
                                break;
                                case 8:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SpikeLeft"));
                                break;
                                case 9:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SpikeRight"));
                                break;
                                case 10:
                                    EntityManager.AddStaticEntity(x, y, CreateSpike(x, y, "SpikeTop"));
                                break;
                                case 11:
                                    //TODO
                                    //Player is here for now
                                Player p = new Player(x * Runtime.CurrentLevel.TileSize, y * Runtime.CurrentLevel.TileSize);
                                    EntityManager.AddDynamicEntity(p);

                                    Start start = new Start(x * Runtime.CurrentLevel.TileSize, y * Runtime.CurrentLevel.TileSize);
                                    EntityManager.AddStaticEntity(x, y, start);
                                break;
                            }

                    }
                    break;
                }
            }

            //objects
            foreach (var objectGroup in map.ObjectGroups)
            {
                switch (objectGroup.Key)
                {
                    case "Objects":

                        foreach (var aObject in objectGroup.Value.Objects)
                        {
                            switch (aObject.Name)
                            {
                                case "Start":

                                    //TODO
                                    //new Start();

                                    break;
                                case "Finish":
                                    //TODO
                                    //new Finish();

                                    break;
                                case "MovingPlatform":
                                    //TODO
                                    //new Finish();
                                    MovingPlatform platform = new MovingPlatform(aObject.X, aObject.Y, aObject.Width,
                                        float.Parse(aObject.Properties["startOffset"]),
                                        float.Parse(aObject.Properties["speed"])
                                        );
                                    EntityManager.AddDynamicEntity(platform);
                                    break;
                            }

                        }
                        break;

                }
            }
        }