// Use this for initialization void Start () { UserDAO userDAO = new UserDAO(); User userData = userDAO.LoadUserFromLocalMemory(); GameObject MusicObject = GameObject.FindGameObjectWithTag("MusicBackground"); if(!MusicObject){ GameObject musicClone = (GameObject)Instantiate(Music, Vector3.zero, Quaternion.identity); AudioSource audioMusic = musicClone.GetComponent<AudioSource>(); //Por defecto las variables de tipo bool son false Debug.Log("MusicGenerator:user.EnableMusic(): " + userData.EnableMusic); if(userData.EnableMusic){ audioMusic.Play(); }else{ audioMusic.Stop(); } } }
void SetInitialGameSettings() { GenerateColorBoard(); UserDAO userDAO = new UserDAO(); movesOverEmptyTiles = 0; isGameOver = false; backPress = false; PathPieces = new Stack<Piece>(); //(1)//currentPlayerPanel = GameObject.Find("CurrentPlayerPanel"); //(2)//remainingTimePlayer = currentPlayerPanel.transform.Find("RemainingTime").GetComponent<Text>(); //Use this call instead two GameObject.Find (1) and (2) as possible. remainingTimePlayer = GameObject.Find("CurrentPlayerPanel/RemainingTime").GetComponent<Text>(); remainingTimePlayer.text = formatTime; MovesBoardController.Instance.FindViewByID(); MovesBoardController.Instance.HideAllMessages(); GameApplication.Instance.Players = new List<User>(); User player; playersPanel = GameObject.Find("PlayersPanel"); for(int i = 1; i < numPlayers + 1; i++){ player = new User(); if(i==1){ player = userDAO.LoadUserFromLocalMemory(); GameObject Player1 = GameObject.Find("Player1"); RectTransform Player1Info = Player1.transform.Find("PlayerInfo").GetComponent<RectTransform>(); Text player1Text = Player1Info.transform.Find("TextName").GetComponent<Text>(); if((player.AvatarName == null || player.AvatarName.Length<1)){ player1Text.text = "Player1"; } else{ player1Text.text = player.AvatarName; } player.RemainingTime = timer; GameApplication.Instance.Players.Add(player); playerPanelP1 = playersPanel.transform.Find("Player1").GetComponent<RectTransform>(); gameButtonsP1 = playerPanelP1.transform.Find("GameButtons").GetComponent<CanvasGroup>(); gameButtonsP1.alpha = 1; } else{ GameObject playerN = GameObject.Find("Player" + i); RectTransform PlayerInfo = playerN.transform.Find("PlayerInfo").GetComponent<RectTransform>(); Text playerNText = PlayerInfo.transform.Find("TextName").GetComponent<Text>(); player.AvatarName = "Player" + i; playerNText.text = player.AvatarName; player.RemainingTime = timer; GameApplication.Instance.Players.Add(player); if(i == 2){ playerPanelP2 = playersPanel.transform.Find("Player" + i).GetComponent<RectTransform>(); gameButtonsP2 = playerPanelP2.transform.Find("GameButtons").GetComponent<CanvasGroup>(); gameButtonsP2.alpha = 0; } } } colorSelector = GameObject.Find("ColorSelector"); GameApplication.Instance.AvailableColors = new List<string>(); for(int i=0; i< MAX_COLORS ; i++) { Image selector = colorSelector.transform.GetChild(i).GetComponent<Image>(); if(i!=0){ selector.enabled = false; } } //currentPlayerName = currentPlayerPanel.transform.Find("CurrentPlayerName").GetComponent<Text>(); currentPlayerName = GameObject.Find("CurrentPlayerPanel/CurrentPlayerName").GetComponent<Text>(); if(currentPlayer == null){ currentPlayer = "Player1"; currentPlayerName.text = (GameApplication.Instance.Players[0].AvatarName == null || GameApplication.Instance.Players[0].AvatarName.Length < 1) ? currentPlayer : GameApplication.Instance.Players[0].AvatarName; } }
void LoadData() { Debug.Log("FriendsController:LoadingData()....."); UserDAO userDAO = new UserDAO(); User userData = userDAO.LoadUserFromLocalMemory(); Debug.Log("userData.AvatarName: " + userData.AvatarName); }
void LoadData() { Debug.Log("LoadingData()....."); userDAO = new UserDAO(); User userData = userDAO.LoadUserFromLocalMemory(); Debug.Log("userData.AvatarName: " + userData.AvatarName); if(userData != null) SetUserProfileInfo(userData); else AvatarNameInput.text = "Player1"; }