IEnumerator TryRegister() { registerPanel.Disable(); var user = new Player() { Username = Username.Text, Password = Password.Text, Email = Email.Text, Level = 1, Health = 100 }; Task signUpTask = user.SignUpAsync(); while (!signUpTask.IsCompleted) { yield return(null); } if (signUpTask.IsFaulted || signUpTask.IsCanceled) { DialogPanel.Show("Think differently", "The username or email adress is already in use. Please choose something even more original."); DialogPanel.Dismissed += new global::DialogPanel.DismissedEventHandler(DialogPanel_Dismissed); } else { LoginPanel.GetComponent <LoginPanel>().Username.Text = user.Username; LoginPanel.GetComponent <LoginPanel>().Password.Text = Password.Text; registerPanel.Hide(); LoginPanel.Show(); } }
void RegisterButton_Click(dfControl control, dfMouseEventArgs mouseEvent) { loginPanel.Hide(); RegisterPanel.Show(); RegisterPanel.GetComponent <RegisterPanel>().Username.Text = Username.Text; RegisterPanel.GetComponent <RegisterPanel>().Password.Text = Password.Text; }
public void Appear() { var tweenAlpha = menuPanel.GetComponent <dfTweenFloat>(); tweenAlpha.StartValue = 0; tweenAlpha.EndValue = 1; tweenAlpha.Play(); menuPanel.IsInteractive = true; GameControl.Instance.Paused = true; }
void GenerateList(string filter) { var children = new List <GameObject>(); foreach (Transform child in PlayerPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); PlayerPanel.Enable(); IEnumerable <Player> filtered = users.Where(t => t.Username.ToLower().Contains(filter.ToLower())) .OrderByDescending(t => pinnedPlayers.Any(u => u.ObjectId.Equals(t.ObjectId))).ThenBy(t => t.Username); foreach (Player player in filtered) { // GameObject ListItem = Instantiate(Resources.Load("List Item")) as GameObject; dfPanel listItem = PlayerPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = PlayerPanel.Width - PlayerPanel.FlowPadding.left - PlayerPanel.FlowPadding.right; listItem.Click += new MouseEventHandler(listItem_Click); ListItemExtras extras = listItem.GetComponent <ListItemExtras>(); extras.Player = player; dfLabel username = listItem.Find("Username Label").GetComponent <dfLabel>(); username.Text = player.Username; username.DisabledColor = new Color32(100, 100, 100, 255); dfSprite onlineSprite = listItem.Find("Online Sprite").GetComponent <dfSprite>(); if (player.IsOnline) { onlineSprite.SpriteName = "OUYA_O 24px"; } else { onlineSprite.SpriteName = "OUYA_A 24px"; } dfButton actionButton = listItem.Find("Action Button").GetComponent <dfButton>(); bool f = pinnedPlayers.Any(t => t.ObjectId.Equals(player.ObjectId)); if (f) { actionButton.Text = "Unpin"; // listItem.BackgroundColor = new Color32(200, 255, 200, 255); listItem.BackgroundColor = new Color32(255, 255, 255, 255); actionButton.Click += new MouseEventHandler(actionButtonUnpin_Click); } else { actionButton.Text = "Pin"; actionButton.Click += new MouseEventHandler(actionButtonPin_Click); } } }
void LobbyButton_Click(dfControl control, dfMouseEventArgs mouseEvent) { if (Slot1.GetComponent <BrainPanelState>().InUse || Slot2.GetComponent <BrainPanelState>().InUse || Slot3.GetComponent <BrainPanelState>().InUse || Slot4.GetComponent <BrainPanelState>().InUse) { Application.LoadLevel("Lobby scene"); } else { _dialog.ShowDialog("You must select at least one brain to use in battle before you can start fighting!" + "\n\nTo select a brain, simply drag it down to an empty slot in the 'Selected brains' panel."); } }
// Use this for initialization void Start() { //BackButton.Click += BackButton_Click; Slot1.Click += Slot1_Click; Slot2.Click += Slot2_Click; Slot3.Click += new MouseEventHandler(Slot3_Click); Slot4.Click += new MouseEventHandler(Slot4_Click); activePanel = Slot1.GetComponent <BrainPanelState>(); countdownLabel = CountdownPanel.transform.Find("Countdown Label").GetComponent <dfLabel>(); countdownTitle = CountdownPanel.transform.Find("Title Part").GetComponent <dfLabel>(); countdownFraction = CountdownPanel.transform.Find("Fraction Part").GetComponent <dfLabel>(); TipLabel = CountdownPanel.transform.Find("Tip Label").GetComponent <dfLabel>(); if (Random.Range(0, 2) == 0) { TipLabel.Text = "Use your mouse as an alternative target to guide your robot."; } StatusLabel.Text = ""; }
void listItem_Click(dfControl control, dfMouseEventArgs mouseEvent) { if (currentlySelected != null) { currentlySelected.BackgroundColor = new Color32(255, 255, 255, 255); currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Hide(); } dfPanel item = control as dfPanel; RoomData data = item.GetComponent <RoomData>(); data.Selected = true; item.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = item; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); }
void slot1_DragDrop(dfControl control, dfDragEventArgs dragEvent) { dfPanel panel = control as dfPanel; BrainPanelState brainPanel = panel.GetComponent <BrainPanelState>(); if (draggedBrain != null) { if (draggedBrain.ChampionGene == null) { // _dialog.ShowDialog("This brain has not been trained yet and cannot be used in battle mode."); brainPanel.Refresh(); return; } brainPanel.AddBrain(draggedBrain); } }
// Update is called once per frame void Update() { if (DataLoaded) { foreach (Brain brain in allBrains) { if (brain.ChampionGene != null) { print("FILE: " + brain.Population.Name + ", URL: " + brain.Population.Url); StartCoroutine(WaitForRequest(brain)); } } if (rootBrains.Count == 0) { Brain b = new Brain(); b.Name = "New brain"; b.UserId = ParseUser.CurrentUser.ObjectId; b.IsNewBrain = true; rootBrains.Add(b); } AddBrains(rootBrains); slot1.GetComponent <BrainPanelState>().Initialize(); //Player player = ParseUser.CurrentUser as Player; //if (player.Slot1 != null) //{ // slot1.GetComponent<BrainPanelState>().AddBrain(allBrains.Where(t => t.ObjectId.Equals(player.Slot1)).First()); //} //if (player.Slot2 != null) //{ // slot2.GetComponent<BrainPanelState>().AddBrain(allBrains.Where(t => t.ObjectId.Equals(player.Slot2)).First()); //} //if (player.Slot3 != null) //{ // slot3.GetComponent<BrainPanelState>().AddBrain(allBrains.Where(t => t.ObjectId.Equals(player.Slot3)).First()); //} //if (player.Slot4 != null) //{ // slot4.GetComponent<BrainPanelState>().AddBrain(allBrains.Where(t => t.ObjectId.Equals(player.Slot4)).First()); //} } }
void slot1_DragLeave(dfControl control, dfDragEventArgs dragEvent) { dfPanel panel = control as dfPanel; panel.GetComponent <BrainPanelState>().Refresh(); //switch (control.gameObject.name) //{ // case "Slot 1": // panel.BackgroundColor = slot1Color; // break; // case "Slot 2": // panel.BackgroundColor = slot2Color; // break; // case "Slot 3": // panel.BackgroundColor = slot3Color; // break; // case "Slot 4": // panel.BackgroundColor = slot4Color; // break; //} }
void listItem_DoubleClick(dfControl control, dfMouseEventArgs mouseEvent) { if (currentlySelected != null) { currentlySelected.BackgroundColor = new Color32(255, 255, 255, 255); currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Hide(); } dfPanel item = control as dfPanel; RoomData data = item.GetComponent <RoomData>(); data.Selected = true; item.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = item; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); if (TestOK()) { if (data.Game.playerCount < data.Game.maxPlayers) { PhotonNetwork.JoinOrCreateRoom(data.Game.name, null, null); } } }
void listItem_Click(dfControl control, dfMouseEventArgs mouseEvent) { if (currentlySelected != null) { currentlySelected.BackgroundColor = new Color32(255, 255, 255, 255); currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Hide(); } dfPanel item = control as dfPanel; RoomData data = item.GetComponent <RoomData>(); data.Selected = true; item.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = item; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); UpdateInfoBox(); if (data.Game.playerCount < data.Game.maxPlayers) { JoinButton.DoClick(); } }
void GenerateList(string filter) { //Player current = Player.CurrentUser as Player; //current.Get<string>("email"); //IList<Player> players = null; //try //{ // players = current.Get<IList<Player>>("pinnedPlayers"); //} //catch (Exception e) //{ //} //if (players == null) //{ // print("players is null"); // players = new List<Player>() { users.LastOrDefault() }; //} //print("count " + players.Count); //players.Add(users.FirstOrDefault()); //current["pinnedPlayers"] = players; //current.SaveAsync(); //current.PinnedPlayers.FetchAllAsync().ContinueWith(t => //{ // if (current.PinnedPlayers != null) // { // foreach (Player p in current.PinnedPlayers) // { // print("Player: " + p.Username); // } // } // current.PinnedPlayers.Add(users.LastOrDefault()); // current.SaveAsync(); // print("Saving pinnedPlayers"); //}); var children = new List <GameObject>(); foreach (Transform child in UserPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); UserPanel.Enable(); IEnumerable <Player> filtered = users.Where(t => t.Username.ToLower().Contains(filter.ToLower())).OrderByDescending(t => t.ObjectId.Equals(Player.CurrentUser.ObjectId)) .ThenByDescending(t => friendList.Contains(t.ObjectId)); foreach (Player player in filtered) { ParseObject friend = null; if (friends != null) { friend = friends.Where(t => ((Player)t[REQUEST_FROM]).ObjectId.Equals(player.ObjectId) || ((Player)t[REQUEST_TO]).ObjectId.Equals(player.ObjectId)).FirstOrDefault(); // friend = friends.FirstOrDefault(); // print("Friend: " + ((Player)friend[REQUEST_TO]).ObjectId); // print("Player: " + player.ObjectId); } // GameObject ListItem = Instantiate(Resources.Load("List Item")) as GameObject; dfPanel listItem = UserPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = UserPanel.Width - UserPanel.FlowPadding.left - UserPanel.FlowPadding.right; ListItemExtras extras = listItem.GetComponent <ListItemExtras>(); extras.Player = player; extras.FriendRequest = friend; dfLabel username = listItem.Find("Username Label").GetComponent <dfLabel>(); username.Text = player.Username; username.DisabledColor = new Color32(100, 100, 100, 255); dfLabel email = listItem.Find("Email label").GetComponent <dfLabel>(); email.Text = player.Email; email.DisabledColor = new Color32(100, 100, 100, 255); dfSprite onlineSprite = listItem.Find("Online Sprite").GetComponent <dfSprite>(); if (player.IsOnline) { onlineSprite.SpriteName = "OUYA_O 24px"; } else { onlineSprite.SpriteName = "OUYA_A 24px"; } dfButton actionButton = listItem.Find("Action Button").GetComponent <dfButton>(); if (friend == null) { actionButton.Text = "Add"; actionButton.Click += new MouseEventHandler(actionClick_add); } else { string status = friend[STATUS] as string; Player from = friend[REQUEST_FROM] as Player; if (Player.CurrentUser.ObjectId.Equals(from.ObjectId)) { switch (status) { case S_ACCEPTED: actionButton.Text = "Remove"; actionButton.Click += new MouseEventHandler(actionClick_remove); listItem.BackgroundColor = new Color32(200, 255, 200, 255); break; case S_REJECTED: actionButton.Text = "Sorry"; break; case S_PENDING: actionButton.Text = "Pending"; actionButton.Disable(); break; } } else { switch (status) { case S_ACCEPTED: actionButton.Text = "Remove"; actionButton.Click += new MouseEventHandler(actionClick_remove); listItem.BackgroundColor = new Color32(200, 255, 200, 255); break; case S_REJECTED: actionButton.Text = "Rejected"; break; case S_PENDING: actionButton.Text = "Accept"; actionButton.Click += new MouseEventHandler(actionClick_accept); break; } } } if (player.Username.Equals(Player.CurrentUser.Username)) { actionButton.Hide(); } } }
void GenerateRoomList() { var children = new List <GameObject>(); foreach (Transform child in ActiveRoomsPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); if (PhotonNetwork.connected) { int sel_idx = -1; if (currentlySelected != null) { sel_idx = currentlySelected.GetComponent <RoomData>().Index; } int idx = 0; if (PhotonNetwork.GetRoomList().Length == 0) { dfLabel label = ActiveRoomsPanel.AddControl <dfLabel>(); label.Padding = new RectOffset(10, 10, 10, 10); label.Text = "No games available"; label.Color = new Color32(200, 200, 200, 255); label.AutoSize = true; } else { foreach (RoomInfo game in PhotonNetwork.GetRoomList().OrderBy(t => Mathf.Abs((int)t.customProperties["level"] - Player.Level))) { dfPanel listItem = ActiveRoomsPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = ActiveRoomsPanel.Width - ActiveRoomsPanel.FlowPadding.left - ActiveRoomsPanel.FlowPadding.right; listItem.Click += new MouseEventHandler(listItem_Click); listItem.DoubleClick += new MouseEventHandler(listItem_DoubleClick); RoomData data = listItem.GetComponent <RoomData>(); data.Game = game; data.Index = idx++; if (data.Index == sel_idx) { // print("They match!"); data.Selected = true; listItem.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = listItem; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); } dfLabel roomName = listItem.Find("Room Name").GetComponent <dfLabel>(); roomName.Text = string.Format("{0} ({1})", game.customProperties["name"].ToString(), game.customProperties["level"].ToString()); dfLabel mapName = listItem.Find("Map Type").GetComponent <dfLabel>(); mapName.Text = game.customProperties["map"].ToString(); dfLabel modeName = listItem.Find("Game Mode").GetComponent <dfLabel>(); modeName.Text = game.customProperties["mode"].ToString(); dfLabel numberPlayers = listItem.Find("Number Players").GetComponent <dfLabel>(); numberPlayers.Text = string.Format("{0}/{1}", game.playerCount, game.maxPlayers); if (game.playerCount < game.maxPlayers) { numberPlayers.Color = new Color32(0, 255, 0, 255); } else { numberPlayers.Color = new Color32(255, 0, 0, 255); } } } } }
// Use this for initialization void Start() { gameInfo.GetComponent <LevelProgressIndicator>().levelLabel.Text = "1"; }