/// <summary> /// 更新STG主线程 /// </summary> private void OnSTGMainUpdate() { // 录像状态中,检测是否进行到了录像的最后一帧 if (Global.IsInReplayMode) { if (_isReplayFinish) { return; } int curFrame = STGStageManager.GetInstance().GetFrameSinceStageStart(); if (curFrame >= ReplayManager.GetInstance().GetReplayLastFrame()) { _isReplayFinish = true; PauseGame(ePauseViewState.PauseAfterReplayFinished); return; } // 检测是否在游戏进行中按下Esc进行暂停 if (!Global.IsPause && Input.GetKeyDown(KeyCode.Escape)) { PauseGame(ePauseViewState.PauseInReplay); } else if (!Global.IsPause && !Global.IsApplicationFocus) { PauseGame(ePauseViewState.PauseInReplay); } } else { if (_isGameOver) { if (!Global.IsPause) { _gameOverTimeCounter++; if (_gameOverTimeCounter >= 30) { PauseGame(ePauseViewState.PauseAfterGameOver); return; } } } // 检测是否在游戏进行中按下Esc进行暂停 if (!Global.IsPause && Input.GetKeyDown(KeyCode.Escape)) { PauseGame(ePauseViewState.PauseInGame); } else if (!Global.IsPause && !Global.IsApplicationFocus) { PauseGame(ePauseViewState.PauseInGame); } } if (_resumeSTGSE) { _resumeSTGSE = false; SoundManager.GetInstance().ResumeAllSTGSound(); } if (!Global.IsPause) { _stgMain.Update(); } }
private void InitReplayItemInfo() { // 初始化 _infoList = new List <ReplayInfo>(); ReplayInfo info; for (int i = 0; i < MaxInfoCount; i++) { info = new ReplayInfo { replayIndex = -1, }; _infoList.Add(info); } // 读取replay的信息 List <ReplayInfo> infos = ReplayManager.GetInstance().GetReplayInfoList(); _infoCount = infos.Count; for (int i = 0; i < _infoCount; i++) { info = infos[i]; _infoList[info.replayIndex] = info; } // 更新ReplayItem的显示 for (int i = 0; i < MaxInfoCount; i++) { ReplayItem item = _itemList[i]; item.SetInfo(_infoList[i]); } }
private void OnPressKeyZ() { if (_mode == eReplayViewMode.Save) { _viewState = eViewState.EditReplayName; _itemList[_selectIndex].EditReplayName(OnEditEndCallback); } else if (_mode == eReplayViewMode.Load) { ReplayInfo info = _infoList[_selectIndex]; if (info.replayIndex != -1) { bool isSuccess = ReplayManager.GetInstance().LoadReplay(info.replayIndex); if (isSuccess) { Logger.Log("Load replay" + info.replayIndex + " success!"); SoundManager.GetInstance().Play("se_selectok", Consts.DefaultUISEVolume, false, false); } else { Logger.Log("Load replay" + info.replayIndex + " fail!"); } } } }
/// <summary> /// 疮痍之后继续游戏 /// </summary> private void OnContinueAfterGameOver() { ReplayManager.GetInstance().SetReplayEnable(false); Global.IsPause = false; _isGameOver = false; _resumeSTGSE = true; // 设置初始残机数和符卡数目 PlayerInterface.GetInstance().SetLifeCounter(Consts.STGInitLifeCount, 0); PlayerInterface.GetInstance().SetSpellCardCounter(Consts.STGInitSpellCardCount, 0); }
private void OnInitReplayUpdate() { ReplayManager.GetInstance().Init(); WaitData data = new WaitData { waitTime = 60, nextState = ePreloadState.PreloadFinish, }; SetNextState(ePreloadState.Wait, data); }
IEnumerator CreateCube() { for (int i = 0; i < number; i++) { GameObject go = ReplayManager.GetInstance("Cube", new Vector3(Random.Range(-250, 250), Random.Range(-250, 250), Random.Range(-250, 250))); go.transform.SetParent(parent.transform); ReplayManager.RegisterPrefab(go); count++; yield return(new WaitForEndOfFrame()); } }
private void GetItem(BagItem value) { //加载Item var objItem = ReplayManager.GetInstance("BagItem", Vector3.zero); objItem.SetActive(true); objItem.name = value.id.ToString(); objItem.transform.localScale = Vector3.one; objItem.transform.SetParent(BagTrigger.Instance.itemParent); ReplayManager.RegisterPrefab(objItem); }
public void OnStateEnter(object data = null) { // 添加监听 CommandManager.GetInstance().Register(CommandConsts.SelectDifficulty, this); CommandManager.GetInstance().Register(CommandConsts.SelectCharacter, this); CommandManager.GetInstance().Register(CommandConsts.LoadReplaySuccess, this); // 打开起始界面 UIManager.GetInstance().ShowView(WindowName.MainView); ReplayManager.GetInstance().Init(); CommandManager.GetInstance().RunCommand(CommandConsts.OnEnterTitle); }
private void GetTab(BagItem value, ArrayList tabArrayList) { //加载Tab var objTab = ReplayManager.GetInstance("BagTab", Vector3.zero); objTab.SetActive(true); objTab.name = value.type.ToString(); objTab.transform.localScale = Vector3.one; objTab.transform.SetParent(BagTrigger.Instance.tabParent); objTab.transform.Find("Background/Label").GetComponent <Text>().text = value.type.ToString(); objTab.GetComponent <Toggle>().group = BagTrigger.Instance.tabGroup; ReplayManager.RegisterPrefab(objTab); tabArrayList.Add(value.type); }
public override void ProcessLogic(PropertyMessage evt) { if (evt.PropertyName.Equals("prefabInfo")) { //生成预制体方式1 PrefabInfo info = (PrefabInfo)evt.NewValue; GameObject go = ReplayManager.GetInstance(info.nameOfPrefab, info.position); //方式2 //Instantiate(Resources.Load("your prefab path")); //注册预制体 ReplayManager.RegisterPrefab(go); } }
private void GetFirstTab() { //加载Tab var objTab = ReplayManager.GetInstance("BagTab", Vector3.zero); objTab.SetActive(true); objTab.name = "全部"; objTab.transform.localScale = Vector3.one; objTab.transform.SetParent(BagTrigger.Instance.tabParent); objTab.transform.Find("Background/Label").GetComponent <Text>().text = "全部"; objTab.GetComponent <Toggle>().group = BagTrigger.Instance.tabGroup; ReplayManager.RegisterPrefab(objTab); objTab.GetComponent <Toggle>().isOn = true; }
/// <summary> /// 创建一个Item /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="prefabName"></param> private void CreateItem(int id, string name, string prefabName = "MenuItem") { ProjectTrigger.Instance.menuItemDic.Add(id, name); var obj = ReplayManager.GetInstance(prefabName, Vector3.zero); obj.transform.SetParent(ProjectTrigger.Instance.contentParent); obj.GetComponent <Toggle>().group = ProjectTrigger.Instance.toggleGroup; ReplayManager.RegisterPrefab(obj); var _dataEntity = obj.GetComponent <MenuItemViewModel>().DataEntity; var _menuEntiyt = (MenuItemEntity)_dataEntity; _menuEntiyt.menuID = id; _menuEntiyt.itemName = name; }
public void InitCharacter() { _character = PlayerInterface.GetInstance().GetCharacter(); if (!Global.IsInReplayMode) { _keyList = new List <eSTGKey>(); } else { _keyList = ReplayManager.GetInstance().GetReplayKeyList(); } _lastInput = eSTGKey.None; _curInput = eSTGKey.None; }
/// <summary> /// 保存并播放replay /// </summary> private void OnSaveReplay(ReplayInfo info) { Logger.Log("Save Replay"); ReplayManager.GetInstance().SaveReplay(info.replayIndex, info.name, _stgData); CommandManager.GetInstance().RunCommand(CommandConsts.SaveReplaySuccess); // 以replay模式重新播放 //Global.IsInReplayMode = true; //_curState = StateClear; //_nextStageName = _curStageName; //// 打开loadingView //List<object> commandList = new List<object>(); //commandList.Add(CommandConsts.STGLoadStageLuaComplete); //object[] commandArr = commandList.ToArray(); //UIManager.GetInstance().ShowView(WindowName.GameLoadingView, commandArr); }
private void OnStateInitSTGUpdate() { _curState = eSTGMainState.StateWait; #if DEBUG_GAMESTATE Logger.Log("Init STG "); #endif CommandManager.GetInstance().Register(CommandConsts.STGInitComplete, this); // 添加事件监听 CommandManager.GetInstance().Register(CommandConsts.PlayerMiss, this); CommandManager.GetInstance().Register(CommandConsts.ContinueGameAfterGameOver, this); // 各种参数初始化 _isGameOver = false; Global.IsPause = false; _resumeSTGSE = false; ReplayManager.GetInstance().SetReplayEnable(true); _stgMain.InitSTG(_stgData.characterIndex); }
/// <summary> /// Execute操作 /// </summary> public override void Execute() { //回放系统需要,实例化物体,添加编号,请记住动态实例化物体的方法 newObject = ReplayManager.GetInstance("Terrain", Vector3.zero); newObject.transform.parent = GetNewPoint(); //物体坐标从数据实体(CommandDataEntity)中获得 newObject.transform.localPosition = Vector3.zero; newObject.transform.localScale = Vector3.one * 0.005f; var towerModel = newObject.GetComponent <TowerModel>(); var entity = (TowerEntity)newObject.GetComponent <TowerModel>().DataEntity; entity.towerPoint = newObject.transform.parent.name; ReplayManager.RegisterPrefab(newObject); ObjectPool <TowerModel> pool = InjectService.Get <ObjectPool <TowerModel> >(); if (!pool.objectsDic.ContainsKey(entity.objectID)) { pool.objectsDic.Add(entity.objectID, towerModel); } }
/// <summary> /// Execute操作 /// </summary> public override void Execute() { //回放系统需要,实例化物体,添加编号,请记住动态实例化物体的方法 Transform parent = GameObject.Find("Phone").transform; newObject = ReplayManager.GetInstance("Phone", Vector3.zero); ReplayManager.RegisterPrefab(newObject); newObject.transform.SetParent(parent); newObject.transform.localPosition = Position; //添加到对象池 //注册本对象到对象池中 ObjectPool <PhoneModel> pool = InjectService.Get <ObjectPool <PhoneModel> >(); var phoneModel = newObject.GetComponent <PhoneModel>(); var phoneEntity = (PhoneEntity)phoneModel.DataEntity; pool.RegisterObject(phoneModel); if (!pool.objectsDic.ContainsKey(phoneEntity.objectID)) { pool.objectsDic.Add(phoneEntity.objectID, phoneModel); } }
/// <summary> /// 界面打开时根据状态来显示不同的item /// <para>0 普通暂停</para> /// <para>1 stage all clear之后的暂停</para> /// <para>2 播放录像时的暂停</para> /// <para>3 录像播放完毕之后的暂停</para> /// </summary> /// <param name="state"></param> private void InitAvailableItems(ePauseViewState state) { _availableIndex = 0; if (state == ePauseViewState.PauseInGame) { _itemImgList[0].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgPause"); _itemImgList[1].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgReturnToGame"); _availableIndex |= 1 << 0; _availableIndex |= 1 << 1; _availableIndex |= 1 << 2; _availableIndex |= 1 << 3; _showItemCount = 4; } else if (state == ePauseViewState.PauseAfterGameClear) { _itemImgList[0].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgPause"); _itemImgList[1].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgReturnToGame"); _availableIndex |= 1 << 1; if (ReplayManager.GetInstance().IsReplayEnable()) { _availableIndex |= 1 << 2; } _availableIndex |= 1 << 3; _showItemCount = 4; } else if (state == ePauseViewState.PauseInReplay) { _itemImgList[0].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgPause"); _itemImgList[1].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgReturnToGame"); _availableIndex |= 1 << 0; _availableIndex |= 1 << 1; _availableIndex |= 1 << 3; _showItemCount = 4; } else if (state == ePauseViewState.PauseAfterReplayFinished) { _itemImgList[0].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgPause"); _itemImgList[1].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgReturnToGame"); _availableIndex |= 1 << 1; _availableIndex |= 1 << 3; _showItemCount = 4; } else if (state == ePauseViewState.PauseAfterGameOver) { _itemImgList[0].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgGameOver"); _itemImgList[1].sprite = ResourceManager.GetInstance().GetSprite("STGPauseViewAtlas", "ImgContinue"); _availableIndex |= 1 << 0; _availableIndex |= 1 << 1; if (ReplayManager.GetInstance().IsReplayEnable()) { _availableIndex |= 1 << 2; } _availableIndex |= 1 << 3; _showItemCount = 4; } _availableList = new List <int>(); Image img; RectTransform tf; for (int i = 0; i < _showItemCount; i++) { tf = _selectItems[i].GetComponent <RectTransform>(); img = tf.GetComponent <Image>(); tf.anchoredPosition = new Vector2(2000, 2000); if ((_availableIndex & (1 << i)) != 0) { img.color = new Color(1, 1, 1, 1); _availableList.Add(i); } else { img.color = new Color(1, 1, 1, 0.3f); } } _availableCount = _availableList.Count; }