Esempio n. 1
0
 public ScoreTests()
 {
     _roomName       = Guid.NewGuid().ToString();
     _joinRoomHelper = new JoinRoomHelper();
     _joinRoomHelper.CreateRoom(name, _roomName);
     _roomHelper = new RoomHelper(name, _roomName);
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        roomHelper = new RoomHelper(null, RoomType.LivingRoom);
        rt         = new List <GameObject> ();
        rt.Add(create());

        current = 0;
        //initializing buttons
        nextButton = GameObject.Find("NextRoomButton").GetComponent <Button> ();
        nextButton.onClick.AddListener(() => HandleNextRoomClick());

        prevButton = GameObject.Find("PrevRoomButton").GetComponent <Button> ();
        prevButton.onClick.AddListener(() => HandlePreviousRoomClick());

        newButton = GameObject.Find("NewRoomButton").GetComponent <Button> ();
        newButton.onClick.AddListener(() => HandleNewRoomClick());

        deleteButton = GameObject.Find("DeleteRoomButton").GetComponent <Button> ();
        deleteButton.onClick.AddListener(() => HandleDeleteRoomClick());

        recolorButton = GameObject.Find("RegenButton").GetComponent <Button> ();
        recolorButton.onClick.AddListener(() => HandleRecolorClick());

        FirstController.getGlobalFirstController().undoButton.onClick.AddListener(() => HandleUndoClick());

        /*GameObject secGameController = (GameObject)GameObject.Instantiate (firstGameControllerPrefab, new Vector3(0,0,7), Quaternion.identity);
         * secGameController.transform.SetParent (this.transform);
         * rooms.Add (secGameController.GetComponent<GameController>());*/
    }
        async private void LoadRooms()
        {
            try
            {
                if (roomList != null)
                {
                    roomAdapter          = new RoomAdapter(this, roomList);
                    ListViewRoom.Adapter = roomAdapter;
                    return;
                }

                ProgressBar.Visibility = Android.Views.ViewStates.Visible;
                Tuple <string, List <RoomModel> > data = await RoomHelper.GetRoomsAsync(this);

                if (!string.IsNullOrEmpty(data.Item1))
                {
                    Toast.MakeText(this, data.Item1, ToastLength.Short).Show();
                    return;
                }
                roomList             = data.Item2;
                roomAdapter          = new RoomAdapter(this, roomList);
                ListViewRoom.Adapter = roomAdapter;
            }
            catch (Exception exc)
            {
            }
            finally
            {
                ProgressBar.Visibility = Android.Views.ViewStates.Gone;
            }
        }
Esempio n. 4
0
        public ActionResult <string> DirtyCommand(string roomId)
        {
            var result = RoomHelper.SetDirtyRoom(roomId).ToString();

            ProjectionHelper.TruncateAndProjectRooms();
            return(result);
        }
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         e.Row.Cells[7].Text = RoomHelper.ConvertQualityToText(e.Row.Cells[7].Text);
     }
 }
Esempio n. 6
0
        internal void Start()
        {
            if (fighters.Count < 1 || mobs.Count < 1)
            {
                throw new Exception("Cannot start combat. 1 Player, 1 NonPlayer required.");
            }

            foreach (var fighter in fighters)
            {
                if (room == null)
                {
                    room = RoomHelper.GetPlayerRoom(fighter.Location);
                }

                fighter.Status = GameStatus.Fighting;
            }

            foreach (var mob in mobs)
            {
                if (room == null)
                {
                    room = RoomHelper.GetPlayerRoom(mob.Location);
                }

                // if at least one mob is aggro, the whole fight is 'aggro' i.e. mob gets first hit each round
                if (mob.Aggro)
                {
                    isAggro = true;
                }

                mob.Status = GameStatus.Fighting;
            }
        }
Esempio n. 7
0
        public override void Execute(Session session, CommandContext context)
        {
            string argContainer = context.Arguments[0];

            // find container
            PlayerItem container = ItemHelper.FindInventoryItem(session.Player, argContainer, true);

            if (container == null)
            {
                session.Write("Can't find container: {0}", argContainer);
                return;
            }

            var room = RoomHelper.GetPlayerRoom(session.Player);

            // toss on floor
            foreach (var item in container.ContainedItems.ToArray())
            {
                container.ContainedItems.Remove(item.Key);
                room.Items.Add(item.Key, item.Value);
            }

            Server.Current.Database.Save(session.Player);
            session.WriteLine("You empty {0}", container.Name);
            room.SendPlayers(string.Format("%d empties %o {0}", container.Name), session.Player, null, session.Player);
        }
Esempio n. 8
0
        public ActionResult <string> OccupyCommand(string roomId, [FromBody] Room room)
        {
            var result = RoomHelper.AddGuestToEmptyRoom(roomId, room).ToString();

            ProjectionHelper.TruncateAndProjectRooms();
            return(result);
        }
Esempio n. 9
0
        public override void Execute(Session session, CommandContext context)
        {
            string argContainer = context.Arguments[0];

            // container in inventory?
            PlayerItem container = ItemHelper.FindInventoryItem(session.Player, argContainer, true);

            if (container == null)
            {
                session.WriteLine("Can't find container: {0}", argContainer);
                return;
            }

            var room = RoomHelper.GetPlayerRoom(session.Player);

            // add items from room, with weight checks
            foreach (var key in room.Items.Keys.ToArray())
            {
                // get item
                var roomItem = Server.Current.Database.Get <PlayerItem>(key);
                if (roomItem != null && session.Player.Weight + roomItem.Weight <= session.Player.MaxWeight)
                {
                    room.Items.Remove(roomItem.Key);
                    container.ContainedItems[roomItem.Key] = roomItem.Name;
                }
            }

            Server.Current.Database.Save(session.Player);
            session.WriteLine("You filled your {0}", container.Name);
            room.SendPlayers(string.Format("%d filled %o {0}.", container.Name), session.Player, null, session.Player);
        }
Esempio n. 10
0
        public ActionResult <string> ChangePriceCommand(string roomId, [FromBody] Room room)
        {
            var result = RoomHelper.SetRoomPrice(roomId, room).ToString();

            ProjectionHelper.TruncateAndProjectRooms();
            return(result);
        }
Esempio n. 11
0
 public void AddRoom()
 {
     foreach (var room in RoomHelper.GetRoomByNumber(RoomNumber))
     {
         LstRooms.Add(room);
         room.LoadScheduler();
     }
 }
Esempio n. 12
0
        public override void Execute(Session session, CommandContext context)
        {
            try
            {
                PlayerItem container;
                PlayerItem putItem      = null;
                bool       itemFound    = false;
                string     argContainer = context.Arguments[1];
                string     argItem      = context.Arguments[0];
                var        room         = RoomHelper.GetPlayerRoom(session.Player.Location);

                // item in inevntory?
                foreach (var key in session.Player.Inventory.Keys)
                {
                    putItem = Server.Current.Database.Get <PlayerItem>(key);
                    if (putItem != null &&
                        putItem.Keywords.Contains(argItem))
                    {
                        itemFound = true;
                        break;
                    }
                }

                if (!itemFound)
                {
                    session.WriteLine("Can't find item: {0}", argItem);
                    return;
                }

                // container in inventory?
                container = ItemHelper.FindInventoryItem(session.Player, argContainer, true);

                // container on floor?
                if (container == null)
                {
                    container = ItemHelper.FindFloorItem(room, argContainer);
                }

                if (container == null)
                {
                    session.WriteLine("Can't find container: {0}", argContainer);
                    return;
                }

                // move item
                session.Player.Inventory.Remove(putItem.Key);
                container.ContainedItems.Add(putItem.Key, putItem.Name);
                Server.Current.Database.Save(session.Player);
                session.WriteLine("You put {0} in {1}", putItem.Name, container.Name);
                return;
            }
            catch
            {
                PrintSyntax(session);
            }

            session.WriteLine("Put what in what?");
        }
Esempio n. 13
0
        private void FlashAllPage()
        {
            RoomHelper.LoadRoomInfoByWhat(thispage, thispage.roomcardgrid, 3, ranktype, rule1, rule2, rule3);
            List <Room> transrooms = RoomHelper.GetTransingRoom();
            List <Room> bookrooms  = RoomHelper.GetBookingRoom();
            string      content    = string.Format("在住房间数:{0},预定房间数:{1}", transrooms.Count(), bookrooms.Count());

            thispage.CustomerSum.Content = content;
        }
Esempio n. 14
0
        public virtual void Unequip(Session session)
        {
            session.Player.Equipped.Remove(WearLocation);
            session.Player.Inventory[Key] = Name;

            session.WriteLine("You remove {0}", Name);
            RoomHelper.GetPlayerRoom(session.Player)
            .SendPlayers(string.Format("%d removes {0}", Name), session.Player, null, session.Player);
        }
        public RoomEntityInstance()
        {
            Tracks = new ListWrapper <TrackDTO>();
            Users  = new ListWrapper <ServerUserModel>();
            TemporaryRoomHelper = new RoomHelper(Users);

            TimeLeftReached   += TimeReachedZero;
            Users.AfterUpdate += UsersOnAfterUpdate;
        }
Esempio n. 16
0
        public override void Execute(Session session, CommandContext context)
        {
            // validate combat
            switch (session.Player.Status)
            {
            case GameStatus.Sleeping:
            case GameStatus.Sitting:
                session.WriteLine("Do you really think it's a good idea to fight while you're sitting or sleeping?");
                return;

            case GameStatus.Fighting:
                session.WriteLine("You're already fighting!");
                return;

            case GameStatus.Incapacitated:
            case GameStatus.MortallyWounded:
                session.WriteLine("You're dying...");
                return;
            }

            if (string.IsNullOrWhiteSpace(context.ArgumentString))
            {
                session.WriteLine("Kill what?");
                return;
            }

            // find mob
            var room = RoomHelper.GetRoom(session.Player.Location);
            var npc  = room.GetNpcs().FirstOrDefault(n => n.Keywords.Contains(context.ArgumentString));

            if (npc == null)
            {
                session.WriteLine("You can't find that here.");
                return;
            }

            if (npc.IsShopkeeper)
            {
                session.WriteLine("You can't fight a shopkeeper.");
                return;
            }

            var combat = new Game.Combat();

            if (npc.Status == GameStatus.Fighting)
            {
                // add player to combat
                Server.Current.CombatHandler.AddToCombat(session.Player, npc.Key);
            }
            else
            {
                // start new combat
                combat.AddFighter(session.Player);
                combat.AddMob(npc);
                Server.Current.CombatHandler.StartFight(combat);
            }
        }
Esempio n. 17
0
    public void AlignRoomToRoomAreaRect(RoomHelper pRoom)
    {
        if (!_initialized)
        {
            InitializeUI();
        }

        pRoom.transform.position   = _roomCenter;
        pRoom.transform.localScale = _roomScale;
    }
Esempio n. 18
0
        public override void Execute(Session session, CommandContext context)
        {
            var room = RoomHelper.GetRoom(session.Player.Location);

            if (room != null)
            {
                room.Title = context.ArgumentString;
                RoomHelper.SaveRoom(room);
                session.WriteLine("Room title changed...");
            }
        }
Esempio n. 19
0
        public override void Execute(Session session, CommandContext context)
        {
            var room = RoomHelper.GetRoom(session.Player.Location);

            if (room != null)
            {
                room.Description = StringHelpers.AutoTruncate(context.ArgumentString);
                RoomHelper.SaveRoom(room);
                session.WriteLine("Room description changed...");
            }
        }
Esempio n. 20
0
        public Pg_RoomInfoViewModel(RoomInfoPage page)
        {
            thispage = page;
            InitPageData();

            thispage.rankrule.SelectionChanged        += rank_change;
            thispage.filterule_row.SelectionChanged   += filter_row_change;
            thispage.filterule_type.SelectionChanged  += filter_type_change;
            thispage.filterule_state.SelectionChanged += filter_state_change;

            RoomHelper.LoadRoomInfoByWhat(thispage, thispage.roomcardgrid, 0, ranktype, rule1, rule2, rule3);
        }
Esempio n. 21
0
 public void ReFlashRoomInfo()
 {
     InitPageData();
     rule1 = "0";
     rule2 = "";
     rule3 = "";
     rule4 = "0";
     thispage.filterule_row.SelectedIndex   = 0;
     thispage.filterule_type.SelectedIndex  = 0;
     thispage.filterule_state.SelectedIndex = 0;
     RoomHelper.LoadRoomInfoByWhat(thispage, thispage.roomcardgrid, 0, ranktype, rule1, rule2, rule3);
 }
Esempio n. 22
0
        public override void Execute(Session session, CommandContext context)
        {
            if (string.IsNullOrWhiteSpace(context.ArgumentString))
            {
                PrintSyntax(session);
                return;
            }

            // confirm room doesn't exist
            // todo: there will inevitably be rooms with similar names, so they'll need to be key'ed different
            var room = RoomHelper.GetRoom(context.ArgumentString);

            if (room != null)
            {
                session.WriteLine(string.Format("Room already exists: {0}", context.ArgumentString));
                return;
            }

            // get player area
            var  playerRoom = RoomHelper.GetRoom(session.Player.Location);
            var  areaKey    = string.Empty;
            Area area       = null;

            if (playerRoom != null)
            {
                areaKey = playerRoom.Area;
                if (!string.IsNullOrEmpty(areaKey))
                {
                    area = RoomHelper.GetArea(areaKey);
                }
            }

            // create room
            room = new Room()
            {
                Key         = context.ArgumentString.ToLower(),
                Title       = context.ArgumentString,
                Description = RoomHelper.GetDefaultRoomDescription(),
                Area        = areaKey,
            };

            // save room
            Server.Current.Database.Save <Room>(room);
            if (area != null)
            {
                area.Rooms.Add(room.Key);
                Server.Current.Database.Save <Area>(area);
            }

            // tell the admin player what the id is, so they can get to it
            session.WriteLine(string.Format("Room created: {0}", context.ArgumentString));
        }
Esempio n. 23
0
        public string Whois()
        {
            var result = new StringBuilder();

            result.AppendLine(string.Format("{0} is a {1} year old, level {2} player.", Forename, Age, Level));
            result.AppendLine(string.Format("{0} is currently in {1}.",
                                            Gender == PlayerGender.Male
                                                ? "He"
                                                : Gender == PlayerGender.Female ? "She" : "It",
                                            RoomHelper.GetPlayerRoom(Location).Title));

            return(result.ToString());
        }
Esempio n. 24
0
    public void RegisterRoom(int pRoomId, RoomHelper pRoom)
    {
        if (_rooms == null)
        {
            _rooms = new Dictionary <int, RoomHelper> ();
        }

        if (pRoom.isStartingRoom)
        {
            _startingRoomId = pRoomId;
        }
        _rooms.Add(pRoomId, pRoom);
    }
Esempio n. 25
0
        public override void Execute(Session session, CommandContext context)
        {
            try
            {
                var room = RoomHelper.GetPlayerRoom(session.Player.Location);

                // dropping gold
                if (context.Arguments.Count == 2 && context.Arguments[1].ToLower() == "coin")
                {
                    int gold = 0;
                    if (int.TryParse(context.Arguments[0], out gold))
                    {
                        if (session.Player.Gold < gold)
                        {
                            session.WriteLine("You don't have that much.");
                            return;
                        }

                        session.Player.Gold -= gold;
                        room.Gold           += gold;
                        session.WriteLine("`YYou drop {0} coin{1}.", gold, gold > 1 ? "s" : string.Empty);
                        room.SendPlayers("%d drops some coins.", session.Player, null, session.Player);
                        Server.Current.Database.Save(session.Player);
                        return;
                    }

                    PrintSyntax(session);
                    return;
                }

                // does player have item?
                PlayerItem item = ItemHelper.FindInventoryItem(session.Player, context.Arguments[0]);
                if (item == null)
                {
                    session.WriteLine("Can't find item: {0}", context.Arguments[0]);
                    return;
                }

                // remove from player inventory
                session.Player.Inventory.Remove(item.Key);
                Server.Current.Database.Save(session.Player);

                room.AddItem(item); // this saves the room
                session.WriteLine("You drop {0}.", item.Name);
                room.SendPlayers("%d drops something.", session.Player, null, session.Player);
            }
            catch
            {
                PrintSyntax(session);
            }
        }
Esempio n. 26
0
        public void TurnGridIntoMaze(IGrid gridToManipulate)
        {
            List <Room> rooms   = gridToManipulate.GetRooms();
            int         rows    = gridToManipulate.GetRows();
            int         columns = gridToManipulate.GetColumns();
            Random      randomDirectionGenerator = new Random();

            foreach (Room room in rooms)
            {
                List <Direction> boundries = RoomHelper.GetBoundriesRoomIsOn(room, rows, columns);

                ValidConnectionDirections?directionToConnect = null;



                if (IsRoomOnNorthBoundry(boundries) && IsRoomOnEastBoundry(boundries))
                {
                    //Don't do anything.
                }
                else if (IsRoomOnNorthBoundry(boundries))
                {
                    directionToConnect = ValidConnectionDirections.EAST;
                }
                else if (IsRoomOnEastBoundry(boundries))
                {
                    directionToConnect = ValidConnectionDirections.NORTH;
                }
                // if the current room is not on a boundry then connect in a random direction
                else
                {
                    int direction = randomDirectionGenerator.Next(0, 2);

                    if (direction == 0)
                    {
                        directionToConnect = ValidConnectionDirections.NORTH;
                    }
                    else if (direction == 1)
                    {
                        directionToConnect = ValidConnectionDirections.EAST;
                    }
                }

                // if there is a direction to connect to
                if (directionToConnect != null)
                {
                    gridToManipulate.Connect(room, (Direction)directionToConnect);
                }
            }
        }
Esempio n. 27
0
        public static void CastTownPortal(Player player, int index)
        {
            player.ManaPoints -= player.Spellbook[index].ManaCost;
            RoomHelper.SetPlayerLocation(player, player.Spellbook[index].Portal.CoordX,
                                         player.Spellbook[index].Portal.CoordY, player.Spellbook[index].Portal.CoordZ);
            const string portalString = "You open a portal and step through it.";

            OutputHelper.Display.StoreUserOutput(
                Settings.FormatAttackSuccessText(),
                Settings.FormatDefaultBackground(),
                portalString);
            IRoom playerRoom = RoomHelper.Rooms[player.PlayerLocation];

            playerRoom.LookRoom();
        }
Esempio n. 28
0
        private void CreateOneRoomNodes(IMap map, HashSet <string> edgeHash, Room room)
        {
            for (var x = 0; x < room.Width; x++)
            {
                for (var y = 0; y < room.Height; y++)
                {
                    var nodeX = x + (room.PositionX * 20);
                    var nodeY = y + (room.PositionY * 20);
                    var node  = new HexNode(nodeX, nodeY);
                    room.Nodes.Add(node);
                    map.AddNode(node);

                    RoomHelper.AddAllNeighborToMap(map, edgeHash, room, node);
                }
            }
        }
Esempio n. 29
0
        public virtual void Equip(Session session)
        {
            // don't equip .None or .Key
            if (WearLocation == Wearlocation.None ||
                WearLocation == Wearlocation.Key ||
                WearLocation == Wearlocation.Container)
            {
                session.WriteLine("You can't equip that.");
                return;
            }

            if (session.Player.Equipped.ContainsKey(WearLocation))
            {
                session.WriteLine("You've already equipped that slot.");
                return;
            }

            // can't equip both hands if either single hand is equipped
            if (WearLocation == Wearlocation.BothHands &&
                (session.Player.Equipped.ContainsKey(Wearlocation.LeftHand) ||
                 session.Player.Equipped.ContainsKey(Wearlocation.RightHand)))
            {
                session.WriteLine("You can't hold a two-handed weapon with any other weapons.");
                return;
            }

            // can't eqiup either hand if both hands is equipped
            if ((WearLocation == Wearlocation.RightHand || WearLocation == Wearlocation.LeftHand) &&
                session.Player.Equipped.ContainsKey(Wearlocation.BothHands))
            {
                session.WriteLine("You're already using both hands.");
                return;
            }

            session.Player.Equipped[WearLocation] = new WearSlot()
            {
                Key  = Key,
                Name = Name
            };

            // remove from inventory
            session.Player.Inventory.Remove(Key);

            session.WriteLine("You don {0}.", Name);
            RoomHelper.GetPlayerRoom(session.Player)
            .SendPlayers(string.Format("%d dons {0}", Name), session.Player, null, session.Player);
        }
Esempio n. 30
0
        public void DieForReal()
        {
            Status    = GameStatus.Sitting;
            HitPoints = 1;

            var deathRoom = RoomHelper.GetPlayerRoom(Location);

            deathRoom.RemovePlayer(this);

            // create corpse
            var corpse      = Server.Current.Database.Get <Template>("corpse");
            var dupedCorpse = Mapper.Map <PlayerItem>(corpse);
            var corpseName  = string.Format("The corpse of {0}", Forename);

            dupedCorpse.AllowedToLoot = Key; // this should be the only place this is used
            dupedCorpse.Name          = corpseName;
            dupedCorpse.Description   = corpseName;
            dupedCorpse.Keywords      = new [] { "corpse", Forename };
            dupedCorpse.WearLocation  = Wearlocation.Corpse;
            Console.WriteLine("NEW CORPSE: {0}", dupedCorpse.Key);
            deathRoom.CorpseQueue[dupedCorpse.Key] = DateTime.Now.AddMilliseconds(Server.CorpseDecayTime);

            // copy player items to corpse
            foreach (var item in Inventory
                     .Select(x => new { Key = x.Key, Value = x.Value })
                     .Union(Equipped.Values.Select(x => new { Key = x.Key, Value = x.Name })
                            .ToArray()))
            {
                dupedCorpse.ContainedItems.Add(item.Key, item.Value);
            }

            // clear inventory/equipped
            Inventory.Clear();
            Equipped.Clear();

            // cache, don't save
            Server.Current.Database.Put(dupedCorpse);
            deathRoom.AddItem(dupedCorpse);

            var room = RoomHelper.GetPlayerRoom(RespawnRoom);

            Location = RespawnRoom;
            room.AddPlayer(this);

            Server.Current.Database.Save(this);
        }