Example #1
0
    public override void OnPointerClick(PointerEventData data)
    {
        float currentTimeClick = data.clickTime;

        if (Mathf.Abs(currentTimeClick - lastTimeClick) < 0.75f)
        {
            if (_core._dungeon[_dungeonLayer - 1].blockIsPlayed.Count == 0)
            {
                Sprite icon = Resources.Load <Sprite>("Sprites/Icon16x16/rift16x16");
                _core.Notify(icon, "warp not active!");
                return;
            }
            _core._player.currentDungeonFloor = _dungeonLayer;
            _core._player.currentStayDunBlock = _core._dungeon[_core._player.currentDungeonFloor - 1].data.warpBlock;
            bool roomPass = false;
            foreach (DungeonBlock block in _core._dungeon[_core._player.currentDungeonFloor - 1].blockIsPlayed)
            {
                if (block.getNumber() == _core._player.currentStayDunBlock)
                {
                    roomPass = true;
                    break;
                }
            }

            if (roomPass == false)
            {
                DungeonBlock newRoom = new DungeonBlock(_core._player.currentStayDunBlock, 1, 0);
                _core._dungeon[_core._player.currentDungeonFloor - 1].blockIsPlayed.Add(newRoom);
            }
            _core.OpenScene(GAMESTATE.MAP);
            _core.getLandCon()._gatePanel.SetActive(false);
            _core.getMenuCon()._itemDetail.SetActive(false);
        }
        lastTimeClick = currentTimeClick;
    }
Example #2
0
 public Node(DungeonBlock _dungeonBlock)
 {
     this.nodePathCost = 1.0f;
     this.totalCost    = 0.0f;
     this.dungeonBlock = _dungeonBlock;
     this.parent       = null;
 }
        void LoadMap()
        {
            if (_dungeonFloorLoaded != _core._player.currentDungeonFloor || _core._mapSpace.transform.childCount == 0)
            {
                _dungeonFloorLoaded = _core._player.currentDungeonFloor;

                foreach (Transform child in _core._mapSpace.transform)
                {
                    GameObject.Destroy(child.gameObject);
                }

                string   sizeStr = _dungeon.data.size;
                string[] size    = sizeStr.Split(':');
                _dgColumnCount = Calculator.IntParseFast(size[0]);
                _dgRowCount    = Calculator.IntParseFast(size[1]);
                _dunBlockCount = _dgColumnCount * _dgRowCount;

                startBlockX = _dungeon.data.warpBlock % _dgColumnCount;
                startBlockY = _dungeon.data.warpBlock / _dgColumnCount + 1;


                LoadAllMonsterInDungeonFloor();

                _dunBlock = new DungeonBlock[_dunBlockCount];

                for (int row = 0; row < _dgRowCount; row++)
                {
                    for (int col = 0; col < _dgColumnCount; col++)
                    {
                        GameObject block = Instantiate(_mapBlockSlot, new Vector3(0, 0, 0), Quaternion.identity);
                        int        pos   = (row * _dgColumnCount) + col;
                        _dunBlock[pos] = new DungeonBlock(pos, 0, 0);
                        block.name     = pos.ToString();
                        block.transform.SetParent(_core._mapSpace.transform);
                        block.transform.localScale = new Vector2(1, 1);
                        blockSize = block.GetComponent <SpriteRenderer>().bounds.size;
                        block.transform.position = new Vector3(blockSize.x / (float)2 + mapPos.x - mapSize.x / (float)2 + ((float)col * (mapSize.x / (float)19) * (float)2), -blockSize.y / (float)2 + mapPos.y + mapSize.y / (float)2 - ((float)row * (mapSize.y / (float)19) * (float)2), mapPos.z);
                        block.GetComponent <SpriteRenderer>().sprite = getBlockIcon(pos, true);
                        block.transform.Find("LightMask").gameObject.SetActive(false);
                        _dunBlock[pos].obj = block;
                    }
                }

                foreach (DungeonBlock block in _dungeon.blockIsPlayed)
                {
                    _dunBlock[block.getNumber()].AddPlayed(block.getPlayed());
                    _dunBlock[block.getNumber()].AddEscaped(block.getEscaped());

                    setBlockIcon(block.getNumber(), false);

                    _dunBlock[block.getNumber()].obj.GetComponent <SpriteRenderer>().sortingOrder = 1;
                }
            }
            Navigate(_core._player.currentStayDunBlock, true);

            _dunBlock[_core._player.currentStayDunBlock].obj.transform.Find("LightMask").gameObject.SetActive(true);
            ChangePlayerIconMap(_core._player.currentStayDunBlock);
            FocusPosition();
        }
Example #4
0
    public void Use()
    {
        AudioManager.PlayButtonClickSound();

        PlayerPiece player = GameManager.Instance.Player;

        // Focus onto player and animate player.
        BoardScroller.Instance.FocusCameraToPos(
            DungeonManager.Instance.GridPosToWorldPos(player.PosX, player.PosY),
            0.2f,
            Graph.InverseExponential);
        ScaleToAction  scaleUp      = new ScaleToAction(player.transform, Graph.SmoothStep, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.75f, 0.5f);
        ScaleToAction  scaleDownHit = new ScaleToAction(player.transform, Graph.Dipper, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.1f, 0.25f);
        ActionSequence smashSeq     = new ActionSequence(scaleUp, scaleDownHit);

        smashSeq.OnActionFinish += () => {
            // Dramatic shake.
            ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 10, 1.85f, Graph.InverseLinear);
            camShake.SetShakeByDuration(0.6f, 35);
            ActionHandler.RunAction(camShake);

            // Make all things take damage.
            for (int i = 0; i < mArrAffectedPositions.Length; i++)
            {
                DungeonBlock block = DungeonManager.Instance.DungeonBlocks[(int)mArrAffectedPositions[i].x, (int)mArrAffectedPositions[i].y];
                switch (block.State)
                {
                case BlockState.EnemyPiece:
                    if (RepeatPanelControls.NumRepeatsLeft > 0)
                    {
                        block.Enemy.TakeDamage(1 * RepeatPanelControls.NumRepeatsLeft);
                    }
                    else
                    {
                        block.Enemy.TakeDamage(1);
                    }
                    break;

                case BlockState.Obstacle:
                    DungeonManager.Instance.DestroyBlock(block.PosX, block.PosY);
                    break;
                }
            }

            RepeatPanelControls.ClearRepeats();
        };
        ActionHandler.RunAction(smashSeq);

        // Dismiss panel.
        ControlAreaManager.SetCardPanelVisibility(CardType.Smash, false);

        // Organise the cards.
        DeckManager.Instance.ReorganiseCards();
    }
Example #5
0
        void addBlock(String line)
        {
            String[] split = line.Split(',');
            IObject  block;
            //Debug.WriteLine(split[0]);
            float x = ((Int32.Parse(split[1]) - 1) * blockBaseDimension * blockSizeMod) + screenX + (2 * blockBaseDimension * blockSizeMod);
            float y = ((Int32.Parse(split[2]) - 1) * blockBaseDimension * blockSizeMod) + screenY + (2 * blockBaseDimension * blockSizeMod);

            switch (split[0])
            {
            case "bluesandblock":
                block = new BlueSandBlock(sprites["tileset"], new Vector2(x, y));
                break;

            case "dragonblock":
                block = new DragonBlock(sprites["tileset"], new Vector2(x, y));
                break;

            case "dungeonblock":
                block = new DungeonBlock(sprites["tileset"], new Vector2(x, y));
                break;

            case "pushableblock":
                block = new PushableBlock(sprites["tileset"], new Vector2(x, y), split[3]);
                break;

            case "stairsblock":
                block = new StairsBlock(sprites["tileset"], new Vector2(x, y));
                break;

            case "fireblock":
                block = new FireBlock(sprites["fire"], new Vector2(x + 8, y));
                break;

            case "fishblock":
                block = new FishBlock(sprites["tileset"], new Vector2(x, y));
                break;

            case "solidblock":
                Color c = Color.Transparent;
                if (split[3] == "blue")
                {
                    c = Color.Blue;
                }
                block = new SolidBlock(sprites["Backgrounds"], new Vector2(x, y), c);
                break;

            default:
                block = new DungeonBlock(sprites["tileset"], new Vector2(x, y));
                break;
            }
            Blocks.Add(block);
        }
Example #6
0
    private void BuildDeadends(int max, int deadPath)
    {
        for (int i = 0; i < max; i++)
        {
            DungeonBlock deadEndStart = mainPath[r.Next(mainPath.Count - 1)];
            cx = deadEndStart.x;
            cy = deadEndStart.y;
            cz = deadEndStart.z;

            go = true;
            BuildPath(deadPath);
            mainPath[mainPath.Count - 1].MarkDeadEnd();
        }
    }
    private void ChangeCurrentBlock(Vector2 newPosition)
    {
        // Disable useless rooms
        if (currentPosition.x - 1 >= 0 && dungeon[(int)currentPosition.x - 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x - 1, (int)currentPosition.y].Unload(true);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x + 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x + 1, (int)currentPosition.y].Unload(true);
        }
        if (currentPosition.y - 1 >= 0 && dungeon[(int)currentPosition.x, (int)currentPosition.y - 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y - 1].Unload(true);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x, (int)currentPosition.y + 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y + 1].Unload(true);
        }

        currentBlock.OnExit();
        currentBlock = dungeon[(int)newPosition.x, (int)newPosition.y];
        currentBlock.OnEnter(player);
        currentPosition = newPosition;

        // Partialy enable neighboor
        if (currentPosition.x - 1 >= 0 && dungeon[(int)currentPosition.x - 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x - 1, (int)currentPosition.y].Load(false);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x + 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x + 1, (int)currentPosition.y].Load(false);
        }
        if (currentPosition.y - 1 >= 0 && dungeon[(int)currentPosition.x, (int)currentPosition.y - 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y - 1].Load(false);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x, (int)currentPosition.y + 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y + 1].Load(false);
        }
    }
Example #8
0
    private void BuildDungeon(int deadEnds, int maxPath)
    {
        if (numOfRooms == 0)
        {
            DungeonBlock db = new DungeonBlock(DungeonBlock.Direction.start, cx, cy, cz);
            dungeonGrid[cx, cy, cz] = db;
            mainPath.Add(db);
            numOfRooms++;
        }

        //Build the correct path.
        BuildPath(maxPath);
        mainPath[mainPath.Count - 1].MarkEnd();

        foreach (DungeonBlock d in mainPath)
        {
            correctPath.Add(d);
        }

        BuildDeadends(deadEnds, maxPath / 2);

        PrintStats();
        PrintPossibles();
    }
        public void ConfirmBtn()
        {
            this.gameObject.SetActive(false);
            int count = 1;

            foreach (Transform child in trans)
            {
                if (count > 1)
                {
                    GameObject.Destroy(child.gameObject);
                }
                count++;
            }
            if (_core._player.currentStayDunBlock == _core._dungeon[_core._player.currentDungeonFloor - 1].data.bossBlock)
            {
                _core._player.currentDungeonFloor = _core._player.currentDungeonFloor + 1;
                if (_core._player.currentDungeonFloor > _core._dungeon.Length)
                {
                    _core._player.currentDungeonFloor = 1;
                    _core._player.currentStayDunBlock = _core._dungeon[_core._player.currentDungeonFloor - 1].data.warpBlock;
                    _core.OpenScene(GAMESTATE.LAND);
                }
                else
                {
                    DungeonBlock newBlock = new DungeonBlock(_core._dungeon[_core._player.currentDungeonFloor - 1].data.warpBlock,
                                                             1, 0);
                    _core._dungeon[_core._player.currentDungeonFloor - 1].blockIsPlayed.Add(newBlock);
                    _core._player.currentStayDunBlock = _core._dungeon[_core._player.currentDungeonFloor - 1].data.warpBlock;
                    _core.OpenScene(GAMESTATE.MAP);
                }
            }
            else
            {
                _core.OpenScene(GAMESTATE.MAP);
            }
        }
Example #10
0
    void CompilePlayerLog(int SaveNum = 0)
    {
        _player.name        = dataPlayerLog[SaveNum].playerName;
        _player.currentSoul = dataPlayerLog[SaveNum].soul;
        Debug.Log("complie dungeonFloor " + dataPlayerLog[SaveNum].dungeonFloor);
        _player.currentDungeonFloor = dataPlayerLog[SaveNum].dungeonFloor;
        _player.currentStayDunBlock = dataPlayerLog[SaveNum].stayDungeonBlock;
        _player.currentMoney        = dataPlayerLog[SaveNum].money;
        ///------load itemstore------
        if (dataPlayerLog[0].itemStore != "")
        {
            string[] itemStore = dataPlayerLog[0].itemStore.Split(',');
            _itemStore = new List <ItemStore>();
            int rowReal = 0;
            for (int i = 0; i < itemStore.Length; i++)
            {
                string[] itemData = itemStore[i].Split(':');

                foreach (ItemDataSet data in dataItemList)
                {
                    if (Calculator.IntParseFast(itemData[1]) == data.id)
                    {
                        //ItemStore item = new ItemStore();
                        //item.id = _cal.IntParseFast(itemData[0]);
                        //item.itemId = data.id;
                        //item.amount = _cal.IntParseFast(itemData[2]);
                        //item.item = data;
                        //_itemStore.Add(item);
                        break;
                    }
                    rowReal++;
                }
            }
            Debug.Log("foreach row " + rowReal);
            int dataCount = 0;
            int row       = 0;
            int itemCount = 0;
            do
            {
                if (dataCount >= dataItemList.Length)
                {
                    dataCount = 0;
                }
                else if (dataCount < 0)
                {
                    dataCount = dataItemList.Length - 1;
                }
                string[] itemData = itemStore[itemCount].Split(':');
                //Debug.Log(dataItemList[dataCount].id + " == " + _cal.IntParseFast(itemData[1]));
                if (dataItemList[dataCount].id == Calculator.IntParseFast(itemData[1]))
                {
                    //Debug.Log("add item" + row);
                    ItemStore item = new ItemStore();
                    item.id     = Calculator.IntParseFast(itemData[0]);
                    item.itemId = dataItemList[dataCount].id;
                    item.amount = Calculator.IntParseFast(itemData[2]);
                    item.data   = dataItemList[dataCount];
                    _itemStore.Add(item);
                    itemCount++;
                }
                else
                {
                    if (dataItemList[dataCount].id >= Calculator.IntParseFast(itemData[1]))
                    {
                        dataCount--;
                    }
                    else
                    {
                        dataCount++;
                    }
                }
                row++;
            } while (itemCount < itemStore.Length);
            Debug.Log("do while row" + row);
        }

        ///-------end load itemstore---------------

        ///-------load herostore ------------
        _heroStore = new List <Hero>();
        string[] heroStore = dataPlayerLog[0].heroStore.Split(',');
        CreateHeroFromData(heroStore);

        ///-----end load herostore-----
        ///-----load playerAvatar-----
        foreach (Hero hero in _heroStore)
        {
            if (hero.getStoreId() == dataPlayerLog[SaveNum].heroIsPlaying)
            {
                _player._heroIsPlaying = hero;
                getCampCon().LoadCampAvatar();
                Debug.Log("current hp " + _player._heroIsPlaying.getStatus().currentHP);
                break;
            }
        }

        ///-----end load playerAvatar-----
        ///-----load dungeonClear-----
        _dungeon = new Dungeon[dataDungeonList.Length];
        for (int i = 0; i < dataDungeonList.Length; i++)
        {
            Dungeon dun = new Dungeon();
            dun.data    = dataDungeonList[i];
            _dungeon[i] = dun;
        }

        string[] floorData = dataPlayerLog[SaveNum].floorIsPlayed.Split(',');
        for (int i = 0; i < floorData.Length; i++)
        {
            string[] floor = floorData[i].Split('_');
            string[] block = floor[1].Split(':');
            for (int a = 0; a < block.Length; a++)
            {
                string[]     blockData = block[a].Split('-');
                DungeonBlock newBlock  = new DungeonBlock(Calculator.IntParseFast(blockData[0]), Calculator.IntParseFast(blockData[1]), Calculator.IntParseFast(blockData[2]));
                _dungeon[Calculator.IntParseFast(floor[0]) - 1].blockIsPlayed.Add(newBlock);
            }
        }
        ///-----End load dungeonClear-----
        string[] shopList = dataPlayerLog[SaveNum].shopList.Split(',');
        _landShopList = new List <ItemShop>();
        for (int i = 0; i < shopList.Length; i++)
        {
            string[] shopCut = shopList[i].Split(':');
            ItemShop newShop = new ItemShop();
            newShop.id       = Calculator.IntParseFast(shopCut[0]);
            newShop.buyCount = Calculator.IntParseFast(shopCut[1]);
            foreach (ItemDataSet data in dataItemList)
            {
                if (newShop.id == data.id)
                {
                    newShop.item = data;
                    break;
                }
            }
            _landShopList.Add(newShop);
        }
    }
    // Use this for initialization
    void Start()
    {
        float height = 0.64f * 16;
        float width  = 0.64f * 28;

        roomSize = new Vector2(width, height);

        cameraMovementSpeed = new Vector2((float)(width / timeToChangeRoom), (float)(height / timeToChangeRoom));
        Debug.Log(cameraMovementSpeed);

        dungeon = new DungeonBlock[room, room];
        for (int i = 0; i < room; ++i)
        {
            for (int j = 0; j < room; ++j)
            {
                dungeon[i, j] = null;
            }
        }

        Random.InitState((int)System.DateTime.Now.Ticks);

        int rand = (int)Random.Range(0.0f, blockPatern.GetLength(0));

        generator.Generate(room);
        generator.CreateAnnexe(room / 2, Generator.AnnexeType.Tresure);

        /*bool hasShopKeeper = false;
         * for (int i = 0; i < (int)Random.Range(2.0f, room / 2); ++i)
         * {
         *  if(hasShopKeeper)
         *      generator.CreateAnnexe((int)Random.Range(1.0f, room / 2), Generator.AnnexeType.Tresure);
         *  else
         *  {
         *      if((int) Random.Range(0.0f,10.0f) == 5)
         *      {
         *          hasShopKeeper = true;
         *          generator.CreateAnnexe((int)Random.Range(1.0f, room / 2), Generator.AnnexeType.Shopkeeper);
         *      }
         *      else
         *          generator.CreateAnnexe((int)Random.Range(1.0f, room / 2), Generator.AnnexeType.Tresure);
         *  }
         * }*/

        Array2D patern = generator.patern;

        // Generate dungeon
        for (int i = 0; i < patern.GetLength(0); ++i)
        {
            for (int j = 0; j < patern.GetLength(1); ++j)
            {
                rand = (int)Random.Range(0.0f, blockPatern.GetLength(0));
                // Salle Normale
                if (patern[i, j] == 1)
                {
                    dungeon[i, j] = Instantiate(blockPatern[rand]);
                }
                // Spawn
                if (patern[i, j] == 2)
                {
                    dungeon[i, j]   = Instantiate(blockPatern[rand]);
                    currentBlock    = dungeon[i, j];
                    currentPosition = new Vector2(i, j);
                }
                // Boss
                if (patern[i, j] == 3)
                {
                    dungeon[i, j] = Instantiate(blockPatern[rand]);
                }

                if (dungeon[i, j] != null)
                {
                    dungeon[i, j].Init(new Vector2(i, j), floorPatern, wallPatern, platformPatern, background);
                    dungeon[i, j].transform.parent = transform;
                }
            }
        }

        // Set first room
        currentBlock.OnEnter(player);
        // Partialy enable neighboor
        if (currentPosition.x - 1 >= 0 && dungeon[(int)currentPosition.x - 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x - 1, (int)currentPosition.y].Load(false);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x + 1, (int)currentPosition.y] != null)
        {
            dungeon[(int)currentPosition.x + 1, (int)currentPosition.y].Load(false);
        }
        if (currentPosition.y - 1 >= 0 && dungeon[(int)currentPosition.x, (int)currentPosition.y - 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y - 1].Load(false);
        }
        if (currentPosition.x + 1 < room && dungeon[(int)currentPosition.x, (int)currentPosition.y + 1] != null)
        {
            dungeon[(int)currentPosition.x, (int)currentPosition.y + 1].Load(false);
        }
    }
    private void CreateDungeonBlocks()
    {
        if (dungeonBlockGrid != null)
        {
            Debug.LogWarning("dungeonBlockGrid is already created.");
            return;
        }

        dungeonBlockGrid = new DungeonBlock[SizeX, SizeY];
        int numXDiv = (SizeX - 2) / divXSize;
        int numYDiv = (SizeY - 2) / divYSize;

        // Fill up edges with walls.
        for (int edgeX = 0; edgeX < SizeX; edgeX++)
        {
            DungeonBlock curTopRowBlock = new DungeonBlock(TerrainType.Wall, edgeX, 0);
            dungeonBlockGrid[edgeX, 0] = curTopRowBlock;

            for (int edgeY = numYDiv * divYSize + 1; edgeY < SizeY; edgeY++)
            {
                DungeonBlock curBtmRowBlock = new DungeonBlock(TerrainType.Wall, edgeX, edgeY);
                dungeonBlockGrid[edgeX, edgeY] = curBtmRowBlock;
            }
        }
        for (int edgeY = 1; edgeY < SizeY - 1; edgeY++)
        {
            DungeonBlock curLeftColBlock = new DungeonBlock(TerrainType.Wall, 0, edgeY);
            dungeonBlockGrid[0, edgeY] = curLeftColBlock;

            for (int edgeX = numXDiv * divXSize + 1; edgeX < SizeX; edgeX++)
            {
                DungeonBlock curRightColBlock = new DungeonBlock(TerrainType.Wall, edgeX, edgeY);
                dungeonBlockGrid[edgeX, edgeY] = curRightColBlock;
            }
        }

//		RoomPattern[] patterns = Resources.FindObjectsOfTypeAll<RoomPattern>();
//		#if UNITY_EDITOR
//		Debug.Log(patterns.Length);
//		if (patterns.Length == 0)
//			Debug.LogError("There are no Room Patterns found.");
//		#endif

        // Actual floor terrain, generated in batches of 5x5 grids.
        for (int divY = 0; divY < numYDiv; divY++)
        {
            for (int divX = 0; divX < numXDiv; divX++)
            {
                int anchorX = divXSize * divX + 1;
                int anchorY = divYSize * divY + 1;

                RoomPattern curPattern = GetRandPattern();

                for (int y = 0; y < divYSize; y++)
                {
                    for (int x = 0; x < divXSize; x++)
                    {
                        int          indexX = anchorX + x;
                        int          indexY = anchorY + y;
                        DungeonBlock curBlock;

                        TerrainType terrainType = curPattern.BlockTerrainType[y * curPattern.SizeY + x];
                        if (terrainType == TerrainType.Wall)
                        {
                            if ((Random.value - curPattern.MatchPercentage) > 0.0f)
                            {
                                terrainType = TerrainType.Tile;
                            }
                        }

                        curBlock = new DungeonBlock(terrainType, indexX, indexY);
                        dungeonBlockGrid[indexX, indexY] = curBlock;
                    }
                }
            }
        }

        // Set the EndTile.
        mnExitPosX  = divXSize * (numXDiv - 1) + 1;
        mnExitPosY  = divYSize * (numYDiv - 1) + 1;
        mnExitPosX += divXSize / 2;
        mnExitPosY += divYSize / 2;
        dungeonBlockGrid[ExitPosX, ExitPosY] = new DungeonBlock(TerrainType.Stairs, ExitPosX, ExitPosY);
        SetSurroundingTilesToEmpty(ExitPosX, ExitPosY);

        // Set the PlayerSpawnPosition
        mnSpawnPosX = divXSize / 2 + 1;
        mnSpawnPosY = divYSize / 2 + 1;
        dungeonBlockGrid[SpawnPosX, SpawnPosY] = new DungeonBlock(TerrainType.Tile, SpawnPosX, SpawnPosY);
        SetSurroundingTilesToEmpty(SpawnPosX, SpawnPosY);
    }
Example #13
0
    private void BuildPath(int maxPath)
    {
        int pathRooms = 0;

        while (go && pathRooms < maxPath)
        {
            possibleDir.Clear();
            GetPossible();
            if (possibleDir.Count == 0)
            {
                go = false;
            }
            else
            {
                pathRooms++;
                int nextRand = r.Next(possibleDir.Count);

                dungeonGrid[cx, cy, cz].AddExit(possibleDir[nextRand]);

                switch (possibleDir[nextRand])
                {
                case DungeonBlock.Direction.right:
                    cx++;
                    from = DungeonBlock.Direction.left;
                    if (cx > size)
                    {
                        cx = 0;
                    }
                    break;

                case DungeonBlock.Direction.left:
                    cx--;
                    from = DungeonBlock.Direction.right;
                    if (cx < 0)
                    {
                        cx = size;
                    }
                    break;

                case DungeonBlock.Direction.top:
                    cy++;
                    from = DungeonBlock.Direction.bottom;
                    if (cy > size)
                    {
                        cy = 0;
                    }
                    break;

                case DungeonBlock.Direction.bottom:
                    cy--;
                    from = DungeonBlock.Direction.top;
                    if (cy < 0)
                    {
                        cy = size;
                    }
                    break;

                case DungeonBlock.Direction.front:
                    cz++;
                    from = DungeonBlock.Direction.back;
                    if (cz > size)
                    {
                        cz = 0;
                    }
                    break;

                case DungeonBlock.Direction.back:
                    cz--;
                    from = DungeonBlock.Direction.front;
                    if (cz < 0)
                    {
                        cz = size;
                    }
                    break;
                }

                DungeonBlock db = new DungeonBlock(from, cx, cy, cz);
                dungeonGrid[cx, cy, cz] = db;
                mainPath.Add(db);
                numOfRooms++;
            }
        }
    }