예제 #1
0
        /// <summary>
        /// Handles the Click event of the btnSubmit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            SceneName = txtSceneName.Text;
            TerrainWidth = Convert.ToInt32(numWidth.Value);
            TerrainHeight = Convert.ToInt32(numHeight.Value);

            foreach (Tile.TileType type in Enum.GetValues(typeof(Tile.TileType)))
            {
                if (type.ToString() == dropDefaultTile.SelectedItem.ToString())
                {
                    TileType = type;
                }
            }

            if (SceneName == "")
            {
                lblError.Text = "Scene name must be set";
            }
            else
            {
                btnSubmit.DialogResult = DialogResult.OK;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
예제 #2
0
 public IEnumerator GenerateTiles()
 {
     newGameButton.enabled = false;
     infoText.text = "Memorize board";
     infoText.color = Color.black;
     selectedType = 0;
     for (int i = 0; i < tiles.Length; i++)
     {
         tiles[i].IsVisible = true;
         tiles[i].Type = (Tile.TileType) Random.Range(0, 5);
     }
     yield return new WaitForSeconds(2f);
     infoText.text = "Tap only one type";
     startedGame = true;
     for (int i = 0; i < tiles.Length; i++)
     {
         tiles[i].IsVisible = false;
     }
 }
예제 #3
0
 protected void Update()
 {
     if (Input.GetMouseButtonDown(0) && startedGame)
     {
         RaycastHit hitInfo;
         var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity, clickableLayers))
         {
             var tile = hitInfo.collider.GetComponent<Tile>();
             if (tile != null && tile.Type > 0)
             {
                 tile.IsVisible = !tile.IsVisible;
                 if (selectedType == 0)
                 {
                     selectedType = tile.Type;
                 }
                 else if (tile.Type == selectedType)
                 {
                     StartCoroutine(CheckForFinish());
                 }
                 else
                 {
                     StartCoroutine(Fail());
                 }
             }
         }
     }
 }
예제 #4
0
 public Character(int x, int y, Tile.TileType type) : base(x, y, type)
 {
 }
예제 #5
0
        private Tile Create(Tile.TileType type)
        {
            //This method is used to create objects and also place them on the map.

            random = new Random();
            Tile tempTile   = null;
            int  randomX    = random.Next(1, mapWidth - 1);
            int  randomY    = random.Next(1, mapHeight - 1);
            int  gold       = random.Next(1, 6);
            int  heroHP     = 0;
            char heroSymbol = 'H';

            while ((mapArray[randomX, randomY] is EmptyTile) == false)
            {
                randomX = random.Next(1, mapWidth);
                randomY = random.Next(1, mapHeight);
            }

            switch (type)
            {
            case Tile.TileType.Hero:
                tempTile = new Hero(randomX, randomY, heroHP, heroSymbol);
                break;

            case Tile.TileType.Enemy:

                //Integrate the Gold and Mage classes into your existing GameEngine and Map classes.

                //Your Enemy array in map should now randomize between Goblins, Mages and Leaders.

                int typeEnemy = random.Next(4);

                if (typeEnemy <= 1)
                {
                    tempTile = new Goblin(randomX, randomY);
                }
                else if (typeEnemy <= 2)
                {
                    tempTile = new Mage(randomX, randomY);
                }
                else if (typeEnemy <= 3)
                {
                    tempTile = new Leader(randomX, randomY);
                }
                break;

            case Tile.TileType.Gold:
                tempTile = new Gold(randomX, randomY);
                break;

            case Tile.TileType.Weapon:

                int typeWeapon = random.Next(4);

                if (typeWeapon <= 1)
                {
                    tempTile = new MeleeWeapon(randomX, randomY, 'D', MeleeWeapon.Types.Dagger);
                }
                else if (typeWeapon <= 2)
                {
                    tempTile = new MeleeWeapon(randomX, randomY, 'S', MeleeWeapon.Types.Longsword);
                }
                else if (typeWeapon <= 3)
                {
                    tempTile = new RangedWeapon(randomX, randomY, 'R', RangedWeapon.Types.Rifle);
                }
                else if (typeWeapon <= 4)
                {
                    tempTile = new RangedWeapon(randomX, randomY, 'B', RangedWeapon.Types.Longbow);
                }
                break;

            default:
                break;
            }
            mapArray[randomX, randomY] = tempTile;
            return(tempTile);
        }
예제 #6
0
파일: Item.cs 프로젝트: BDemut/dungeon_game
        //level as in level of the game not of the player
        static public Item Generate(int level, Tile.TileType tileType = Tile.TileType.ROOM)
        {
            int rollType = Game.rng.Next(3);
            int rollName = Game.rng.Next(5);

            int s_price = (Game.rng.Next(level * 3) + 1) * 2 + Game.rng.Next(1);

            if (tileType == Tile.TileType.SPECIAL)
            {
                s_price += 5;
            }

            int b_price = s_price * 5;

            switch (rollType)
            {
            case 0:
                int damage = ((s_price * 3) / 4) - Game.rng.Next(4);
                if (damage > 12)
                {
                    damage = 12;
                }
                if (damage < 1)
                {
                    damage = 1;
                }
                switch (rollName)
                {
                case 0:
                    return(new Sword(damage, b_price, s_price));

                case 1:
                    return(new Sword(damage, b_price, s_price, "Longsword"));

                case 2:
                    return(new Sword(damage, b_price, s_price, "Dagger"));

                case 3:
                    return(new Sword(damage, b_price, s_price, "Saber"));

                case 4:
                    return(new Sword(damage, b_price, s_price, "Broadsword"));
                }
                break;

            case 1:
                int block = (s_price / 2) - Game.rng.Next(4);
                if (block > 8)
                {
                    block = 8;
                }
                if (block < 1)
                {
                    block = 1;
                }
                switch (rollName)
                {
                case 0:
                case 1:
                case 2:
                    return(new Shield(block, b_price, s_price, "Round shield"));

                case 3:
                    return(new Shield(block, b_price, s_price, "Square shield"));

                case 4:
                    return(new Shield(block, b_price, s_price, "Fancy shield"));
                }
                break;

            case 2:
                int power = ((s_price * 3) / 8) - Game.rng.Next(2);
                if (power > 6)
                {
                    power = 6;
                }
                if (power < 1)
                {
                    power = 1;
                }
                switch (rollName)
                {
                case 0:
                    return(new Wand(power, b_price, s_price, "Straight wand"));

                case 1:
                    return(new Wand(power, b_price, s_price, "Crooked wand"));

                case 2:
                    return(new Wand(power, b_price, s_price, "Shiny wand"));

                case 3:
                    return(new Wand(power, b_price, s_price, "Staff wand"));

                case 4:
                    return(new Wand(power, b_price, s_price, "Small wand"));
                }
                break;

            default:
                throw new SystemException("item generator");
            }
            return(new Item()); //should never execute; added it here because visual studio is hissy
        }
        /// <summary>
        /// Grows a seed of a certain tile type, and of a certain seed id (optional)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="seedID"></param>
        /// <param name="percentChance"> This is the chance of any direction. This is overridden by the optional next parameters</param>
        /// <param name="percTop">Overrides the percentChance on the top checks only</param>
        /// <param name="percBottom">Overrides the percentChance on the bottom checks only</param>
        /// <param name="percRight">Overrides the percentChance on the right checks only</param>
        /// <param name="percLeft">Overrides the percentChance on the left checks only</param>
        public void GrowSeeds(Tile.TileType type, string seedID = "all", int percentChance = 35, int percTop = -1, int percBottom = -1, int percRight = -1, int percLeft = -1)
        {
            List <Tile> GrownTiles = new List <Tile>();

            // (columns) Top To Bottom:
            for (int row = 0; row < WorldHeight; row++)
            {
                for (int col = 0; col < WorldWidth; col++)
                {
                    Tile curTile = WorldTiles[row][col];
                    if (curTile.Type == type && checkSeedID(curTile, seedID) && !GrownTiles.Contains(curTile))
                    {
                        GrownTiles.AddRange(scanAndGrowTile(curTile, percentChance, percTop, percBottom, percRight, percLeft));
                        GrownTiles.Add(curTile);
                    }
                }
            }

            // (columns) Bottom to Top:
            for (int row = WorldHeight - 1; row >= 0; row--)
            {
                for (int col = WorldWidth - 1; col >= 0; col--)
                {
                    Tile curTile = WorldTiles[row][col];
                    if (curTile.Type == type && checkSeedID(curTile, seedID) && !GrownTiles.Contains(curTile))
                    {
                        GrownTiles.AddRange(scanAndGrowTile(curTile, percentChance, percTop, percBottom, percRight, percLeft));
                        GrownTiles.Add(curTile);
                    }
                }
            }

            // (rows) Left to Right:
            for (int col = 0; col < WorldWidth; col++)
            {
                for (int row = 0; row < WorldHeight; row++)
                {
                    Tile curTile = WorldTiles[row][col];
                    if (curTile.Type == type && checkSeedID(curTile, seedID) && !GrownTiles.Contains(curTile))
                    {
                        GrownTiles.AddRange(scanAndGrowTile(curTile, percentChance, percTop, percBottom, percRight, percLeft));
                        GrownTiles.Add(curTile);
                    }
                }
            }

            // (rows) Right to Left:
            for (int col = WorldWidth - 1; col >= 0; col--)
            {
                for (int row = WorldHeight - 1; row >= 0; row--)
                {
                    Tile curTile = WorldTiles[row][col];
                    if (curTile.Type == type && checkSeedID(curTile, seedID) && !GrownTiles.Contains(curTile))
                    {
                        GrownTiles.AddRange(scanAndGrowTile(curTile, percentChance, percTop, percBottom, percRight, percLeft));
                        GrownTiles.Add(curTile);
                    }
                }
            }
            GrownTiles.Clear();
            ResetAllShapeableTiles();
            GenerateAllBuildings();
            SetTileDebugText(debugTileMode);
        }
예제 #8
0
 public Map_Tile(Random random, Tile.TileType tileTypeSet, Map exteriorSet) : base(random)
 {
     tileType = tileTypeSet;
     exterior = exteriorSet;
     //GenerateMap(random);
 }
예제 #9
0
        public override void GenerateMap(Random random)
        {
            Tile.TileType[] tileTypes        = new Tile.TileType[] { Tile.TileType.Mountain, Tile.TileType.Plain, Tile.TileType.Forest, Tile.TileType.Dessert, Tile.TileType.Water };
            int             clutter          = random.Next(5, 20);
            int             explorationSites = 1;

            int tileSize   = 16;
            int tileOffset = -tileSize / 2;

            bool tilePlaced = false;

            while (explorationSites-- > 0)
            {
                tilePlaced = false;
                while (!tilePlaced)
                {
                    int x = random.Next(tileOffset, tileSize + tileOffset);
                    int y = random.Next(tileOffset, tileSize + tileOffset);

                    if (!tiles.ContainsKey(TileKey(x, y)))
                    {
                        tilePlaced = true;
                        tiles.Add(TileKey(x, y), new Tile(Tile.TileType.City));
                        tiles[TileKey(x, y)].Interior = new Map_City(random, this);
                    }
                }
            }

            while (clutter-- > 0)
            {
                tilePlaced = false;
                while (!tilePlaced)
                {
                    int x = random.Next(tileOffset, tileSize + tileOffset);
                    int y = random.Next(tileOffset, tileSize + tileOffset);

                    if (!tiles.ContainsKey(TileKey(x, y)))
                    {
                        tilePlaced = true;
                        tiles.Add(TileKey(x, y), new Tile(tileTypes[random.Next(tileTypes.Length)]));
                    }
                }
            }

            for (int y = 0 - 8; y < 16 - 8; y++)
            {
                for (int x = 0 - 8; x < 16 - 8; x++)
                {
                    if (!tiles.ContainsKey(TileKey(x, y)))
                    {
                        tiles.Add(TileKey(x, y), new Tile(tileType));
                    }
                }
            }

            foreach (KeyValuePair <string, Tile> t in tiles)
            {
                t.Value.Exsterior = exterior;
            }

            MoveCamera(0, 0);
        }
예제 #10
0
 public void SetMode_Remove()
 {
     mode = Tile.TileType.Sea;
 }
예제 #11
0
 public void FillWithTile(Rectangle rectangle, Tile.TileType type)
 {
     FillWithTile(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom, type);
 }
예제 #12
0
 public void SetMode_Build()
 {
     mode = Tile.TileType.Grassland;
 }
예제 #13
0
 public Enemy(int x, int y, Tile.TileType type, int damage, int hp) : base(x, y, type)
 {
     setDamage(damage);
     setHp(hp);
     setMaxHp(hp);
 }
예제 #14
0
        public Item(Tile.TileType type, string name, string description, int id, bool smelt, int stackCount, ContentManager content)
        {
            tileType        = type;
            tileName        = name;
            tileDescription = description;
            itemID          = id;
            sValue          = 1;
            stackMaxCount   = stackCount;
            canSmelt        = smelt;
            switch (type)
            {
            case Tile.TileType.BlankTile:
            {
                // texture = content.Load<Texture2D>("")
                break;
            }

            case Tile.TileType.DryTile1:
            {
                texture = content.Load <Texture2D>("TileObjects/DryTile1Item");
                break;
            }

            case Tile.TileType.DryTile2:
            {
                texture = content.Load <Texture2D>("TileObjects/DryTile2Item");
                break;
            }

            case Tile.TileType.DryTile3:
            {
                texture = content.Load <Texture2D>("TileObjects/DryTile3Item");
                break;
            }

            case Tile.TileType.Granite1:
            {
                texture = content.Load <Texture2D>("TileObjects/Granite1Item");
                break;
            }

            case Tile.TileType.Granite2:
            {
                texture = content.Load <Texture2D>("TileObjects/Granite2Item");
                break;
            }

            case Tile.TileType.Granite3:
            {
                texture = content.Load <Texture2D>("TileObjects/Granite3Item");
                break;
            }

            case Tile.TileType.Grass1:
            {
                texture = content.Load <Texture2D>("TileObjects/Grass1Item");
                break;
            }

            case Tile.TileType.Grass2:
            {
                texture = content.Load <Texture2D>("TileObjects/Grass2Item");
                break;
            }

            case Tile.TileType.Grass3:
            {
                texture = content.Load <Texture2D>("TileObjects/Grass3Item");
                break;
            }

            case Tile.TileType.ConstructionBlock:
            {
                texture = content.Load <Texture2D>("TileObjects/ConstructionBlockItem");
                break;
            }

            case Tile.TileType.MarkerBlock:
            {
                texture = content.Load <Texture2D>("TileObjects/MarkerBlockItem");
                break;
            }

            case Tile.TileType.ConstructionTube:
            {
                // texture = content.Load<Texture2D>("TileObject/")
                break;
            }

            case Tile.TileType.ConstructionDrillBit:
            {
                break;
            }

            case Tile.TileType.QuarryBlock:
            {
                texture = content.Load <Texture2D>("TileObjects/QuarryBlockItem");
                break;
            }

            case Tile.TileType.ItemPipeNorth:
            {
                texture = content.Load <Texture2D>("TileObjects/NorthTubeItem");
                break;
            }

            case Tile.TileType.ItemPipeEast:
            {
                texture = content.Load <Texture2D>("TileObjects/EastTubeItem");
                break;
            }

            case Tile.TileType.ItemPipeSouth:
            {
                texture = content.Load <Texture2D>("TileObjects/SouthTubeItem");
                break;
            }

            case Tile.TileType.ItemPipeWest:
            {
                texture = content.Load <Texture2D>("TileObjects/WestTubeItem");
                break;
            }

            case Tile.TileType.StorageCrate:
            {
                texture = content.Load <Texture2D>("TileObjects/StorageCrateItem");
                break;
            }

            case Tile.TileType.RedWire1:
            {
                texture = content.Load <Texture2D>("TileObjects/RedWire2Item");
                break;
            }

            case Tile.TileType.RedWire2:
            {
                texture = content.Load <Texture2D>("TileObjects/RedWire2Item");
                break;
            }

            case Tile.TileType.GreenWire1:
            {
                texture = content.Load <Texture2D>("TileObjects/GreenWire2Item");
                break;
            }

            case Tile.TileType.GreenWire2:
            {
                texture = content.Load <Texture2D>("TileObjects/GreenWire2Item");
                break;
            }

            case Tile.TileType.GoldWire1:
            {
                texture = content.Load <Texture2D>("TileObjects/GoldWire2Item");
                break;
            }

            case Tile.TileType.GoldWire2:
            {
                texture = content.Load <Texture2D>("TileObjects/GoldWire2Item");
                break;
            }
            }
        }
예제 #15
0
    void SetVillages()
    {
        int count = Random.Range(villageCount, villageCount * 2);
        int size = Random.Range(villageSize, villageSize * 2);
        villagePoints = new List<Vector3>();

        Tile.TileType[] possibleTypes = new Tile.TileType[3] { Tile.TileType.Grass, Tile.TileType.Mountain, Tile.TileType.Sand };

        for (int i = 0; i < count; i++)
        {
            villagePoints.Add(GetRandomPosition(possibleTypes));
        }

        grid = BleedGenerator.BleedPoints(grid, villagePoints, size, Color.gray);
    }
        private void SetTileType(int xPos, int zPos, Tile.TileType type)
        {
            Tile curTile = WorldTiles[zPos][xPos];

            curTile.UpdateTileType(type);
        }
예제 #17
0
 public Tuple(Tile.TileType _type, Color _color)
 {
     type = _type;
     color = _color;
 }
예제 #18
0
        private Tile create(Tile.TileType type, int specification)
        {
            int[] spawn_location = getSpawnPosition();

            if (type == Tile.TileType.Hero)
            {
                return(new Hero(spawn_location[1], spawn_location[0], 10));
            }
            else if (type == Tile.TileType.Enemy)
            {
                if (specification == 0)
                {
                    return(new Goblin(spawn_location[1], spawn_location[0]));
                }
                else if (specification == 1)
                {
                    return(new Mage(spawn_location[1], spawn_location[0]));
                }
                else
                {
                    Leader l = new Leader(spawn_location[1], spawn_location[0]);
                    l.setTarget(this.getHero());
                    return(l);
                }
            }
            else if (type == Tile.TileType.Gold)
            {
                return(new Gold(spawn_location[1], spawn_location[0]));
            }
            else if (type == Tile.TileType.Weapon)
            {
                //0 = melee weapon 1 = ranged weapon
                int super_type = rnd.Next(0, 2);
                if (super_type == 0)
                {
                    //2 = dagger 3 = longsword
                    int sub_type = rnd.Next(2, 4);
                    if (sub_type == 2)
                    {
                        return(new MeleeWeapon(MeleeWeapon.Types.Dagger, 'd', spawn_location[1], spawn_location[0]));
                    }
                    else
                    {
                        return(new MeleeWeapon(MeleeWeapon.Types.Longsword, 'l', spawn_location[1], spawn_location[0]));
                    }
                }
                else
                {
                    //2 = longbow 3 = rifle
                    int sub_type = rnd.Next(2, 4);
                    if (sub_type == 2)
                    {
                        return(new RangedWeapon(RangedWeapon.Types.Longbow, 'b', spawn_location[1], spawn_location[0]));
                    }
                    else
                    {
                        return(new RangedWeapon(RangedWeapon.Types.Rifle, 'r', spawn_location[1], spawn_location[0]));
                    }
                }
            }
            else
            {
                return(new EmptyTile(spawn_location[1], spawn_location[0]));
            }
        }