Beispiel #1
0
    //ローカルの全記録をランキングに登録
    public void SaveRankingAll(CallbackVoid callback)
    {
        int cntProc       = 0;
        int cntFinishProc = 0;

        foreach (var recordData in recordDatas)
        {
            cntProc = cntProc + 2;
            SaveRanking(recordData, Save_ranking_item.SAVE_RANKING_HIGH, () => { cntFinishProc++; });
            SaveRanking(recordData, Save_ranking_item.SAVE_RANKING_LOW, () => { cntFinishProc++; });
        }
        StartCoroutine(MonitorSaveProcs());


        return;

        IEnumerator MonitorSaveProcs()
        {
            while (cntProc > cntFinishProc)
            {
                yield return(null);
            }
            callback();
        }
    }
		internal CallbackBinder (Callback callback) {
			this.OnWidgetLoaded			= new CallbackVoid (callback.OnWidgetLoaded);

			this.OnStateChange			= new CallbackOnStateChange (callback.OnStateChange);

			this.OnProgress				= new CallbackOnProgress (callback.OnProgress);
			this.OnLocationChanged		= new CallbackOnLocationChanged (callback.OnLocationChanged);
			this.OnStatusChange			= new CallbackOnStatusChange (callback.OnStatusChange);
			this.OnSecurityChange		= new CallbackOnSecurityChange (callback.OnSecurityChange);

			this.OnKeyDown				= new KeyCallback (callback.OnClientDomKeyDown);
			this.OnKeyUp				= new KeyCallback (callback.OnClientDomKeyUp);
			this.OnKeyPress				= new KeyCallback (callback.OnClientDomKeyPress);

			this.OnMouseDown			= new MouseCallback (callback.OnClientMouseDown);
			this.OnMouseUp				= new MouseCallback (callback.OnClientMouseUp);
			this.OnMouseClick			= new MouseCallback (callback.OnClientMouseClick);
			this.OnMouseDoubleClick		= new MouseCallback (callback.OnClientMouseDoubleClick);
			this.OnMouseOver			= new MouseCallback (callback.OnClientMouseOver);
			this.OnMouseOut				= new MouseCallback (callback.OnClientMouseOut);

			this.OnActivate				= new Callback2 (callback.OnClientActivate);
			this.OnFocus				= new Callback2 (callback.OnClientFocus);
			this.OnBlur					= new Callback2 (callback.OnClientBlur);

			this.OnAlert				= new CallbackPtrPtr (callback.OnAlert);
			this.OnAlertCheck			= new CallbackOnAlertCheck (callback.OnAlertCheck);
			this.OnConfirm 				= new CallbackOnConfirm (callback.OnConfirm);
			this.OnConfirmCheck 		= new CallbackOnConfirmCheck (callback.OnConfirmCheck);
			this.OnConfirmEx 			= new CallbackOnConfirmEx (callback.OnConfirmEx);
			this.OnPrompt 				= new CallbackOnPrompt (callback.OnPrompt);
			this.OnPromptUsernameAndPassword = new CallbackOnPromptUsernameAndPassword (callback.OnPromptUsernameAndPassword);
			this.OnPromptPassword 		= new CallbackOnPromptPassword (callback.OnPromptPassword);
			this.OnSelect 				= new CallbackOnSelect (callback.OnSelect);

			this.OnLoad 				= new CallbackVoid (callback.OnLoad);
			this.OnUnload 				= new CallbackVoid (callback.OnUnload);
			
			this.OnShowContextMenu		= new CallbackOnShowContextMenu (callback.OnShowContextMenu);
			
			this.OnGeneric				= new CallbackWString (callback.OnGeneric);
		}
Beispiel #3
0
    //指定したレコードデータをランキングに登録
    public void SaveRanking(RecordData recordData, Save_ranking_item save_Ranking_Item, CallbackVoid callback)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(rankingClassName);

        query.WhereEqualTo("name", settings.name);                 // プレイヤー名でデータを絞る
        query.WhereEqualTo("gameModeId", recordData.game_mode_id); // 種目でデータを絞る
        query.WhereEqualTo("type", (int)save_Ranking_Item);        // MAX・MINでデータを絞る

        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e == null)
            {     // データの検索が成功したら、
                if (objList.Count == 0)
                { // ハイスコアが未登録の場合
                    NCMBObject cloudObj    = new NCMBObject(rankingClassName);
                    cloudObj["gameModeId"] = recordData.game_mode_id;
                    cloudObj["type"]       = (int)save_Ranking_Item;
                    cloudObj["name"]       = settings.name;



                    switch (save_Ranking_Item)
                    {
                    case Save_ranking_item.SAVE_RANKING_HIGH:
                        cloudObj["distance"] = recordData.max_distance;
                        cloudObj["timeSpan"] = recordData.timespan_maxdistance;
                        break;

                    case Save_ranking_item.SAVE_RANKING_LOW:
                        cloudObj["distance"] = recordData.min_distance;
                        cloudObj["timeSpan"] = recordData.timespan_mindistance;
                        break;

                    default:
                        break;
                    }
                    cloudObj.SaveAsync(); // セーブ
                }
                else
                {                                     // ハイスコアが登録済みの場合
                    NCMBObject cloudObj = objList[0]; // クラウド上のレコードデータを取得
                    float distance      = System.Convert.ToSingle(cloudObj["distance"]);
                    float timeSpan      = System.Convert.ToSingle(cloudObj["timeSpan"]);
                    switch (save_Ranking_Item)
                    {
                    case Save_ranking_item.SAVE_RANKING_HIGH:
                        if (distance < recordData.max_distance || (distance == recordData.max_distance && timeSpan > recordData.timespan_maxdistance))
                        {
                            cloudObj["distance"] = recordData.max_distance;
                            cloudObj["timeSpan"] = recordData.timespan_maxdistance;
                            cloudObj.SaveAsync();
                        }
                        break;

                    case Save_ranking_item.SAVE_RANKING_LOW:
                        if (distance > recordData.min_distance || (distance == recordData.min_distance && timeSpan > recordData.timespan_mindistance))
                        {
                            cloudObj["distance"] = recordData.min_distance;
                            cloudObj["timeSpan"] = recordData.timespan_mindistance;
                            cloudObj.SaveAsync();
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            callback();
        });
    }