void _InitPlayerMovementRule(Transform tr_players, string[] go_position, initDelegate initMethod) { int length = Math.Min(tr_players.childCount, 4); for (int i = 0; i < length; i++) { initMethod(tr_players.GetChild(i).Find(String.Concat(go_position[0], (i + 1).ToString())).Find(go_position[1]).gameObject); } }
/*void _InitPlayerPresence(Transform tr_players, initDelegate initMethod) { * if (PlayersNumber == 4) * return; * * int length = Math.Min(tr_players.childCount, 4); * for(int i = PlayersNumber; i < length; i++) { * initMethod(tr_players.GetChild(i).gameObject); * } * }*/ void _InitPlayerRule(Transform tr_players, initDelegate initMethod) { int length = PlayersNumber; for (int i = 0; i < length; i++) { initMethod(tr_players.gameObject); } }
// For the moment go_position.size == 2 ONLY // Need to create recursive function for FIND // Find a solution to facto initRoom/PLayer ?! void _InitRoomRule(Transform tr_rooms, string[] go_position, initDelegate initMethod) { int length = tr_rooms.childCount; for (int i = 0; i < length; i++) { if (tr_rooms.GetChild(i).gameObject.active) { initMethod(tr_rooms.GetChild(i).Find(go_position[0]).Find(go_position[1]).gameObject); } } }
/// <summary> /// 사용자 정보 받아오기 ( 앱에 로그인 되어 있는 유저를 말함 ) /// </summary> /// <param name="userToken">유저 토큰</param> /// <param name="func">성공적으로 마쳤을때 불러올 함수</param> /* public IEnumerator getPlayerInfo(initDelegate func) * { * // GAME.init 이 true 가 되기보다 getPlayerInfo 더 빠를수도 있음을 방지 * while (!GAME.init) * yield return null; * * if (GAME.init) * { * WWWForm form = new WWWForm(); * form.AddField("game_stage", GAME.game_stage); * form.AddField("user_token", LA.User.Lemon._user.playerToken); * WWW w = new WWW("http://lemontree.dothome.co.kr/get_user_info", form); * * yield return w; * * if (!w.text.Equals("NOT FOUND")) * { * LA.LAData data = JsonUtility.FromJson<LA.LAData>(w.text); * * // _EDITION_0_ * LA.User.Lemon._user.playerToken = data.LA_USER_TOKEN; * LA.User.Lemon._user.playerName = data.LA_USER_NAME; * LA.User.Lemon._user.playerAge = System.Convert.ToInt32(data.LA_USER_AGE); * if (data.LA_USER_SEX.Equals("0")) * LA.User.Lemon._user.playerSex = "MAN"; * else LA.User.Lemon._user.playerSex = "WOMAN"; * // _EDITION_1_ * LA.User.Lemon._user.playerEmail = data.LA_USER_EMAIL; * LA.User.Lemon._user.playerCP = data.LA_USER_PHONE; * LA.User.Lemon._user.playerAchievement = data.LA_USER_ACHIEVEMENT; * LA.User.Lemon._user.playerFollower = data.LA_USER_FOLLOWER; * // _EDITION_2_ * LA.User.Lemon._user.playerGames = data.LA_USER_GAMES; * * func(LA.User.Lemon._user); * } * } * } */ /// <summary> /// 유저 정보 받아오기 ( 어느 유저 타겟에 대한 정보 ) /// </summary> /// <param name="userToken">유저 토큰</param> /// <param name="func">성공적으로 마쳤을때 불러올 함수</param> public IEnumerator getUserInfo(string userToken, initDelegate func) { // GAME.init 이 true 가 되기보다 getUserInfo호출이 더 빠를수도 있음을 방지 while (!GAME.init) { yield return(null); } if (GAME.init) { WWWForm form = new WWWForm(); form.AddField("game_stage", GAME.game_stage); form.AddField("user_token", userToken); WWW w = new WWW("http://lemontree.dothome.co.kr/get_user_info", form); yield return(w); if (!w.text.Equals("")) { LA.User.UserInfo uinfo = new LA.User.UserInfo(); LA.LAData data = JsonUtility.FromJson <LA.LAData>(w.text); // _EDITION_0_ uinfo.playerToken = data.LA_USER_TOKEN; uinfo.playerName = data.LA_USER_NAME; uinfo.playerAge = System.Convert.ToInt32(data.LA_USER_AGE); if (data.LA_USER_SEX.Equals("0")) { uinfo.playerSex = "MAN"; } else { uinfo.playerSex = "WOMAN"; } // _EDITION_1_ uinfo.playerEmail = data.LA_USER_EMAIL; uinfo.playerCP = data.LA_USER_PHONE; uinfo.playerAchievement = data.LA_USER_ACHIEVEMENT; uinfo.playerFollower = data.LA_USER_FOLLOWER; // _EDITION_2_ uinfo.playerGames = data.LA_USER_GAMES; func(uinfo); } else { Debug.Log("w Error"); } } }
public void SetDungeon() { GameObject go_rooms = transform.root.Find("Rooms").Find("Level_0").gameObject; GameObject go_players = transform.root.Find("Players").gameObject; // Consumable if (ConsumablePresence == 0) { m_initMethodGo = _DestroyGo; } else { m_initMethodGo = _SetActiveGo; } _InitRoomRule(go_rooms.transform, new string[] { "Items", "Consumables" }, m_initMethodGo); // Monster if (StaticMonsterPresence == 0) { m_initMethodGo = _DestroyGo; } else { m_initMethodGo = _SetActiveGo; } _InitRoomRule(go_rooms.transform, new string[] { "Enemies", "Monsters" }, m_initMethodGo); // Player //m_initMethodGo = _DestroyGo; //_InitPlayerPresence(go_players.transform, m_initMethodGo); //m_initMethodGo = _SetActiveGo; m_initMethodGo = _CreatePrefab; _InitPlayerRule(go_players.transform, m_initMethodGo); _InitScoreDungeon(); //m_initMethodGo = _SetPlayerSpeed; //_InitPlayerMovementRule(go_players.transform, new string[] {"Controller_", "Movement"}, m_initMethodGo); }