示例#1
0
    // Parsing
    public static RoomData FromObject(JsonData jsonData)
    {
        RoomData roomData = new RoomData();

        int gameID = SessionData.GetInstance().GameID;
        int room_x = (int)jsonData["room_x"];
        int room_y = (int)jsonData["room_y"];
        int room_z = (int)jsonData["room_z"];

        float world_x= jsonData["world_x"].IsInt ? (float)((int)jsonData["world_x"]) : (float)((double)jsonData["world_x"]);
        float world_y= jsonData["world_y"].IsInt ? (float)((int)jsonData["world_y"]) : (float)((double)jsonData["world_y"]);
        float world_z= jsonData["world_z"].IsInt ? (float)((int)jsonData["world_z"]) : (float)((double)jsonData["world_z"]);

        roomData.RoomKey.Set(gameID, room_x, room_y, room_z);
        roomData.WorldPosition.Set(world_x, world_y, world_z);
        roomData.StaticRoomData = StaticRoomData.FromObject(roomData.RoomKey, jsonData["data"]);

        {
            JsonData portalList = jsonData["portals"];

            for (int portalIndex= 0; portalIndex < portalList.Count; portalIndex++)
            {
                JsonData portalObject = portalList[portalIndex];
                RoomPortal portal = RoomPortal.FromObject(portalObject);

                roomData.RoomPortals.Add(portal);
            }
        }

        {
            JsonData mobObjects = jsonData["mobs"];

            roomData.m_mobs = new Dictionary<int, MobData>();

            for (int mobIndex= 0; mobIndex < mobObjects.Count; mobIndex++)
            {
                JsonData mobObject = mobObjects[mobIndex];
                MobData mobData = MobData.FromObject(mobObject);

                roomData.SetMobById(mobData.mob_id, mobData);
            }
        }

        {
            JsonData energyTankObjects = jsonData["energyTanks"];

            roomData.m_energyTanks = new Dictionary<int, EnergyTankData>();

            for (int energyTankIndex = 0; energyTankIndex < energyTankObjects.Count; energyTankIndex++)
            {
                JsonData energyTankObject = energyTankObjects[energyTankIndex];
                EnergyTankData energyTankData = EnergyTankData.FromObject(energyTankObject);

                roomData.SetEnergyTankById(energyTankData.energy_tank_id, energyTankData);
            }
        }

        return roomData;
    }
 public void onUserLeftRoom(RoomData eventObj, String username)
 {
     if (Global.localUsername != username)
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             System.Diagnostics.Debug.WriteLine("someone left");
         });
 }
示例#3
0
 void Awake()
 {
     Player = new PlayerData();
     Room = new RoomData();
     MessageQueue = new Queue<string>();
     AfkChecker = gameObject.GetOrAddComponent<AFKChecker>();
     AfkChecker.OnStatusChanged += OnAway;
 }
示例#4
0
 public Room(RoomData data)
 {
     RoomRect = data.RoomRect;
     isMonsterHouse = data.IsMonsterHouse;
     isShop = data.IsShop;
     EntranceDoorPositions = new Vector2[] { };
     ID = InstanceID++;
     //Debug.Log(this.ToString());
 }
        public void onUserJoinedRoom(RoomData eventObj, String username)
        {
            _page.UpdateStatus(username + " joined " + eventObj.getId());
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _page.UnLockGameboard();
                _page.UpdateStatus("Click on any block to start Game");

            });
        }
    /// <summary>
    /// Create and add a new Room into the repository.
    /// </summary>
    public RoomData Post(RoomData data)
    {
        // Note: repository creates a Room, not RoomData.
        var room = Program.Rooms.Store(Room.createInstance(data.RoomType));

        // set room ID back to the data object
        data.Id = room.Id;

        return data;
    }
示例#7
0
	public void UpdateItemCount (RoomData roomData) {
		SQLiteDB sqliteDB = OpenDatabase ();
		StringBuilder sb = new StringBuilder ();
		sb.Append ("update " + ROOM_DATA_LIST_TABLE + " ");
		sb.Append ("set " + RoomDataField.ITEM_COUNT + " = " + roomData.ItemCount + " ");
		sb.Append ("where " + RoomDataField.ID + " = " + roomData.Id + ";");
		Debug.Log("sql = "+sb.ToString());
		SQLiteQuery sqliteQuery = new SQLiteQuery (sqliteDB, sb.ToString ());
		sqliteQuery.Step ();
		CloseDatabase (sqliteDB, sqliteQuery);
	}
 public void onUserChangeRoomProperty(RoomData roomData, string sender, Dictionary<String, Object> properties)
 {
     _page.showResult("Notification for User Changed Room Propert received");
     _page.showResult(roomData.getId());
     _page.showResult(sender);
     foreach (KeyValuePair<string, object> entry in properties)
     {
         _page.showResult("KEY:" + entry.Key);
         _page.showResult("VALUE:" + entry.Value.ToString());
     }
 }
    IEnumerator LoadRoomRoutine( RoomData data )
    {
        string levelName = m_CurrentWorldName + data.Name;

        AsyncOperation loadLevel = Application.LoadLevelAdditiveAsync( levelName );

        while( loadLevel.isDone == false )
        {
            //Debug.Log( "Loading " + levelName + ": " + Mathf.Round( loadLevel.progress * 100 ) + "%" );
            yield return null;
        }   
    }
	void Init (RoomData roomData) {
		Debug.Log ("roomId = " + roomData.Id);
		mRoomData = roomData;
		mShortMoneyTweenColor = priceLabelObject.GetComponent<TweenColor>();
		string spriteName = "room_item_" + roomData.Id;
		UISpriteData spriteData = roomItemAtlas.GetSprite (spriteName);
		itemSprite.spriteName = "room_item_" + roomData.Id;
		itemSprite.width = spriteData.width;
		itemSprite.height = spriteData.height;
		nameLabel.text = roomData.ItemName;
		priceLabelObject.GetComponent<UILabel>().text  = "price : " + roomData.ItemPrice;
		countLabel.text = "所持数 : " + roomData.ItemCount;
		descriptionLabel.text = roomData.ItemDescription;
	}
    void LoadRoom( string name, int x, int y )
    {
        if( DoesRoomExist( x, y ) == true )
        {
            return;
        }

        RoomData newRoomData = new RoomData();
        newRoomData.Name = name;
        newRoomData.X = x;
        newRoomData.Y = y;

        m_LoadRoomQueue.Enqueue( newRoomData );
    }
 public void onUserJoinedRoom(RoomData roomObj, String username)
 {
     Debug.WriteLine("On User Joined Room "+username);
     if (!GlobalContext.joinedUsers.Contains(username))
     {
         GlobalContext.joinedUsers.Add(username);
     }
     if (!GlobalContext.localUsername.Equals(username))
     {
         GlobalContext.opponentName = username;
     }
     if((GlobalContext.joinedUsers.Count==2)&& GlobalContext.tableProperties["IsPrivateRoom"].Equals("true"))
     {
         Deployment.Current.Dispatcher.BeginInvoke(delegate() { App.g_HomePageListener.StartQuiz(); });
     }
 }
示例#13
0
	void Init (RoomData roomData) {  
		mRoomData = roomData;
		if(mItemSpriteList == null){
			CreateItemSpriteList();
		}
		if (mRoomData.ItemCount == 0) {
			lockObject.SetActive (true);
			return;
		}
		// only first
		UISprite firstItemSprite = mItemSpriteList[0];
		if(!firstItemSprite.enabled){
			SetActiveItem ();
		}
		SetTextData (); 
	}
示例#14
0
    public void ResetCell(RoomData roomData, Pair pos, int ord = 0)
    {
        room = roomData;
        roomID = room.ID;

        int roomLevel = GameManager.Instance.GetRoomLevel(roomID);
        LevelItemData levelItemData = GameManager.Instance.GetLevelItemData(roomData.boardID);

        if (levelItemData == null)
            return;

        int boardID = levelItemData.getItemID(roomLevel);
        ItemData itemData = GameManager.Instance.GetItemData(boardID);

        ResetItem(pos, itemData, ord, false);
    }
示例#15
0
	public List<RoomData> GetRoomDataList () {
		SQLiteDB sqliteDB = OpenDatabase ();
		string sql = "select * from " + ROOM_DATA_LIST_TABLE + ";";
		Debug.Log("sql = "+ sql);
		SQLiteQuery sqliteQuery = new SQLiteQuery (sqliteDB, sql);
		List<RoomData> roomDataList = new List<RoomData> ();
		while (sqliteQuery.Step()) {
			RoomData roomData = new RoomData ();
			roomData.Id = sqliteQuery.GetInteger (RoomDataField.ID);
			roomData.ItemCount = sqliteQuery.GetInteger (RoomDataField.ITEM_COUNT);
			roomData.ItemPrice = sqliteQuery.GetInteger (RoomDataField.PRICE);
			roomData.GenerateSpeed = (float)sqliteQuery.GetDouble (RoomDataField.GENERATE_SPEED);
			roomData.ItemName = sqliteQuery.GetString (RoomDataField.NAME);
			roomData.ItemDescription = sqliteQuery.GetString (RoomDataField.DESCRIPTION);
			roomDataList.Add (roomData);
		}
		CloseDatabase (sqliteDB, sqliteQuery);
		return roomDataList;
	}
    void UpdateRoomQueue()
    {
        if( m_IsLoadingRoom == true )
        {
            return;
        }

        if( m_LoadRoomQueue.Count == 0 )
        {
            return;
        }

        m_CurrentLoadRoomData = m_LoadRoomQueue.Dequeue();
        m_IsLoadingRoom = true;

        //Debug.Log( "Loading new room: " + m_CurrentLoadRoomData.Name + " at " + m_CurrentLoadRoomData.X + ", " + m_CurrentLoadRoomData.Y );

        StartCoroutine( LoadRoomRoutine( m_CurrentLoadRoomData ) );
    }
示例#17
0
    void OnRecieveRoomList(ServerMessage.RoomList message)
    {
        browserItems.ForEach(x => Destroy(x.gameObject));
        browserItems.Clear();

        foreach (var room in message.Rooms)
        {
            // Make instance of view
            var view = UiUtility.AddChild<UiBrowserItem>(Browser.gameObject, BrowserItemPrototype, true);
            view.Text.text = string.Format("{0}'s Game / Players: {1} / Started?: {2}", room.Owner.Name, room.Players.Count, room.GameStarted);
            view.Toggle.group = toggleGroup;
            view.RoomData = room;

            // Add toggle listener
            var temp = room;
            view.Toggle.onValueChanged.AddListener((enabled) =>
            {
                if (enabled)
                {
                    Debug.LogFormat("Select room {0}", view.RoomData.ID);
                    selectedRoom = temp;
                }
            });

            view.gameObject.GetOrAddComponent<DoubleClickHandler>().OnDoubleClick += () =>
            {
                OnJoin();
            };

            browserItems.Add(view);
        }

        // Select first item
        if (browserItems.Count != 0)
            browserItems[0].Toggle.isOn = true;

        NoGames.SetActive(browserItems.Count == 0);
    }
        public void onUserJoinedRoom(RoomData eventObj, String username)
        {
            System.Diagnostics.Debug.WriteLine(username + " joined room");
            /*
            if(!username.Equals(Global.localUsername))
            {
                Global.opponentUsername = username;
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _page.ready.Text = Global.localUsername + " \nvs\n" + Global.opponentUsername;
                });
                        
            }
            else if(!eventObj.getRoomOwner().Equals(Global.localUsername))
            {
                Global.opponentUsername = eventObj.getRoomOwner();
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _page.ready.Text = Global.localUsername + " \nvs\n" + Global.opponentUsername;
                });

            }
            */
        }
 public RoomData method_11(uint uint_0)
 {
     RoomData result;
     if (this.method_12(uint_0) != null)
     {
         result = this.method_12(uint_0);
     }
     else
     {
         RoomData @class = new RoomData();
         @class.FillNull(uint_0);
         result = @class;
     }
     return result;
 }
示例#20
0
 public void onUserJoinedRoom(RoomData eventObj, String username)
 {
     //_game_page.showResult(username + " joined " + eventObj.getId());
 }
示例#21
0
 public void onUserLeftRoom(RoomData eventObj, String username)
 {
 }
示例#22
0
 public void onRoomDestroyed(RoomData eventObj)
 {
 }
示例#23
0
 public void onRoomCreated(RoomData eventObj)
 {
 }
示例#24
0
		public void onUserChangeRoomProperty(RoomData roomData, string sender, Dictionary<string, object> properties, Dictionary<string, string> lockedPropertiesTable){}
 public void onUserLeftRoom(RoomData eventObj, string username)
 {
     Log ("onUserLeftRoom : " + username);
     m_apppwarp.onUserLeft(username);
 }
 public void onUserJoinedRoom(RoomData eventObj, string username)
 {
     Log ("onUserJoinedRoom : " + username);
 }
 public void onUserChangeRoomProperty(RoomData roomData, string sender, Dictionary<String, System.Object> properties)
 {
     Log("Notification for User Changed Room Property received");
     Log(roomData.getId());
     Log(sender);
     foreach (KeyValuePair<String, System.Object> entry in properties)
     {
         Log("KEY:" + entry.Key);
         Log("VALUE:" + entry.Value.ToString());
     }
 }
 public RoomData method_12(uint uint_0)
 {
     RoomData @class = new RoomData();
     RoomData result;
     lock (this.hashtable_0)
     {
         if (this.hashtable_0.ContainsKey(uint_0))
         {
             result = (this.hashtable_0[uint_0] as RoomData);
             return result;
         }
         if (this.method_13(uint_0))
         {
             result = this.GetRoom(uint_0).Class27_0;
             return result;
         }
         DataRow dataRow = null;
         using (DatabaseClient class2 = GoldTree.GetDatabase().GetClient())
         {
             dataRow = class2.ReadDataRow("SELECT * FROM rooms WHERE Id = '" + uint_0 + "' LIMIT 1");
         }
         if (dataRow == null)
         {
             result = null;
             return result;
         }
         @class.method_1(dataRow);
     }
     if (!this.hashtable_0.ContainsKey(uint_0))
     {
         this.hashtable_0.Add(uint_0, @class);
     }
     result = @class;
     return result;
 }
 public RoomData method_17(uint uint_0, DataRow dataRow_0)
 {
     RoomData result;
     if (this.hashtable_0.ContainsKey(uint_0))
     {
         result = (this.hashtable_0[uint_0] as RoomData);
     }
     else
     {
         RoomData @class = new RoomData();
         if (this.method_13(uint_0))
         {
             @class = this.GetRoom(uint_0).Class27_0;
         }
         else
         {
             @class.method_1(dataRow_0);
         }
         if (!this.hashtable_0.ContainsKey(uint_0))
         {
             this.hashtable_0.Add(uint_0, @class);
         }
         result = @class;
     }
     return result;
 }
示例#30
0
		public void onUserJoinedRoom(RoomData eventObj, string username){}