//加载关卡prefab public void loadStage() { var stageName = _stage.PrefabName; if (stageName == null) { stageName = "Stage"; } if (stage != null) { ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.LoadStage), null); ResetSceneControl(); DestroyImmediate(stage.gameObject); // Destroy(stage.gameObject); } //加载prefab // stage = (GameObject)Instantiate(Resources.Load("Prefabs/Stage/Stage")); stage = (GameObject)Instantiate(Resources.Load("Prefabs/Stage/" + stageName)); mask = (GameObject)Instantiate(Resources.Load("Prefabs/Objects/Mask")); AudioManager.GetInstance().PlayNewAudio("Audio/Stage/" + _stage.Chapter.ChapterAudio); UserData userData = UserDataManager.GetInstance().GetUserData(); UserStage userStage = userData.GetUserStage(_stage.StageId); // _star = userStage.Star; GameObject obj = GameObject.Find("SceneControl"); // GameObject sr = GameObject.Find(stage.name + "/Sprite"); // _spr = sr.GetComponent<SpriteRenderer>(); // SceneControl sc = obj.GetComponent<SceneControl>(); // ClickAndRotate car = spr.GetComponent<ClickAndRotate>(); // car.SetChecked(true); }
public void RequestLogin() { process.SetActive(true); if (idTxt.text == "" || pwdTxt.text == "") { this.userState = UserStage.EmptyField; if (idTxt.text == "") { process.GetComponentsInChildren <Text>()[0].text = "아이디를 입력해세요."; } else { process.GetComponentsInChildren <Text>()[0].text = "비밀번호를 입력해세요."; } process.SetActive(true); EnableObjects(false); this.userState = UserStage.EmptyField; } else { this.userState = UserStage.NotConnected; } EnableObjects(false); }
public void Cancle() { login.Enter(); login.EnableObjects(true); this.userState = UserStage.RequestRegistering; GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Login; }
public void Enter() { this.networkManager.messageReceiver = this; this.userState = UserStage.RequestFinding; id.text = ""; nick.text = ""; process.SetActive(false); }
/// <summary> /// Packet을 수신 했을 때 호출됨 /// </summary> /// <param name="msg"></param> public void OnReceive(Packet msg) { // 제일 먼저 프로토콜 아이디를 꺼내온다. PROTOCOL protocolID = (PROTOCOL)msg.PopProtocolID(); switch (protocolID) { case PROTOCOL.FailFinding: { process.SetActive(true); int result = msg.PopInt32(); switch (result) { case -3: process.GetComponentsInChildren <Text>()[0].text = "DB 연결 실패"; break; case -2: // Debugging - 거의 나타나지 않음 process.GetComponentsInChildren <Text>()[0].text = "잘못된 신호"; break; case -1: switch (signal) { case 0: process.GetComponentsInChildren <Text>()[0].text = "없는 닉네임입니다."; break; case 1: process.GetComponentsInChildren <Text>()[0].text = "없는 아이디입니다."; break; } break; } this.userState = UserStage.FailFinding; } break; case PROTOCOL.SuccessFinding: { process.SetActive(true); switch (signal) { case 0: process.GetComponentsInChildren <Text>()[0].text = "아이디 : " + msg.PopString(); break; case 1: process.GetComponentsInChildren <Text>()[0].text = "비밀번호 : " + msg.PopString(); break; } this.userState = UserStage.SuccessFinding; } break; } }
public void Enter() { this.networkManager.messageReceiver = this; this.userState = UserStage.RequestRegistering; id.text = ""; pwd.text = ""; nick.text = ""; process.SetActive(false); EnableObjects(true); }
/// <summary> /// Packet을 수신 했을 때 호출됨 /// </summary> /// <param name="msg"></param> public void OnReceive(Packet msg) { // 제일 먼저 프로토콜 아이디를 꺼내온다. PROTOCOL protocolID = (PROTOCOL)msg.PopProtocolID(); switch (protocolID) { case PROTOCOL.FailLogin: { process.SetActive(true); int result = msg.PopInt32(); switch (result) { case -4: process.GetComponentsInChildren <Text>()[0].text = "이미 접속 중"; break; case -3: process.GetComponentsInChildren <Text>()[0].text = "서버 DB 문제"; break; case -2: process.GetComponentsInChildren <Text>()[0].text = "없는 아이디입니다."; break; case -1: process.GetComponentsInChildren <Text>()[0].text = "비밀번호가 틀렸습니다."; break; } this.userState = UserStage.FailLogin; } break; case PROTOCOL.SuccessLogin: { UserData.User.Instance.Initialize(msg.PopString(), msg.PopInt32(), msg.PopInt32()); process.GetComponentsInChildren <Text>()[0].text = UserData.User.Instance.name + "님 환영합니다."; this.userState = UserStage.SuccessLogin; } break; case PROTOCOL.StartLoading: { byte playerIndex = msg.PopByte(); //this.battleRoom.gameObject.SetActive(true); //this.battleRoom.StartLoading(playerIndex); GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Select; gameObject.SetActive(false); } break; } }
} //关卡列表 public void parseJson(JsonData jd) { ChapterId = Int32.Parse(jd["ChapterId"].ToString()); Stages = new List <UserStage>(); foreach (JsonData stage in jd["Stages"]) { UserStage s = new UserStage(); s.parseJson(stage); Stages.Add(s); } }
public void OnConnected() { timer = 0; totalTimer = 0; Packet msg = Packet.Create((short)PROTOCOL.RequestRegistering); msg.Push(id.text); msg.Push(pwd.text); msg.Push(nick.text); this.networkManager.Send(msg); this.userState = UserStage.Connected; }
/// <summary> /// Server에 접속이 완료되면 호출됨 /// </summary> public void OnConnected() { timer = 0; #if DEBUG Debug.Log("Connected"); #endif Packet msg = Packet.Create((short)PROTOCOL.RequestLogin); msg.Push(idTxt.GetComponent <InputField>().text); msg.Push(pwdTxt.GetComponent <InputField>().text); this.networkManager.Send(msg); this.userState = UserStage.Connected; }
//加载数据 public void LoadData(Stage stage, UserStage userStage) { if (!_inited) { init(); } if (stage == null) { gameObject.SetActive(false); return; } _title.text = stage.Order + ""; int star = -1; if (userStage == null) { _lock.gameObject.SetActive(true); // _button.enabled = false; } else { star = userStage.Star; // _button.enabled = true; _lock.gameObject.SetActive(false); } Debug.Log("star=" + star + ",_stars.Length=" + _stars.Length); for (int i = 0; i < _stars.Length; i++) { if (userStage == null) { _stars[i].gameObject.SetActive(false); continue; } if (i == star) { _stars[i].gameObject.SetActive(true); } else { _stars[i].gameObject.SetActive(false); } } _userStage = userStage; }
public void RequestRegistering() { process.SetActive(true); if (id.text == "" || pwd.text == "" || nick.text == "") { this.userState = UserStage.EmptyField; process.GetComponentsInChildren <Text>()[0].text = "모든 칸을 채워주세요."; } else { this.userState = UserStage.NotConnected; } EnableObjects(false); }
public void RequestFindPWD() { process.SetActive(true); if (id.text == "") { this.userState = UserStage.EmptyField; process.GetComponentsInChildren <Text>()[0].text = "아이디를 채워주세요."; } else { signal = 1; this.userState = UserStage.NotConnected; } EnableObjects(false); }
/// <summary> /// Packet을 수신 했을 때 호출됨 /// </summary> /// <param name="msg"></param> public void OnReceive(Packet msg) { // 제일 먼저 프로토콜 아이디를 꺼내온다. PROTOCOL protocolID = (PROTOCOL)msg.PopProtocolID(); switch (protocolID) { case PROTOCOL.FailFriendList: { int result = msg.PopInt32(); #if DEBUG switch (result) { case -3: Debug.Log("DB 연결 실패"); break; case -1: Debug.Log("DB Data 없음"); break; } #endif this.userState = UserStage.NotState; main.Enter(); GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Main; } break; case PROTOCOL.SuccessFriendList: { int count = msg.PopInt32(); int index = 0; for (int i = 0; i < count; i++) { friends.Add(new UserInfo(msg.PopString(), msg.PopInt32(), (RANK)msg.PopInt32())); friendsObj.Add(Instantiate(friendInfo, contents.transform)); Text[] texts = friendsObj[i].GetComponentsInChildren <Text>(); texts[0].text = friends[friends.Count - 1].Name; texts[1].text = friends[friends.Count - 1].Rank.ToString(); texts[2].text = friends[friends.Count - 1].Score.ToString(); } } break; } }
public void Connect() { if (!this.networkManager.IsConnected()) { this.networkManager.Connect(); } else { timer = 0; Packet msg = Packet.Create((short)PROTOCOL.RequestFriendList); msg.Push(User.Instance.name); this.networkManager.Send(msg); this.userState = UserStage.Connected; } }
private void OnVictory(UEvent evt) { Debug.Log("OnVictory"); //更改玩家数据 UserData userData = UserDataManager.GetInstance().GetUserData(); UserStage userStage = userData.GetUserStage(_stage.StageId); bool needSave = false; Debug.Log("OnVictory userStage.Star=" + userStage.Star + ",_star=" + _star); if (userStage.Star < _star) { needSave = true; userStage.Star = _star; } if (!userStage.Completed) { userStage.Completed = true; needSave = !userData.OpenStage(_stage.NextStage); } if (needSave) { DBManager.WriteUserData(); } //展示胜利面板 _victoryPanel.GetComponent <Victory>().ResetAni(); _victoryPanel.SetActive(true); //展示星星数 // for (int i = 0; i <= 2; i++) // { // var star = _victoryPanel.transform.Find("StarNode" + i + "/Star"); // var empty = _victoryPanel.transform.Find("StarNode" + i + "/Empty"); // if (i + 1 <= _star){ // star.gameObject.SetActive(true); // empty.gameObject.SetActive(false); // } // else // { // star.gameObject.SetActive(false); // empty.gameObject.SetActive(true); // } // } }
public bool OpenStage(Stage stage) { //是否有当前章节 UserChapter uc = null; foreach (var c in Chapters) { if (c.ChapterId == stage.ChapterId) { uc = c; break; } } if (uc != null) { foreach (var s in uc.Stages) { if (stage.StageId == s.StageId) { return(false); } } } else { UserChapter nuc = new UserChapter(); nuc.Stages = new List <UserStage>(); nuc.ChapterId = stage.ChapterId; uc = nuc; Chapters.Add(uc); } UserStage us = new UserStage(); us.StageId = stage.StageId; us.Star = 0; us.Completed = false; uc.Stages.Add(us); DBManager.WriteUserData(); return(true); }
public void OnConnected() { timer = 0; totalTimer = 0; Packet msg = Packet.Create((short)PROTOCOL.RequestFinding); msg.Push(signal); switch (signal) { case 0: msg.Push(nick.text); break; case 1: msg.Push(id.text); break; } this.networkManager.Send(msg); this.userState = UserStage.Connected; }
void Update() { switch (this.userState) { case UserStage.ProcessTimer: timer -= Time.deltaTime; startingTimerObj.GetComponentInChildren <Text>().text = (int)timer + "초 후 시작"; if (timer <= 0) { this.userState = UserStage.ProcessGame; startingTimerObj.GetComponentInChildren <Text>().text = "게임 시작"; Invoke("StartGame", 1); } break; case UserStage.ProcessGame: //여기부터 유닛들이 진짜 움직이기 시작함 break; } }
public void CreateUserStage(UserStage stage, BooleanCallback callback) { var json = JsonUtility.ToJson(stage); StartCoroutine(API_POST("userStage/insert", json, (connect, response) => { if (connect) { //성공알림 Debug.Log("success create stage"); Debug.Log(response); callback(true); } else { Debug.LogError(response); callback(false); //재시도 } })); }
/// <summary> /// Packet을 수신 했을 때 호출됨 /// </summary> /// <param name="msg"></param> public void OnReceive(Packet msg) { // 제일 먼저 프로토콜 아이디를 꺼내온다. PROTOCOL protocolID = (PROTOCOL)msg.PopProtocolID(); switch (protocolID) { case PROTOCOL.FailRegistering: { process.SetActive(true); int result = msg.PopInt32(); switch (result) { case -3: process.GetComponentsInChildren <Text>()[0].text = "DB 연결 실패"; break; case -2: process.GetComponentsInChildren <Text>()[0].text = "알 수 없는 문제"; break; case -1: process.GetComponentsInChildren <Text>()[0].text = "아이디 또는 이름 중복"; break; } this.userState = UserStage.FailRegistering; } break; case PROTOCOL.SuccessRegistering: { process.SetActive(true); process.GetComponentsInChildren <Text>()[0].text = "가입 완료"; this.userState = UserStage.SuccessRegistering; } break; } }
public void Enter() { userState = UserStage.NotState; this.networkManager.messageReceiver = this; if (friendsObj != null) { foreach (GameObject gameObj in friendsObj) { DestroyImmediate(gameObj); } friends.Clear(); friendsObj.Clear(); } else { friends = new List <UserInfo>(); friendsObj = new List <GameObject>(); } this.userState = UserStage.NotConnected; }
private void InitUserData() { _userData = new UserData(); //初始化第一章第一关 _userData.DeviceId = System.Guid.NewGuid().ToString(); Chapter c = ConfigManager.GetInstance().GetAllChapters()[0]; List <UserChapter> chapters = new List <UserChapter>(); UserChapter uc = new UserChapter(); uc.ChapterId = c.ChapterId; uc.Stages = new List <UserStage>(); chapters.Add(uc); Stage s = c.Stages[0]; UserStage us = new UserStage(); us.StageId = s.StageId; us.Completed = false; us.Star = 0; uc.Stages.Add(us); _userData.Chapters = chapters; _userData.CurrentStage = s.StageId; DBManager.WriteUserData(); }
public void MoveMain() { main.Enter(); this.userState = UserStage.NotState; GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Main; }
public void Enter() { networkManager.messageReceiver = this; this.userState = UserStage.ProcessTimer; startingTimerObj.SetActive(true); }
void Update() { switch (this.userState) { case UserStage.RequestRegistering: break; case UserStage.EmptyField: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestRegistering; } break; case UserStage.NotConnected: if (totalTimer > 10) { process.GetComponentsInChildren <Text>()[0].text = "서버 무응답"; if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { this.userState = UserStage.RequestRegistering; EnableObjects(true); process.SetActive(false); totalTimer = 0; } } else { if (timer > 2) { process.GetComponentsInChildren <Text>()[0].text = "연결 중..."; } else if (timer > 1) { process.GetComponentsInChildren <Text>()[0].text = "연결 중.."; } else if (timer > 0) { process.GetComponentsInChildren <Text>()[0].text = "연결 중."; } if (timer > 3) { Connect(); timer = 0; } else { timer += Time.deltaTime; } totalTimer += Time.deltaTime; } break; case UserStage.FailRegistering: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestRegistering; } break; case UserStage.SuccessRegistering: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestRegistering; Cancle(); } break; } }
void Update() { switch (this.userState) { case UserStage.RequestLogin: break; case UserStage.EmptyField: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestLogin; } break; case UserStage.NotConnected: if (totalTimer > 10) { process.GetComponentsInChildren <Text>()[0].text = "서버 무응답"; if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { this.userState = UserStage.RequestLogin; EnableObjects(true); process.SetActive(false); totalTimer = 0; } } else { if (timer > 2) { process.GetComponentsInChildren <Text>()[0].text = "연결 중..."; } else if (timer > 1) { process.GetComponentsInChildren <Text>()[0].text = "연결 중.."; } else if (timer > 0) { process.GetComponentsInChildren <Text>()[0].text = "연결 중."; } if (timer > 3) { Connect(); timer = 0; } else { timer += Time.deltaTime; } totalTimer += Time.deltaTime; } break; case UserStage.Connected: break; case UserStage.FailLogin: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestLogin; } break; case UserStage.SuccessLogin: if (Input.touchCount > 0 || Input.GetMouseButtonUp(0)) { EnableObjects(true); process.SetActive(false); this.userState = UserStage.RequestLogin; GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Main; main.Enter(); } break; case UserStage.WaitingMatching: if (GUI.Button(new Rect(Screen.width - 100, Screen.height / 2 - 25, 100, 50), "cancle")) { this.userState = UserStage.Connected; Packet msg = Packet.Create((short)PROTOCOL.CancleMatching); this.networkManager.Send(msg); } break; } }
void Start() { this.userState = UserStage.RequestLogin; Enter(); }
public void OnDisconnected() { this.userState = UserStage.RequestLogin; GameObject.Find("SceneManager").GetComponent <MySceneManager>().Present = SceneList.Login; }
public UserStage DeepCopy() { UserStage copy = new UserStage(nickname, stage_num, stage_star, stage_move); return(copy); }