示例#1
0
        private void HowToPlay_Load(object sender, EventArgs e)
        {
            int counter     = 0;
            int tileSize    = 32;
            int labelLength = 132;
            Dictionary <TileTypes, string> descriptions = new Dictionary <TileTypes, string>();

            descriptions.Add(TileTypes.Grass, "Grass, You can walk on it");
            descriptions.Add(TileTypes.Tree, "Trees, Cut these down with an axe");
            descriptions.Add(TileTypes.Sticks, "Sticks, Collect these to craft tools");
            descriptions.Add(TileTypes.Rocks, "Rocks, Collect these to craft tools");
            descriptions.Add(TileTypes.Bush, "Bush, Collect berries for food from bushes");
            descriptions.Add(TileTypes.Water, "Water, Build a bridge to cross it");
            descriptions.Add(TileTypes.Bridge, "Bridges, Create these with a log");
            descriptions.Add(TileTypes.Passive, "Cows, Kill these with a sword for food");
            descriptions.Add(TileTypes.Hostile, "Tigers, Don't come to close, they will eat you");
            descriptions.Add(TileTypes.Treasure, "Treasure, Dig up the relic with a spade");
            descriptions.Add(TileTypes.Chest, "Chest, Contains a relic");
            descriptions.Add(TileTypes.Home, "Home Village, Your humble abode");
            foreach (TileTypes tileType in Enum.GetValues(typeof(TileTypes)))
            {
                if (tileType == TileTypes.Cave || tileType == TileTypes.Stone || tileType == TileTypes.Ravine || tileType == TileTypes.Player)//Ignore removed types and player tiles
                {
                    continue;
                }
                Tile  tileRef = TileOperators.extractControlFromType(tileType, Zone.Surface);
                Image image   = tileRef.Image;
                Utils.nonAntialiasingPictureBox tileIcon = new Utils.nonAntialiasingPictureBox();
                tileIcon.Image     = image;
                tileIcon.BackColor = Color.Transparent;
                tileIcon.SizeMode  = PictureBoxSizeMode.Zoom;
                tileIcon.Size      = new Size(tileSize, tileSize);
                tileIcon.Location  = new Point((tileSize + labelLength) * (counter / 5) + 10, (tileSize + 5) * (counter % 5) + 300);
                this.Controls.Add(tileIcon);
                tileIcon.BringToFront();
                tileIcon.Show();

                Label lblDescription = new Label();

                lblDescription.Text      = descriptions[tileType];
                lblDescription.BackColor = Color.Transparent;
                lblDescription.ForeColor = Color.White;
                lblDescription.Size      = new Size(labelLength, tileSize);
                lblDescription.TextAlign = ContentAlignment.MiddleCenter;
                lblDescription.Font      = new Font("Times new Roman", 9, FontStyle.Italic);
                lblDescription.Location  = new Point((tileSize + labelLength) * (counter / 5) + 10 + tileSize, (tileSize + 5) * (counter % 5) + 300);
                this.Controls.Add(lblDescription);
                lblDescription.BringToFront();
                lblDescription.Show();


                counter++;
            }
        }
示例#2
0
            //Builds the surface
            public Tile[,] buildLevelSurface(LevelContainerClass.levelInfo levelInformation)
            {
                //Create array to add tiles to
                Tile[,] controlArray;
                controlArray = new Tile[levelInformation.width, levelInformation.height];
                int caveIndex = 0;                                                                                                           // No longer used
                int tileSize  = Math.Min(Program.formWidth, Program.formHeight) / Math.Max(levelInformation.width, levelInformation.height); //Set the tiles to be the size of the smallest dimension of the space it is in divided by the longest side of level

                //Loop every tile
                for (int x = 0; x < levelInformation.width; x++)
                {
                    for (int y = 0; y < levelInformation.height; y++)
                    {
                        //Handle player seperately
                        if (levelInformation.surface[x, y] == TileTypes.Player)
                        {
                            //Assume player is on grass
                            controlArray[x, y] = TileOperators.extractControlFromType(TileTypes.Grass, Zone.Surface);

                            //Create the player
                            player = new Player(TileTypes.Grass);
                            player.hiddenControl = controlArray[x, y];
                            player.BringToFront();

                            //Sets the playersdetails
                            TileOperators.setTileDetails(player, tileSize, 0, 0);
                            //Override the players location
                            player.Location = new System.Drawing.Point(0, 0);
                        }
                        else
                        {
                            //Extract the tile at this location
                            controlArray[x, y] = TileOperators.extractControlFromType(levelInformation.surface[x, y], Zone.Surface);
                            //Set cave ID - Not used
                            if (levelInformation.surface[x, y] == TileTypes.Cave)
                            {
                                Cave cave = (Cave)controlArray[x, y];
                                cave.SetId(levelInformation.surfaceCaveId[caveIndex]);
                                caveIndex++;
                            }
                        }
                        //Set details of the tile at current location
                        TileOperators.setTileDetails(controlArray[x, y], tileSize, x, y);
                    }
                }
                //Return initialised level
                return(controlArray);
            }
示例#3
0
        public void attackNeighbouringTiles()
        {
            if (base.isInRange())
            {
                levelHandler.requestPlayersBrutallyPainfulDeath();
                return;
            }
            Point curLoc = TileOperators.getGridPosition(this);

            for (int i = -1; i <= 2; i += 2)
            {
                if (curLoc.Y + i < 0 || curLoc.Y + i >= levelHandler.currentLevelSurfaceArray.GetLength(0))
                {
                    continue;
                }
                Tile neighbour = levelHandler.currentLevelSurfaceArray[curLoc.Y + i, curLoc.X];
                if (neighbour.GetType().ToString() == (TileOperators.extractControlFromType(TileTypes.Passive, Zone.Surface)).GetType().ToString())
                {
                    PassiveAnimal animal = (PassiveAnimal)neighbour;
                    animal.animalAttack();
                }
            }
            for (int i = -1; i <= 2; i += 2)
            {
                if (curLoc.X + i < 0 || curLoc.X + i >= levelHandler.currentLevelSurfaceArray.GetLength(1))
                {
                    continue;
                }
                Tile neighbour = levelHandler.currentLevelSurfaceArray[curLoc.Y, curLoc.X + i];
                if (neighbour.GetType().ToString() == (TileOperators.extractControlFromType(TileTypes.Passive, Zone.Surface)).GetType().ToString())
                {
                    PassiveAnimal animal = (PassiveAnimal)neighbour;
                    animal.animalAttack();
                }
            }
        }
示例#4
0
        //Checks if the player has meet the requirements for the given objective
        public static bool meetsRequirements(ObjectiveTypes objective)
        {
            int countRequired = getObjectiveOccurances(levelHandler.objectives, objective);

            if (countRequired == 0)
            {
                return(true);
            }
            switch (objective)
            {
            case ObjectiveTypes.FindFood:
                for (int i = 0; i <= countRequired; i++)
                {
                    if (levelHandler.player.HasItem(ItemTypes.Meat, i) &&
                        levelHandler.player.HasItem(ItemTypes.Berries, countRequired - i))
                    {
                        return(true);
                    }
                }
                return(false);

            case ObjectiveTypes.ReturnHome:     //Shouldn't be handled by this, should be handled by the act of entering the village, as it cannot be done without all other objectives being complete
                if (levelHandler.player.hiddenControl.GetType().ToString() == TileOperators.extractControlFromType(TileTypes.Home, Zone.Surface).GetType().ToString())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ObjectiveTypes.CollectItem:
                Dictionary <ItemTypes, int> countPerItem = new Dictionary <ItemTypes, int>();
                foreach (ItemTypes itemType in levelHandler.itemsToCollect)
                {
                    if (countPerItem.ContainsKey(itemType))
                    {
                        countPerItem[itemType]++;
                    }
                    else
                    {
                        countPerItem.Add(itemType, 1);
                    }
                }

                foreach (ItemTypes itemType in Enum.GetValues(typeof(ItemTypes)))
                {
                    //Check if the item has an entry in the dictionary
                    int val;
                    if (!countPerItem.TryGetValue(itemType, out val))
                    {
                        continue;
                    }
                    if (!levelHandler.player.HasItem(itemType, val))
                    {
                        return(false);
                    }
                }
                return(true);

            case ObjectiveTypes.ObtainRelic:
                if (levelHandler.player.HasItem(ItemTypes.Relic, countRequired))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(false);
            }
        }