Esempio n. 1
0
 /// <summary>
 /// Adds a layer to the list
 /// </summary>
 /// <param name="key">Name of the layer</param>
 /// <param name="layer">The layer to be added</param>
 public void SetLayer(string key, Layer layer)
 {
     if (!layers.ContainsKey(key))
     {
         layers.Add(key, layer);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initialises the layers in the level
        /// </summary>
        public void Initialise(ContentManager contentManager)
        {
            // Initialise the ground layer
            if (!ResourceManager.Instance.ContainsTexture(GroundLayerTexture))
            {
                ResourceManager.Instance.Texture(GroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", GroundLayerTexture)));
            }
            groundLayer = new Layer(Width, Height, 0, GroundLayerTexture, GroundLayerValues, 0, 0);
            // Initialise the surGroundlayer
            if (!ResourceManager.Instance.ContainsTexture(SurGroundLayerTexture))
            {
                ResourceManager.Instance.Texture(SurGroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", SurGroundLayerTexture)));
            }
            /*surGroundLayer = new Layer(Width, Height, 0, SurGroundLayerTexture, SurGroundLayerValues, 0, 0);
            // Initialise the foreground layer
            if (!ResourceManager.Instance.ContainsTexture(ForegroundLayerTexture))
            {
                ResourceManager.Instance.Texture(ForegroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", ForegroundLayerTexture)));
            }
            foregroundLayer = new Layer(Width, Height, 0, ForegroundLayerTexture, ForegroundLayerValues, 0, 0);
            // Initialise the collision layer
            if (!ResourceManager.Instance.ContainsTexture(CollisionLayerTexture))
            {
                ResourceManager.Instance.Texture(CollisionLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", CollisionLayerTexture)));
            }*/
            collisionLayer = new Layer(Width, Height, 0, CollisionLayerTexture, CollisionLayerValues, 0, 0);

            // Add all the spawnpoints to the tech data manager
            for (int i = 0; i < NumSpawners; i += 1)
            {
                TDManager.DataList.Add(Spawners[i].PointID, Spawners[i]);
            }

            // Add all the warps to the tech data manager
            for (int i = 0; i < NumWarps; i += 1)
            {
                TDManager.DataList.Add(Warps[i].Name, Warps[i]);
            }

            // Add all the trigger boxes to the tech data manager
            for (int i = 0; i < NumTriggers; i += 1)
            {
                TDManager.TriggerboxList.Add(Triggers[i]);
            }

            // Testing values and printing them to the console

            /*Console.WriteLine("Number of Warp Points: " + NumWarps);
            Console.WriteLine("X: " + Warps[0].Position.X + "\tY: " + Warps[0].Position.Y);
            Console.WriteLine("Width: " + Warps[0].BoundingBox.Width + "\tHeight: " + Warps[0].BoundingBox.Height);
            Console.WriteLine("Image: " + Warps[0].ImageName);
            Console.WriteLine("ImageX: " + Warps[0].ImageBounds.X + "\tImageY: " + Warps[0].ImageBounds.Y);
            Console.WriteLine("ImageWidth: " + Warps[0].ImageBounds.Width + "\tImageHeight: " + Warps[0].ImageBounds.Height);
            */
        }
Esempio n. 3
0
        /// <summary>
        /// Initialises the layers in the level
        /// </summary>
        public void Initialise(ContentManager contentManager)
        {
            // Initialise the background segments
            if (NumberOfBackgroundSegments > 0)
            { backgroundSegments = new Texture2D[NumberOfBackgroundSegments]; }

            for (int i = 0; i < NumberOfBackgroundSegments; i+=1)
            {
                if (!ResourceManager.Instance.ContainsTexture(BackgroundLayerTextures[i]))
                {
                    ResourceManager.Instance.Texture(BackgroundLayerTextures[i], contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", BackgroundLayerTextures[i])));
                }

                backgroundSegments[i] = ResourceManager.Instance.Texture(BackgroundLayerTextures[i]);
            }
            // Initialise the ground layer
            if (!ResourceManager.Instance.ContainsTexture(GroundLayerTexture))
            {
                ResourceManager.Instance.Texture(GroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", GroundLayerTexture)));
            }
            groundLayer = new Layer(Width, Height, 0, GroundLayerTexture, GroundLayerValues, 0, 0);

            if (NumberOfSurgroundSegments > 0)
            { surgroundSegments = new Texture2D[NumberOfSurgroundSegments]; }

            for (int i = 0; i < NumberOfSurgroundSegments; i += 1)
            {
                if (!ResourceManager.Instance.ContainsTexture(SurgroundLayerTextures[i]))
                {
                    ResourceManager.Instance.Texture(SurgroundLayerTextures[i], contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", SurgroundLayerTextures[i])));
                }

                surgroundSegments[i] = ResourceManager.Instance.Texture(SurgroundLayerTextures[i]);
            }
            // Initialise the surGroundlayer
            /*if (!ResourceManager.Instance.ContainsTexture(SurGroundLayerTexture))
            {
                ResourceManager.Instance.Texture(SurGroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", SurGroundLayerTexture)));
            }
            surGroundLayer = new Layer(Width, Height, 0, SurGroundLayerTexture, SurGroundLayerValues, 16, 16);
            // Initialise the foreground layer
            /*if (!ResourceManager.Instance.ContainsTexture(ForegroundLayerTexture))
            {
                ResourceManager.Instance.Texture(ForegroundLayerTexture, contentManager.Load<Texture2D>(System.IO.Path.Combine(@"Tiles\", ForegroundLayerTexture)));
            }
            foregroundLayer = new Layer(Width, Height, 0, ForegroundLayerTexture, ForegroundLayerValues, 0, 0);*/
            // Initialise the collision layer
            collisionLayer = new Layer(Width, Height, 0, CollisionLayerTexture, CollisionLayerValues, 0, 0);

            TDManager.Initialize();

            // Add all the spawnpoints to the tech data manager
            for (int i = 0; i < NumSpawners; i += 1)
            {
                TDManager.DataList.Add(Spawners[i].PointID, Spawners[i]);
            }

            // Add all the warps to the tech data manager
            for (int i = 0; i < NumWarps; i += 1)
            {
                TDManager.DataList.Add(Warps[i].Name, Warps[i]);
            }

            // Add all the trigger boxes to the tech data manager
            for (int i = 0; i < NumTriggers; i += 1)
            {
                TDManager.TriggerboxList.Add(Triggers[i]);
            }

            for (int i = 0; i < NumCheckPoints; i += 1)
            {
                TDManager.DataList.Add(CheckPoints[i].PointID, CheckPoints[i]);
            }

            for (int i = 0; i < NumItems; i += 1)
            {
                TDManager.TriggerboxList.Add(new TriggerBox("spawn", Pickups[i].Name, new Rectangle(0, 0, Width, Height)));
                TDManager.DataList.Add(Pickups[i].Name, new PickUpPoint(Pickups[i].Type, Pickups[i].Name, Pickups[i].Position));
            }
        }