Exemplo n.º 1
0
 void Awake()
 {
     _movingPlatformScript = trap.GetComponent <MovingPlatform>();
     _turretScript         = trap.GetComponent <Turret>();
     _trapDoorScript       = trap.GetComponent <Trapdoor>();
     _audioSource          = GetComponent <AudioSource>();
 }
Exemplo n.º 2
0
 private String ParseFieldChar(Trapdoor trapdoor)
 {
     if (trapdoor.PlacedCounter >= 3)
     {
         return(" ");
     }
     else
     {
         return("~");
     }
 }
Exemplo n.º 3
0
    /// <summary>
    /// Loads things that aren't tiles at their correct positions
    /// </summary>
    /// <param name="positionStringList">The given list of strings by the main method</param>
    protected void LevelPositionLoader(List <string> positionStringList)
    {
        for (int i = 0; i < positionStringList.Count; i++)
        {
            string[] splitArray = positionStringList[i].Split(' ');
            // All the code blocks below check what object needs to be loaded, loads them in, and then assigns the correct values that are in the file to them
            switch (splitArray[0])
            {
            case "PENGUIN":
                Monster penguin = new LittlePenguin(this)
                {
                    StartPosition = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]))
                };
                penguin.Reset();
                monsterList.Add(penguin);
                break;

            case "DUMMY":
                Monster dummy = new Dummy("Assets/Sprites/Enemies/Dummy", this)
                {
                    StartPosition = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]))
                };
                dummy.Reset();
                monsterList.Add(dummy);
                break;

            case "BUNNY":
                Bunny bunny = new Bunny(this)
                {
                    StartPosition = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]))
                };
                bunny.Reset();
                monsterList.Add(bunny);
                break;

            case "SPIKETRAP":
                AutomatedObject spikeTrap = new SpikeTrap("Assets/Sprites/InteractiveObjects/SpikeTrap@2", "spikeTrap", 0, this);
                spikeTrap.Position = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]));
                objectList.Add(spikeTrap);
                break;

            case "HANDLE":
                Handle handle = new Handle("Assets/Sprites/InteractiveObjects/handles@2", "Handle", 0)
                {
                    Position = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]))
                };
                handle.ObjectNumberConnected = int.Parse(splitArray[3]);
                objectList.Add(handle);
                break;

            case "TRAPDOOR":
                Trapdoor trapdoor = new Trapdoor(TileType.DoorTile, "Assets/Sprites/InteractiveObjects/NextLevelCombined@2", "Trapdoor", 0, this)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2])),
                    Objectnumber = int.Parse(splitArray[3])
                };
                objectList.Add(trapdoor);
                break;

            case "DOOR":
                Door doorupperleft = new Door("Assets/Sprites/Tiles/DoorBottomRight@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]) + 50, float.Parse(splitArray[2]) + 50),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door doorupperright = new Door("Assets/Sprites/Tiles/DoorUpperRight@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]) + 50, float.Parse(splitArray[2])),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door doorbottomleft = new Door("Assets/Sprites/Tiles/DoorBottomLeft@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]) + 50),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door doorbottomright = new Door("Assets/Sprites/Tiles/DoorUpperleft@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2])),
                    Objectnumber = int.Parse(splitArray[3])
                };
                levelTileField.Add(doorupperleft, (int)doorupperleft.Position.X / 50, (int)doorupperleft.Position.Y / 50);
                levelTileField.Add(doorupperright, (int)doorupperright.Position.X / 50, (int)doorupperright.Position.Y / 50);
                levelTileField.Add(doorbottomleft, (int)doorbottomleft.Position.X / 50, (int)doorbottomleft.Position.Y / 50);
                levelTileField.Add(doorbottomright, (int)doorbottomright.Position.X / 50, (int)doorbottomright.Position.Y / 50);
                break;

            case "VDOOR":
                Door vdoorupperleft = new Door("Assets/Sprites/Tiles/VerticalDoorUpperLeft@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2])),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door vdoorupperright = new Door("Assets/Sprites/Tiles/VerticalDoorUpperRight@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]) + 50, float.Parse(splitArray[2])),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door vdoormiddleleft = new Door("Assets/Sprites/Tiles/VerticalDoorMiddleLeft@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]) + 50),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door vdoorbottomleft = new Door("Assets/Sprites/Tiles/VerticalDoorBottomLeft@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]), float.Parse(splitArray[2]) + 100),
                    Objectnumber = int.Parse(splitArray[3])
                };
                Door vdoormiddleright = new Door("Assets/Sprites/Tiles/VerticalDoorMiddleRight@2", "Door", 0)
                {
                    Position     = new Vector2(float.Parse(splitArray[1]) + 50, float.Parse(splitArray[2]) + 50),
                    Objectnumber = int.Parse(splitArray[3])
                };
                levelTileField.Add(vdoorupperleft, (int)vdoorupperleft.Position.X / 50, (int)vdoorupperleft.Position.Y / 50);
                levelTileField.Add(vdoorupperright, (int)vdoorupperright.Position.X / 50, (int)vdoorupperright.Position.Y / 50);
                levelTileField.Add(vdoorbottomleft, (int)vdoorbottomleft.Position.X / 50, (int)vdoorbottomleft.Position.Y / 50);
                levelTileField.Add(vdoormiddleright, (int)vdoormiddleright.Position.X / 50, (int)vdoormiddleright.Position.Y / 50);
                levelTileField.Add(vdoormiddleleft, (int)vdoormiddleleft.Position.X / 50, (int)vdoormiddleleft.Position.Y / 50);
                break;

            case "SHIELDMAIDEN":
                ShieldMaidenLoader(splitArray);
                break;

            case "KEY":
                KeyLoader(splitArray);
                break;

            case "LOCK":
                LockLoader(splitArray);
                break;
            }
        }
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     trapDoor = GetComponent <Trapdoor>();
 }
Exemplo n.º 5
0
        public Tile[,] ParseLevelFile(out List <Crate> CrateList, ref Truck Truck, ref Employee Employee)
        {
            Tile[,] tiles;
            CrateList = new List <Crate>();
            OpenFileDialog fileChooser = new OpenFileDialog();

            if (fileChooser.ShowDialog() == DialogResult.OK)
            {
                if (!Path.GetFileName(fileChooser.FileName).Contains("level"))
                {
                    return(null);
                }
                String[] horizontalText = File.ReadAllLines(fileChooser.FileName.ToString());

                int largestHeight = 0;
                int largestWidth  = 0;
                for (int i = 0; i < horizontalText.Length; i++)
                {
                    if (horizontalText[i].Length > largestWidth)
                    {
                        largestWidth = horizontalText[i].Length;
                    }
                    if (horizontalText.Length > largestHeight)
                    {
                        largestHeight = horizontalText.Length;
                    }
                }
                tiles = new Tile[largestWidth, largestHeight];
                for (int y = 0; y < largestHeight; y++)
                {
                    for (int x = 0; x < horizontalText[y].Length; x++)
                    {
                        switch (horizontalText[y][x] + "")
                        {
                        case "#":
                            tiles[x, y] = new Wall();
                            break;

                        case ".":
                            tiles[x, y] = new Field();
                            break;

                        case " ":
                            tiles[x, y] = new Spacer();
                            break;

                        case "@":
                            tiles[x, y] = new Field(Truck);
                            break;

                        case "o":
                            Crate crate = new Crate();
                            CrateList.Add(crate);
                            tiles[x, y] = new Field(crate);
                            break;

                        case "x":
                            tiles[x, y] = new Destination();
                            break;

                        case "~":
                            tiles[x, y] = new Trapdoor();
                            break;

                        case "$":
                            tiles[x, y] = new Field(Employee);

                            break;
                        }
                    }
                }
                return(tiles);
            }
            return(null);
        }
Exemplo n.º 6
0
        public override void Load()
        {
            try
            {
                mapPath = System.IO.File.ReadAllText("launchoptions.txt");
            }
            catch (FileNotFoundException fnfe)
            { }

            // reset lists
            this.gameObjects = new List <GameObject>();
            this.frames      = new List <UI.Frame>();

            //this.Name = "test";

            //this.Background = AssetLoader.LoadTexture("Assets/Textures/backgrounds/wood1.png");

            Trapdoor trapdoor = new Trapdoor();

            this.AddGameObject(trapdoor);

            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));
            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));
            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));



            /*Enemy enemy = new Enemy();
             * enemy.Transform.Position = new Vector2(500, 500);
             * this.AddGameObject(enemy);
             *
             * Enemy enemy2 = new Enemy();
             * enemy2.Transform.Position = new Vector2(800, 200);
             * this.AddGameObject(enemy2);*/

            /*Bat bat = new Bat();
             * bat.Transform.Position = new Vector2(0, 0);*/
            //this.AddGameObject(bat);

            /*Bat bat2 = new Bat();
             * bat2.Transform.Position = new Vector2(2000, 0);*/
            //this.AddGameObject(bat2);

            /*BabyFishDemon fish = new BabyFishDemon();
             * fish.Transform.Position = new Vector2(100, 720);*/
            //this.AddGameObject(fish);

            player = new Player();
            this.AddGameObject(player);



            fadeScreen = new GameObject("fade");
            fadeScreen.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/UI/fade.png");
            fadeScreen.Sprite.Color   = Color.White * 0; // make the screen invisible
            this.AddGameObject(fadeScreen);

            /*upperWall = new GameObject("upperwall");
             * upperWall.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/blocks/stone_block.png");
             * this.AddGameObject(upperWall);*/

            this.inventory  = new Inventory();
            this.statsFrame = new StatsFrame();

            /*TestUIFrame testUIframe = new TestUIFrame();
             * this.AddFrame(testUIframe);*/

            this.AddFrame(inventory);
            this.AddFrame(npcTalkingFrame);
            this.AddFrame(statsFrame);
            this.AddFrame(deathFrame);
            this.AddFrame(pauseFrame);
            this.AddFrame(beatMushroomFrame);

            //weather = new Weather();
            //this.AddGameObject(weather);

            this.LoadMap(false);



            base.Load();
            //enemy.SetInterval(1000);
        }