public ESCPlayer(ESCMaze m) { dice = new ESCDice(); maze = m; currentRoom = m.Entrance; siblingActions = new Dictionary <ESCRoom.RoomDirection, List <ActionType> >(); }
//public List<RoomDirection> DirectionsAvailable() //{ // var dirAvailable = new List<RoomDirection>(); // for (var key in ) //} public void InsertSibling(RoomDirection dir) { ESCRoom newRoom = maze.RequestRoom(); if (newRoom.type != RoomType.Exit) { newRoom.GenerateDirectionPockets(dir); } Siblings[dir] = newRoom; SiblingsAlive++; }
public ESCMaze() { Gems = CalcGems(); roomsPool = new Dictionary <ESCRoom.RoomType, List <ESCRoom> >(); foreach (ESCRoom.RoomType rt in roomsCount.Keys) { if (!roomsPool.ContainsKey(rt)) { roomsPool[rt] = new List <ESCRoom>(); } roomsPool[rt].Add(new ESCRoom(this, rt)); } Entrance = new ESCRoom(this, ESCRoom.RoomType.Entrance); }
public ESCRoom RequestRoom() { var keyList = new List <ESCRoom.RoomType>(roomsPool.Keys); ESCRoom.RoomType key = keyList[ESCUtil.Rand.Next(0, keyList.Count)]; ESCRoom ejectedRoom = roomsPool[key][0]; roomsPool[key].RemoveAt(0); if (roomsPool[key].Count == 0) { roomsPool.Remove(key); } return(ejectedRoom); }
//Pushed Button public void PerformAction(ESCRoom.RoomDirection dir, ActionType action, int playerId) { switch (action) { case ActionType.Discover: currentRoom.InsertSibling(dir); break; case ActionType.Move: currentRoom = currentRoom.Siblings[dir]; break; case ActionType.OpenMinorLock: --maze.Gems; currentRoom.InnerCondition = null; break; case ActionType.OpenNormalLock: maze.Gems -= 2; currentRoom.InnerCondition = null; break; case ActionType.OpenBigLock: maze.Gems -= 3; currentRoom.InnerCondition = null; break; case ActionType.Exit: List <ESCPlayer> playerList = GameObject.FindObjectOfType <ESCEngine>().PlayerList; playerList[playerId].dice.Synthesize(); playerList.Remove(this); break; } roomAction.Clear(); siblingActions.Clear(); }