//string TempCurrentGKDate; //初始化关卡数据 public void InitGuanKaDate() { print(" 初始化 关卡数据!!!!!! "); //进游戏 才能调用 //GlobalSetDate.instance.GetGameAllCunstomStr(); GlobalDateControl.GetGameAllCunstomStr(); //查找存档中是否有本关卡的关卡记录 通过本关卡名字获取本关卡数据 string TempCurrentGKDate = GlobalDateControl.GetCurrentGKDate(); //GlobalSetDate.instance.GetGuanKaStrByGKNameAndRemoveIt(SceneManager.GetActiveScene().name); //print("关于本关卡的关卡记录>> " + TempCurrentGKDate); if (TempCurrentGKDate == null) { //print(" 记录 null "+ TempCurrentGKDate); TempCurrentGKDate = ""; //GuanKaStr; } else { //print(" 有关卡记录 草!!!!!!! "); //如果全局数据中有本关卡数据 清除掉原数据中本关卡数据 匹配本关卡数据 if (GlobalDateControl.GetCGKName().Split('@').Length == 1) { GetPiPei(); } //GetPiPei(); } ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.CHANGE_SCREEN, SetChangeThisGKInZGKTempDate); ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.RECORDOBJ_CHANGE, GKDateChange); ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.PLAYER_ZT, PlayerZT); }
// Start is called before the first frame update void Start() { //print(GlobalDateControl.GetCurrentGKDate()); //GlobalDateControl.SetDateInCGKDateAndGetInZGKDate(QISHI); if (GlobalDateControl.IsHasDateByName(QISHI)) { IsHasPlayed = true; print(" 起始剧情已经播放完毕!!! "); } else { print(" @@@@ 没有记录 "); } if (IsHasPlayed) { //飞船是到岸的 默认-89.62 到岸是 -23.73 FeiChuanDaoAn(); _text.GetComponent <CanvasGroup>().alpha = 0; //龙不动 //门是关的 //ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.OPEN_DOOR, "Men_1-1"), this); return; } zz.GetComponent <CanvasGroup>().alpha = 1; txtCSPos = _text.transform.position; _text.GetComponent <CanvasGroup>().alpha = 0; }
void PlotOverSave() { print("对话 存档是否 被调用 !!!!!!!!!!!!"); for (int i = 0; i < OverCunRuShuJuArr.Length; i++) { GlobalDateControl.SetMsgInCurrentGKDateAndSetInZGKDate(OverCunRuShuJuArr[i]); } //ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.OPEN_DOOR, OpenDoor); ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.OPEN_DOOR, "Men_2-0"), this); if (IsNeedRecordByOver) { GlobalDateControl.SaveMapDate(); } //是否出现啥 徽章 或者爆炸 等 //if (IsOverMoveSelf) //{ // OverDelSelf(); //} //能不能延迟 才能使玩家 行动 }
void ChangeScreen() { print(" 场景 变化 screenChange "); playerUI = GlobalTools.FindObjByName("PlayerUI"); playerUI.GetComponent <PlayerUI>().skill_bar.GetComponent <UI_ShowPanel>().SaveAllHZDate(); //用来判断 地图地形 是否生成 过 如果生成过 就不用再生成了 直接根据数据生成就可以(控制 地图块内的 自动生成 粒子 草之类的) GlobalSetDate.instance.IsCMapHasCreated = false; //获取角色当前数据 当前血量 当前蓝量 发给GlobalSetDate 什么格式 以后再说 cLive=1000,cLan=1000 GlobalSetDate.instance.ScreenChangeDateRecord(); GlobalSetDate.instance.HowToInGame = GlobalSetDate.CHANGE_SCREEN; if (GlobalTools.FindObjByName("UI_Bag(Clone)/mianban1") != null) { //GlobalSetDate.instance.bagDate = GlobalTools.FindObjByName("UI_Bag(Clone)/mianban1").GetComponent<Mianban1>().HZSaveDate(); //GlobalSetDate.instance.CurrentMapMsgDate.bagDate = GlobalSetDate.instance.CurrentMapMsgDate.bagDate = GlobalSetDate.instance.bagDate; GlobalSetDate.instance.CurrentMapMsgDate.bagDate = GlobalTools.FindObjByName("UI_Bag(Clone)/mianban1").GetComponent <Mianban1>().HZSaveDate(); print("切换到新 地图时 总地图数据 " + GlobalSetDate.instance.CurrentMapMsgDate.mapDate); print("GlobalSetDate.instance.CurrentMapMsgDate.bagDate: " + GlobalSetDate.instance.CurrentMapMsgDate.bagDate); GlobalDateControl.SaveMapDate(); } //通知储存关卡变化的数据 ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.CHANGE_SCREEN, null), this); //ObjectPools.GetInstance().delAll();//解决切换场景时候特效没回收被销毁导致再取取不出来的问题 但是这样销毁会导致卡顿很长的切换速度 已用重新创建解决 SetPlayerPositionAndScreen(); //SceneManager.LoadScene("loads"); //print("*** GlobalSetDate.instance.screenName "+ GlobalSetDate.instance.screenName); StartCoroutine(IEStartLoading(GlobalSetDate.instance.screenName)); playerUI.GetComponent <PlayerUI>().GetScreenZZChange(1); //GlobalSetDate.instance.Show_UIZZ(); }
void PlotOver() { print("剧情 没有文本了!!!! 结束剧情"); //结束剧情 ClickJishiReSet(); if (IsNeedRecordByOver) { GlobalDateControl.SetMsgInCurrentGKDateAndSetInZGKDate(this.TalkID, IsNeedRecordByOver); } HuanYuanCamera(); if (_cBar) { _cBar.GetComponent <UI_talkBar>().RemoveSelf(); } if (!IsOverMoveSelf) { StartCoroutine(SetPlotFalse(0.4f, true)); return; } StartCoroutine(SetPlotFalse(0.4f)); }
// Update is called once per frame void Update() { if (isUp) { if (men && men.transform.position.y < upPos.transform.position.y) { float moveY = men.transform.position.y + moveSpeed; men.transform.position = new Vector3(men.transform.position.x, moveY, men.transform.position.z); Gensui(); } else { if (!isCanBeRecord) { return; } string zt = this.name + "-0"; ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RECORDOBJ_CHANGE, zt), this); isUp = false; if (isSaveBySelf) { GlobalDateControl.SaveMapDate(); } if (openDoorAudio) { openDoorAudio.Stop(); } _zt = "0"; } } if (isDown) { if (men && men.transform.position.y > downPos.transform.position.y) { float moveY = men.transform.position.y - moveSpeed; men.transform.position = new Vector2(men.transform.position.x, moveY); Gensui(); } else { if (!isCanBeRecord) { return; } string zt = this.name + "-1"; ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.RECORDOBJ_CHANGE, zt), this); isDown = false; if (isSaveBySelf) { GlobalDateControl.SaveMapDate(); } if (openDoorAudio) { openDoorAudio.Stop(); } _zt = "1"; } } }
void GetRecord() { if (IsGetRecordSelf) { print(" 记录自己!!!!!!!!!! " + this.transform.name); GlobalDateControl.SetMsgInCurrentGKDateAndSetInZGKDate(this.transform.name); } }
public void GetStartPlotByTimes() { print("?????? playNums: " + playNums); if (IsHitAlertControl && playNums == maxNums) { //对话完成 这里之后可以操作 if (talkBar) { talkBar.GetComponent <UI_talkBar>().RemoveSelf(); } OutHitKuaiReSet(); GetComponent <TheTimer>().TimesAdd(0.4f, TimeTalkBarCallBack2); //IsSHowTalkBar = false; playNums = 0; print(" 对话框 结束 playNums 归零 " + playNums); print("---------------------------------------------------------------------------"); if (IsStopPlayerControl) { CanControl(); } //存档 GlobalDateControl.SetMsgInCurrentGKDateAndSetInZGKDate(this.TalkID); IsPlotOver = true; return; } string str = plotList[playNums]; string txtTop = str.Split('-')[0]; _time = float.Parse(str.Split('-')[1]); switch (txtTop) { case "talk": string talkMen = str.Split('-')[2]; string talkContent = str.Split('-')[3]; GetTalk(talkContent, talkMen, _time); break; case "walk": break; } if (!IsHitAlertControl) { GetComponent <TheTimer>().TimesAdd(_time, TimeCallBack); } if (playNums < maxNums) { playNums++; } }
void OnTriggerEnter2D(Collider2D Coll) { if (GlobalDateControl.IsHasDateByName(TalkID)) { return; } if (!IsHitKuaiStop && !IsHitAlertControl && !isStarting) { return; } if (Coll.tag == "Player") { if (IsHitKuaiStop) { IsStartPlot = true; startNums = 0; playNums = 0; HitKuaiStop(); if (GlobalTools.FindObjByName("player").GetComponent <GameBody>().IsGround) { Globals.IsHitPlotKuai = true; } print("IsHitKuaiStop!!!!! 剧情开始 "); GetStartPlotByTimes(); //显示提示牌 //ShowAlertBar(); return; } //if (!IsHitAlertControl && !isStarting) //{ // //自动播放的 // isStarting = true; // playNums = 0; // //GetStart(); // GetStartPlotByTimes(); //} //else //{ // //玩家点击交互的 // playNums = 0; // //StopPlayerControl(); // if (GlobalTools.FindObjByName("player").GetComponent<GameBody>().IsGround) Globals.IsHitPlotKuai = true; // print("hitplotKuai"); // //显示提示牌 // //ShowAlertBar(); //} } }
//是否已经 播放完 读取记录判断 ***新库类 根据位置等 读取记录信息 void CheckSaveDate() { //剧情是否被播过? //GlobalSetDate.instance.TempZGuanKaStr; if (GlobalDateControl.IsHasDateByName(TalkID)) { //有记录 IsHitKuaiStop = false; } else { print("该剧情 没有 记录过!"); } }
void GetJGDateBySave() { string currentGKDate = GlobalDateControl.GetCurrentGKDate(); if (currentGKDate != "") { string[] arr = currentGKDate.Split(','); if (GlobalTools.IsHasDate(JGDate, arr)) { //有数据 JGDate = GlobalTools.GetHasDate(JGDate, arr); JGNum = int.Parse(JGDate.Split('-')[1]); } } }
//到岸 void Daoan() { if (IsStopPlot) { return; } if (!IsCloseDoor) { IsCloseDoor = true; player = GlobalTools.FindObjByName("player"); ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.OPEN_DOOR, "Men_1-1"), this); XiachuanGangqing(); } ycNums += Time.deltaTime; if (ycNums < 1) { return; } if (!IsStandUp) { if (player.GetComponent <GameBody>().GetDB().animation.lastAnimationName == "getStand_1") { IsStandUp = true; Globals.isInPlot = false; player.GetComponent <GameBody>().GetStand(); //GlobalTools.FindObjByName("PlayerUI").GetComponent<PlayerUI>().GetUIShow(); GlobalTools.FindObjByName("MainCamera").GetComponent <CameraController>().ReSetNewAddXPos(); return; } //print(" lastAnimationName " + player.GetComponent<GameBody>().GetDB().animation.lastAnimationName+" "+ player.GetComponent<GameBody>().GetDB().animation.lastAnimationState + " Globals.isInPlot " + Globals.isInPlot); if (player.GetComponent <GameBody>().GetDB().animation.lastAnimationName != "getStand_1") { player.GetComponent <GameBody>().GetDB().animation.GotoAndPlayByFrame("getStand_1"); } } //print("起始剧情结束"); GlobalDateControl.SetMsgInCurrentGKDateAndSetInZGKDate(Plot1.QISHI, false, true); }
//匹配记录的机关状态 门是开的还是关的 BOSS有没有杀掉 public void GetPiPei() { string TempCurrentGKDate = GlobalDateControl.GetCurrentGKDate().Split(':')[1]; print("*****************************************************************开始进行 当前关卡的数据匹配 TempCurrentGKDate: " + TempCurrentGKDate); if (TempCurrentGKDate == "") { return; } //开始匹配关卡数据 string[] strArr = TempCurrentGKDate.Split(','); //if (Globals.isDebug) print("匹配!!TempCurrentGKDate: "+ TempCurrentGKDate); print(" 匹配关卡记录数据------------------------ > " + strArr + " length " + strArr.Length); for (var i = 0; i < strArr.Length; i++) { print("*******************************************************************************************" + strArr[i]); if (strArr[i] == "") { continue; } string s = strArr[i].Split('-')[0]; s = GlobalTools.GetNewStrQuDiaoClone(s); //s = GlobalTools.GetNewStrQuDiaoKuohao(s); string zt = "0"; if (strArr[i].Split('-').Length > 1) { zt = strArr[i].Split('-')[1].Split('@')[0]; } string sName = s.Split('_')[0]; //print("字母头 sName: " + sName+" zt "+zt); //找名字 好像部分大小写 if (sName == "Men") { if (zt == "0") { //print("ssss "+s); GlobalTools.FindObjByName(s).GetComponent <Door>().Chushi(); } else if (zt == "1") { //print("s " + s); GlobalTools.FindObjByName(s).GetComponent <Door>().HasOpen(); } } else if (sName == "BOSS" || sName == "B") { print("匹配到 boss名字 : " + s); GameObject boss = GlobalTools.FindObjByName(s); if (boss != null) { print(">>>进来没!!!"); boss.SetActive(false); DestroyImmediate(boss, true); } } else if (sName == "WP") { //GlobalTools.FindObjByName(s).SetActive(false); if (zt == "1") { print("s ------> " + s); //生成一个 GameObject o = GlobalTools.GetGameObjectByName(s); if (o == null) { return; } string posStr = strArr[i].Split('@')[1]; Vector2 pos = new Vector2(float.Parse(posStr.Split('#')[0]), float.Parse(posStr.Split('#')[1])); o.transform.position = pos; } else { //状态=0 的时候 删除 if (GlobalTools.FindObjByName(s) != null) { GlobalTools.FindObjByName(s).GetComponent <Wupinlan>().DistorySelf(); } } } else if (sName == "G") { GameObject guai; if (GlobalDateControl.GetCGKName().Split('@').Length != 1) { print(">>1"); guai = GlobalTools.FindObjByNameInRMaps(s); } else { print(">>2"); //非生成地图 guai = GlobalTools.FindObjByName(s); } if (guai == null) { print("******************************怪物名字 " + s); guai = GlobalTools.FindObjByNameInGuais(s); GlobalTools.FindObjByName("MainCamera").GetComponent <ScreenDoorGuaiControl>().TheGuaiList.Remove(guai); if (guai) { guai.SetActive(false); } continue; } //要在 maps 里面找 print(" >////////////////////guai sname " + s + " 是否匹配到怪 " + guai); if (GuaiList.Count != 0 && guai != null) { GuaiList.Remove(guai); if (GlobalTools.FindObjByName("maps") && GlobalTools.FindObjByName("maps").GetComponent <GetReMap2>().GuaiList.Remove(guai)) { guai.SetActive(false); } else { guai.SetActive(false); } CheckGuaiDoor(); } else { guai.SetActive(false); } } else if (sName == "JG") { //机关记录 //JG_screenName-nums(数组位置) string ScreenName = strArr[i].Split('_')[1] + "_" + strArr[i].Split('_')[2].Split('-')[0]; //print("ScreenName "+ ScreenName); if (ScreenName == SceneManager.GetActiveScene().name) { JGNum = int.Parse(strArr[i].Split('-')[1]); //print("---------------------------- 匹配!!!"); } } else { print("其他记录 " + s); if (GlobalTools.FindObjByName(s) != null) { GlobalTools.FindObjByName(s).SetActive(false); } } } }
//记录数据的改变 存入全局临时变量 如果是BOSS死掉 存入文档 捡到boss装备也要自动存档 public void GKDateChange(UEvent e) { print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 关卡数据匹配 当前 关卡名 " + GlobalDateControl.GetCurrentGKDate().Split(':')[0]); string changeDate = e.eventParams.ToString(); //Men_1-1 //print(" GKDateChange 事件 "+ changeDate); string changeDateName = changeDate.Split('-')[0]; //men_1 string type = changeDateName.Split('_')[0]; //men string changezt; if (changeDate.Split('-').Length > 1) { changezt = changeDate.Split('-')[1]; } string TempCurrentGKDate = GlobalDateControl.GetCurrentGKDate().Split(':')[1]; print("临时 关卡 数据 : " + TempCurrentGKDate); if (TempCurrentGKDate == "") { TempCurrentGKDate = changeDate; print("临时 关卡 数据 没有数据的时候 TempCurrentGKDate>>>> : " + TempCurrentGKDate); } else { //print(" >>????? TempCurrentGKDate "+ TempCurrentGKDate+ " ??changeDate "+ changeDate); //men_1-0,men_2-0,boss_1-0 当前关卡数据长这样 string[] currentGKDateArr = TempCurrentGKDate.Split(','); //先查找 关卡数据中是否有该数据 有的就变化状态 没有的话就在后面加 if (!GlobalTools.IsHasDate(changeDate, currentGKDateArr)) { TempCurrentGKDate += "," + changeDate; print(" 如果 原始数据 没有新数据 直接 加载后面? 生成数据是: " + TempCurrentGKDate + " /////// 新数据: " + changeDate); //return; } else { print("如果 变化数据 原始数据中有的 话 进入这里 开始 更新 数据状态 @@@@@@"); string newGKDate = ""; for (var i = 0; i < currentGKDateArr.Length; i++) { string theGKDate = currentGKDateArr[i]; string dateName = theGKDate.Split('-')[0]; //if (Globals.isDebug) print("theGKDate > " + theGKDate); //string zt = theGKDate.Split('-')[1]; //这里 替换了 名字相同的内容 也就是替换了状态 if (dateName == changeDateName) { if (i != currentGKDateArr.Length - 1) { newGKDate += changeDate + ","; } else { newGKDate += changeDate; } } else { if (i != currentGKDateArr.Length - 1) { newGKDate += theGKDate + ","; } else { newGKDate += theGKDate; } } } TempCurrentGKDate = newGKDate; print(" 改变状态后的 数据 TempCurrentGKDate " + TempCurrentGKDate); } } //string TempGKDateStr = GuankaName + ":" + TempCurrentGKDate; string TempGKDateStr = GlobalDateControl.GetCGKName() + ":" + TempCurrentGKDate; if (TempCurrentGKDate != null) { GlobalDateControl.SetCurrentGKDateInZGKTempDate(TempGKDateStr); } print("记录数据 TempCurrentGKDate " + TempGKDateStr); //print("TempCurrentGKDate: " + TempCurrentGKDate); if (type == "boss" || type == "G" || type == "B" || type == "WP") { //将关卡数据写入全局临时数据 存档 GlobalDateControl.SaveMapDate(); } }
//启动游戏的时候 调用存档数据先 对比当前关卡数据是否有变动 //每关都要对比加到临时数据 //GameObject UI_screenChangeZZ; //public void Show_UIZZ() //{ // if (!UI_screenChangeZZ) // { // UI_screenChangeZZ = GlobalTools.GetGameObjectByName("ZZ_screenChange"); // } // UI_screenChangeZZ.GetComponent<UI_screenChangeZZ>().Show_UIZZ(); //} //public void Hide_UIZZ() //{ // if (!UI_screenChangeZZ) // { // UI_screenChangeZZ = GlobalTools.GetGameObjectByName("ZZ_screenChange"); // } // UI_screenChangeZZ.GetComponent<UI_screenChangeZZ>().Hide_UIZZ(); //} //public void ShowLoadProgressNums(float nums, bool isHasChangeScreen = false) //{ // UI_screenChangeZZ.GetComponent<UI_screenChangeZZ>().ShowLoadProgressNums(nums); //} public void GetSave() { //储存玩家所有数据 print("SAVE........."); //if (Globals.isDebug) print("save临时总关卡数据 " + TempZGuanKaStr); GameObject player = GlobalTools.FindObjByName("player"); if (player == null) { return; } if (CurrentUserDate == null) { CurrentUserDate = new UserDate(); } CurrentUserDate.curLive = player.GetComponent <RoleDate>().live.ToString(); print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@CurrentUserDate.curLive存档时血量 " + CurrentUserDate.curLive); CurrentUserDate.curLan = player.GetComponent <RoleDate>().lan.ToString(); //CurrentUserDate.screenName = SceneManager.GetActiveScene().name; CurrentUserDate.screenName = GlobalDateControl.GetCGKName(); if (HowToInGame == TEMP_SCREEN) { //print("临时进的游戏吗????"); CurrentUserDate.playerPosition = player.transform.position.x + "_" + player.transform.position.y; } else { CurrentUserDate.playerPosition = player.transform.position.x + 2 + "_" + player.transform.position.y; } //print("储存的 玩家位置 "+ CurrentUserDate.playerPosition); //存档时候 技能CD满 GlobalTools.FindObjByName("PlayerUI").GetComponent <PlayerUI>().skill_bar.GetComponent <UI_ShowPanel>().AllSkillCDFull(); CurrentUserDate.cameraPosition = GlobalTools.FindObjByName("MainCamera").transform.position.x + "_" + GlobalTools.FindObjByName("MainCamera").transform.position.y; //CurrentUserDate.mapDate = GlobalTools.FindObjByName("MainCamera").GetComponent<GameControl>().GetSaveZGKDate(); GlobalDateControl.SaveMapDate(); //print(" @@@@--- CurrentUserDate.mapDate "+ CurrentUserDate.mapDate); if (GlobalTools.FindObjByName("UI_Bag(Clone)/mianban1") != null) { CurrentUserDate.bagDate = CurrentMapMsgDate.bagDate; //GlobalTools.FindObjByName("UI_Bag(Clone)/mianban1").GetComponent<Mianban1>().HZSaveDate(); } //print(" 储存进来的徽章数据 "+ CurrentUserDate.bagDate); //血瓶数量 if (GlobalTools.FindObjByName("PlayerUI(Clone)/xueping") != null) { CurrentUserDate.xp_nums = GlobalTools.FindObjByName("PlayerUI(Clone)/xueping").GetComponent <XuePingBox>().GetXPNums(); } CurrentUserDate.userName = "******"; CurrentUserDate.onlyId = 2; ScreenChangeDateRecord(); //print(CurrentUserDate.curLan); //print(CurrentUserDate.screenName); //print(CurrentUserDate.playerPosition); //print(CurrentUserDate.cameraPosition); //print("mapdate----------------------------------------------------------------> "+CurrentUserDate.mapDate); //print(CurrentUserDate.userName); GameSaveDate.GetInstance().SaveDateByURLName(saveDateName, CurrentUserDate); //print("////////////////////////////////////////////////////////////////////////////////////////////////////////===================================记录完成!!! "); }
//判断 剧情是否 播过 bool IsPlotHasPlayed() { print(" 检测剧情是否已经播过!!!! " + TalkID); return(GlobalDateControl.IsHasDateByName(TalkID)); }