Ejemplo n.º 1
0
    void OnGUI()
    {
        if (GUILayout.Button("创建一个士兵"))
        {
            AVUser.LogInAsync("games", "123").ContinueWith(loginTask=>{
                Debug.Log("login success!");
                user = (AVUser)loginTask.Result;

                AVUser otherUser = null;
                AVUser.Query.GetAsync("55220263e4b07952a95fbf7a").ContinueWith(t=>{
                    otherUser = (AVUser)t.Result;

                    AVObject soldier = new AVObject("Soldier"){
                        {"type", 3},
                        {"lv", 1},
                        {"exp", 50},
                        {"user2", new List<AVUser>(){
                            user,
                            otherUser
                        }}
                    };

                    soldier.SaveAsync().ContinueWith(saveTask =>
                        {
                            Debug.Log("solider created!");
                        });
                    });
            });
        }
    }
Ejemplo n.º 2
0
	public void SetMatch(AVUser user, AVObject villageObject)
	{
		CurMatchUser = user;
		CurMatchVillage = villageObject;

		lbMatchBeliefAll.text = villageObject.Get<int>("BeliefAll").ToString();
		lbMatchUserName.text = user.Username;

		btnFight.gameObject.SetActive(true);
	}
 private async void btn_stepIn_Click(object sender, RoutedEventArgs e)
 {
     if (txb_password.Text.Trim() == txb_password_verify.Text.Trim())
     {
         AVUser user = new AVUser() { Username = txb_username.Text.Trim(), Password = txb_password.Text.Trim() };
         await user.SignUpAsync();
         await AVUser.LogInAsync(txb_username.Text.Trim(), txb_password.Text.Trim());
         NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
     }
 }
Ejemplo n.º 4
0
	public void SetVillageTo(AVUser user, VillageData villageData, List<BuildingData> buildingDataList)
	{
		CurUser = user;
		CurVillageData = villageData;
		CurBuildingDataList = buildingDataList;

		if(user != AVUser.CurrentUser)
			IsPlayerVillage = false;

		BuildingGroupComp.ReloadAllBuildings(buildingDataList);
	}
Ejemplo n.º 5
0
	private void RegisterUser () {
		var user = new AVUser();
		user.Username = "******";
		user.Password = "******";
		user.Email = "*****@*****.**";
		user.SignUpAsync().ContinueWith(t => {
			if (t.IsFaulted) {
				Debug.Log("Register Failed");
			}
			else {
				Debug.Log("Register Succeeded");
			}
		});
	}
Ejemplo n.º 6
0
	// 网络-注册
	public void NetDoRegist(string userName, string password, string email)
	{
		AVUser user = new AVUser();
		user.Username = userName;
		user.Password = password;
		user.Email = email;

		GameManager.Instance.AsyncBeginWait();
		user.SignUpAsync().ContinueWith(t => {
			// TODO 创建玩家的Village
			GameManager.Instance.AsyncBeginWait();

			AVObject obj = new AVObject("Village");
			obj["UserID"] = AVUser.CurrentUser.ObjectId;
			obj["Belief"] = 0;
			obj["BeliefAll"] = 0;
			
			obj.SaveAsync().ContinueWith(t2 => {
				
				// 创建玩家神庙
				BuildingData newBuilding = new BuildingData();
				newBuilding.AVObject = new AVObject("Building");
				newBuilding.UserID = AVUser.CurrentUser.ObjectId;
				newBuilding.Type = EBuildingType.Altar;
				newBuilding.Level = 1;
				newBuilding.SlotID = 4;
				newBuilding.Sibling = 1;

				newBuilding.AVObject.SaveAsync().ContinueWith(t3=>{
					// 进入登录界面
					// TODO 将用户名和密码拷贝过去
					GameManager.Instance.AsyncEndWait(()=>{
						UIManager.Instance.ChangeScreen(EScreen.Login);
					});
				});
			});
		});
	}
Ejemplo n.º 7
0
	// TODO 将测试战斗转换为单机关卡
	public void TestBattleInitial()
	{
		/*
		// 初始化假玩家数据
		PlayerUserData = new AVUser(){ObjectId = "player_user_id", Username = "******"};
		PlayerVillageData = new VillageData(){UserID = "player_user_id", Defence = 0, Power = 0, Trick = 0, Belief = 0};
		PlayerBuildingDataList = new List<BuildingData>();
		PlayerBuildingDataList.AddRange(new BuildingData[]{
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Altar, SlotID = 0, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Church, SlotID = 1, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Lib, SlotID = 2, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Tower, SlotID = 3, Level = 3, Sibling = 1},
		});
		
		// 计算玩家属性
		RecalcAllPlayerProperty();
		*/
		
		// 初始化假敌人数据
		AVUser tempUser = new AVUser(){ObjectId = "enemy_user_id", Username = "******"};
		OtherUserData = new UserData(tempUser);
		OtherVillageData = new VillageData(){UserID = "enemy_user_id", Defence = 0, Power = 0, Trick = 0, Belief = 0};
		OtherBuildingDataList = new List<BuildingData>();
		OtherBuildingDataList.AddRange(new BuildingData[]{
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Altar, SlotID = 0, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Church, SlotID = 1, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Lib, SlotID = 2, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Tower, SlotID = 3, Level = 3, Sibling = 1},
		});
		
		// 计算敌人属性
		RecalcPlayerProperties();
		
		// 初始化敌人场景
		SceneManager.Instance.SwitchScene(ESceneMode.Visit);
	}
Ejemplo n.º 8
0
	public UserData(AVUser avUser)
	{
		AVUser = avUser;
	}
Ejemplo n.º 9
0
 public static Task<bool> AssociateWithAuthData(AVUser user, string snsType, string accessToken, string openId, long expiresIn)
 {
     return AVUser.AssociateWithAuthData(user, snsType, accessToken, openId, expiresIn, CancellationToken.None);
 }
Ejemplo n.º 10
0
		public void SetWriteAccess(AVUser user, bool allowed)
		{
			this.SetWriteAccess(user.ObjectId, allowed);
		}
Ejemplo n.º 11
0
 internal static void SaveCurrentUser(AVUser user)
 {
     AVUser avUser = AVUser.currentUser;
     if (avUser != null)
         Monitor.Enter(avUser.mutex);
     if (user != null)
         Monitor.Enter(user.mutex);
     try
     {
         lock (AVUser.currentUserMutex)
         {
             if (AVUser.currentUser != null && AVUser.currentUser != user)
                 AVUser.currentUser.isCurrentUser = false;
             AVUser.currentUser = user;
             if (AVUser.currentUser == null)
             {
                 AVClient.ApplicationSettings["CurrentUser"] = (object)null;
             }
             else
             {
                 AVUser.currentUser.isCurrentUser = true;
                 IDictionary<string, object> local_1 = AVUser.currentUser.ServerDataToJSONObjectForSerialization();
                 local_1["sessionToken"] = (object)AVUser.currentUser.SessionToken;
                 local_1["objectId"] = (object)AVUser.currentUser.ObjectId;
                 DateTime local_2 = AVUser.currentUser.CreatedAt.Value;
                 local_1["createdAt"] = (object)local_2.ToString(AVClient.dateFormatString);
                 DateTime local_3 = AVUser.currentUser.UpdatedAt.Value;
                 local_1["updatedAt"] = (object)local_3.ToString(AVClient.dateFormatString);
                 AVClient.ApplicationSettings["CurrentUser"] = (object)AVClient.SerializeJsonString(local_1);
             }
             AVUser.currentUserMatchesDisk = true;
         }
     }
     finally
     {
         if (avUser != null)
             Monitor.Exit(avUser.mutex);
         if (user != null)
             Monitor.Exit(user.mutex);
     }
 }
Ejemplo n.º 12
0
 private static void CheckAVUserForSNS(AVUser user)
 {
     if (user.ObjectId == null)
         throw new AVException(AVException.ErrorCode.CloudNotFindUser, "Cloud not find user.", (Exception)null);
     if (user.SessionToken == null)
         throw new AVException(AVException.ErrorCode.SessionMissing, "The user cannot be altered by a client without the session.", (Exception)null);
 }
Ejemplo n.º 13
0
 public static Task<bool> DissociateAuthData(AVUser user, string snsType, CancellationToken cancellationToken)
 {
     AVUser.CheckAVUserForSNS(user);
     IDictionary<string, object> data = AVUser.BuildAuthData(snsType, (string)null, (string)null, 0L);
     return InternalExtensions.OnSuccess<Tuple<HttpStatusCode, IDictionary<string, object>>, bool>(AVClient.RequestAsync("PUT", "/users/" + user.ObjectId, user.SessionToken, data, cancellationToken), (Func<Task<Tuple<HttpStatusCode, IDictionary<string, object>>>, bool>)(t => t.Result.Item1 == HttpStatusCode.OK));
 }
Ejemplo n.º 14
0
 public static Task<bool> DissociateAuthData(AVUser user, string snsType)
 {
     return AVUser.DissociateAuthData(user, snsType, CancellationToken.None);
 }
Ejemplo n.º 15
0
	public void TestBattle()
	{
		// 初始化假玩家数据
		PlayerVillageData = new VillageData(){UserID = "player_user_id", Defence = 0, Power = 0, Trick = 0, Belief = 0};
		PlayerBuildingDataList.AddRange(new BuildingData[]{
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Altar, SlotID = 0, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Church, SlotID = 1, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Lib, SlotID = 2, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "player_user_id", Type = EBuildingType.Tower, SlotID = 3, Level = 3, Sibling = 1},
		});
		
		// 计算玩家属性
		RecalcPlayerProperties();
		
		
		// 初始化假敌人数据
		AVUser tempUser = new AVUser(){ObjectId = "enemy_user_id", Username = "******"};
		OtherUserData = new UserData(tempUser);
		OtherVillageData = new VillageData(){UserID = "enemy_user_id", Defence = 0, Power = 0, Trick = 0, Belief = 0};
		OtherBuildingDataList = new List<BuildingData>();
		OtherBuildingDataList.AddRange(new BuildingData[]{
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Altar, SlotID = 0, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Church, SlotID = 1, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Lib, SlotID = 2, Level = 3, Sibling = 1},
			new BuildingData(){UserID = "enemy_user_id", Type = EBuildingType.Tower, SlotID = 3, Level = 3, Sibling = 1},
		});
		
		// 计算敌人属性
		RecalcPlayerProperties();
		
		// 初始化敌人场景
		SceneManager.Instance.SwitchScene(ESceneMode.Battle);
		
		// 启动战斗UI
		UIManager.Instance.ChangeScreen(EScreen.Fight);
		
		// 开启战斗状态
		SceneManager.Instance.SceneComp_Battle.StartFight();
		// -- 此处强切一次状态
		SceneManager.Instance.SceneComp_Battle.BattleState = EBattleState.BattleOn;
	}
Ejemplo n.º 16
0
		public AVACL(AVUser owner)
		{
			this.SetReadAccess(owner, true);
			this.SetWriteAccess(owner, true);
		}
Ejemplo n.º 17
0
		public bool GetReadAccess(AVUser user)
		{
			return this.GetReadAccess(user.ObjectId);
		}
Ejemplo n.º 18
0
 public DemoContact(AVUser user)
 {
     this.BindingUser = user;
 }
Ejemplo n.º 19
0
 internal static void ClearInMemoryUser()
 {
     lock (AVUser.currentUserMutex)
     {
         AVUser.currentUserMatchesDisk = false;
         AVUser.currentUser = (AVUser)null;
     }
 }