public void MoveToNPC() { Vector3 tmpDist = (m_target.position - transform.position); if (tmpDist.magnitude < 2) { if (npcState == NPCState.eRun) { timeCount = 0; npcState = NPCState.eAttack; npcAnimalMsg.ChangeEventId((ushort)NPCMonsterEvent.eAnimalAttack); SendMsg(npcAnimalMsg); } } else { if (npcState == NPCState.eAttack) { timeCount = 0; npcState = NPCState.eRun; npcAnimalMsg.ChangeEventId((ushort)NPCMonsterEvent.eAnimalRun); SendMsg(npcAnimalMsg); } } Debug.DrawLine(transform.position, m_target.position, Color.cyan); Vector3 tmpLoc = tmpDist - tmpDist.normalized * deltaDist; agent.destination = tmpLoc + transform.position; Debug.DrawLine(transform.position, agent.destination, Color.red); transform.LookAt(m_target.position); }
/// <summary> /// 异步切换场景 /// </summary> IEnumerator HandoverScene(int num) { //slider.gameObject.SetActive(true); //gameObject.SetActive(false); //reminderLabel.gameObject.SetActive(false); opera = SceneManager.LoadSceneAsync(num); opera.allowSceneActivation = false; while (!opera.isDone) { if (tmpProgress >= 100) { break; } yield return(null); } //yield return opera; yield return(new WaitForSeconds(0.1f)); isProgressBar = true; //向lua发送加载选择场景UI MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)RoleEvents.GetResource); SendMsg(tmpMsg); opera.allowSceneActivation = true; }
void OnMouseExit() { MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)NPCTextureEvents.MouseExitNPC); SendMsg(tmpMsg); }
void LoadResult() { Debuger.Log(" Check resource finish ............"); MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)CheckAssetEvents.CheckFinish); SendMsg(tmpMsg); ObjectPoolManager <MsgBase> .Instance.ReleaseObject(tmpMsg); }
public void DonePress() { Debug.Log("BtnPress"); MsgBase tmpBase = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpBase.ChangeEventId((ushort)UIDemoLoading.ShowPanel); SendMsg(tmpBase); ObjectPoolManager <MsgBase> .Instance.ReleaseObject(tmpBase); gameObject.SetActive(false); }
public override void ProcessEvent(MsgBase msg) { switch (msg.msgId) { case (ushort)UIDemoEvents.DemoMsg: { Debug.Log(" c# recv msg ====="); MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)UIDemoLoadingEvents.TestMsg); SendMsg(tmpMsg); ObjectPoolManager <MsgBase> .Instance.ReleaseObject(tmpMsg); } break; default: break; } }
/// <summary> /// 登录 /// </summary> public void OnLoginButtonClick(Text hint, string name, string pass) { string zhanghao = name; //切换到play场景,角色魔法师 TODO PlayerPrefs.SetString("LoginAccount", zhanghao); zhanghao1 = zhanghao; string mima1 = pass; Sqlite.Instance().Open(Application.dataPath + "/data.db"); Sqlite.Instance().ExecuteNonQuery("create table if not exists User(uid integer primary key autoincrement,account text,password text,username text,character text)"); Sqlite.Instance().ExecuteNonQuery("create table if not exists storage(account text,save text,level integer, hpbar real, mpbar real, expbar real, totalExp real, equip text)"); reader = Sqlite.Instance().ExecuterReader("select * from User where account = '" + zhanghao + "'"); if (reader.Read()) { string password = reader.GetString(2); string character = reader.GetString(4); string username = reader.GetString(3); if (mima1 == password) { //Debug.Log("登录成功"); have = true; if (character == "0") { //切换到play场景,角色魔法师 TODO PlayerPrefs.SetInt("SelectCharacterIndex", 0); //存储输入的帐号 PlayerPrefs.SetString("Account", zhanghao); //StartCoroutine(HandoverScene(3)); } else if (character == "1") { //切换到play场景,角色剑士 TODO PlayerPrefs.SetInt("SelectCharacterIndex", 1); //存储输入的帐号 PlayerPrefs.SetString("Account", zhanghao); //StartCoroutine(HandoverScene(3)); } else { //存储输入的帐号 PlayerPrefs.SetString("Account", zhanghao); //切换到character场景 //向lua发送加载切换进度条的消息 MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)RoleEvents.LoadinProgressLoad); SendMsg(tmpMsg); //HandoverScene2(1); StartCoroutine(HandoverScene(1)); //Debug.Log("!!!!!!!!!!!!!!!!!!!!!!"); } } else { //Debug.Log("密码错误"); hint.gameObject.SetActive(true); hint.text = "帐号或密码错误"; } } else { //Debug.Log("账号不存在"); hint.gameObject.SetActive(true); hint.text = "账号不存在"; } Sqlite.Instance().Close(); }
private void SkillOneButtonClick(BaseEventData tmpEvent) { skillMsg.ChangeEventId((ushort)CharactorEvent.eAttackBig); SendMsg(skillMsg); }
void OnButtonPressed(string buttonName) { buttonMsg.ChangeEventId((ushort)CharactorEvent.eAttack); SendMsg(buttonMsg); }
// <summary> // 提示语 // </summary> // <param name = "reminder" > 提示语 </ param > public void OnClickOk(Text hint, string name, string pass) { string zhanghao = name; string mima1 = pass; Sqlite.Instance().Open(Application.dataPath + "/data.db"); Sqlite.Instance().ExecuteNonQuery("create table if not exists User(uid integer primary key autoincrement,account text,password text,username text,character text)"); Sqlite.Instance().ExecuteNonQuery("create table if not exists storage(account text,save text,level integer, hpbar real, mpbar real, expbar real, totalExp real, equip text)"); //int a = Sqlite.Instance.ExecuteNonQuery(string.Format("insert into User values('{0}','{1}')", zhanghao, mima1)); bool result1 = Regex.IsMatch(zhanghao, "^\\d{8,12}$"); bool result2 = Regex.IsMatch(mima1, "^.{8,12}$"); if (zhanghao == "null" || mima1 == "null") { //Debug.Log("qweqwe"); hint.gameObject.SetActive(true); hint.text = "帐号或密码不能为空"; } else if (!result1) { hint.gameObject.SetActive(true); hint.text = "账号长度为8-12位的数字"; } else { if (!result2) { hint.gameObject.SetActive(true); hint.text = "密码长度为8-12位"; } else { reader = Sqlite.Instance().ExecuterReader("select * from User where account = '" + zhanghao + "'"); if (reader.Read()) { hint.gameObject.SetActive(true); hint.text = "账号已存在"; } else { //存储输入的帐号 PlayerPrefs.SetString("Account", zhanghao); Sqlite.Instance().ExecuteNonQuery(string.Format("insert into User(account,password,username,character) values('{0}','{1}','{2}','{3}')", zhanghao, mima1, 000, "风云无忌")); Sqlite.Instance().ExecuteNonQuery(string.Format("insert into storage values('{0}','{1}', 1, 100, 100, 0, 100, '0')", zhanghao, 0)); //向lua发送加载切换进度条的消息 MsgBase tmpMsg = ObjectPoolManager <MsgBase> .Instance.GetFreeObject(); tmpMsg.ChangeEventId((ushort)RoleEvents.SigninProgressLoad); SendMsg(tmpMsg); StartCoroutine(HandoverScene(1)); } } } //Sqlite.Instance.ExecuteNonQuery("delete from Userr"); //Debug.Log("清空数据库"); Sqlite.Instance().Close(); }