/// <summary> /// 初始化数据对象 /// </summary> private void InitDataTarget() { keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); iGameState = GameState.Instance.GetEntity <IGameState>(); iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); iInteractiveState = GameState.Instance.GetEntity <IInteractiveState>(); }
/// <summary> /// 初始化数据对象 /// </summary> private void InitDataTarget() { keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>(); iSkillState = GameState.Instance.GetEntity <ISkillState>(); iGameState = GameState.Instance.GetEntity <IGameState>(); iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); }
// Use this for initialization void Start() { List <Archive> allArchives = DataCenter.Instance.GetAllArchive(); //不存在id为1的存档就来一份吧~ if (allArchives.All(a => a.ID != 1)) { DataCenter.Instance.Save(1, "firstTest", "testIntro"); } //加载存档1 DataCenter.Instance.LoadArchive(1); //测试任务 MetaTasksData metaTaskDataSystem = DataCenter.Instance.GetMetaData <MetaTasksData>(); RuntimeTasksData runtimeTaskData = DataCenter.Instance.GetEntity <RuntimeTasksData>(); List <RunTimeTaskInfo> allCanDotask = runtimeTaskData.GetAllToDoList(); RunTimeTaskInfo firstTask = allCanDotask[0]; //根据runtimetask的id去metaTask里拿Task的所有信息 MetaTaskInfo firstTaskMetaInfo = metaTaskDataSystem[firstTask.ID]; Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskLocation); Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskTitile); Debug.Log(firstTaskMetaInfo.MetaTaskNode.TaskType); //******任务具体逻辑************ //任务完成 firstTask.IsOver = true; //获取新任务继续 var newTaskList = runtimeTaskData.GetAllToDoList(); //获取按键数据 KeyContactData keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); keyContactData.SetKeyContactStruct(1, new KeyContactStruct() { id = 1, key = 2, keyContactType = EnumKeyContactType.Action }); var keyDataStructs = keyContactData.GetKeyContactStruct(1); //获取 PlayerState PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>(); playerState.Agility = 1; playerState.Level = 20; //写入数据 DataCenter.Instance.Save(2, "test2", "test2"); Debug.Log("存档成功"); }
void Start() { keyImage = GetComponent <Image>(); keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); playerState = DataCenter.Instance.GetEntity <PlayerState>(); skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>(); iSkillState = GameState.Instance.GetEntity <ISkillState>(); iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); Show(); }
public DataCenter() { PlayerState = new PlayerState(); KeyConatactData = new KeyContactData(); RuntimeTasks = new RuntimeTasksData(); gameRunnedState = new GameRunnedState(); RuntimeTaskMap = new TaskMap.RunTimeTaskData(); BusinessmanStates = new BusinessmanStates(); GameRunningStaetData = new GameRunningStateData(); ActionInteractiveStateData = new ActionInteractiveStateData(); SceneStateDatas = new SceneStateDatas(); }
/// <summary> /// 当显示时初始化按键数据 /// </summary> private void OnEnable() { playerState = DataCenter.Instance.GetEntity <PlayerState>(); keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>(); selectTargetPanel.gameObject.SetActive(false); UIManager.Instance.KeyUpHandle += Instance_KeyUpHandle; enumKeySettingType = EnumKeySettingType.Lattice; if (keySettingFocusPath) { nowKeySettingLattice = keySettingFocusPath.GetFirstFocus() as UIFocusKeySettingLattice; if (nowKeySettingLattice) { nowKeySettingLattice.SetForcus(); } //初始化显示 UIFocus[] uiKeySettingLatticeArray = keySettingFocusPath.NewUIFocusArray;// keySettingFocusPath.UIFocuesArray; foreach (UIFocus item in uiKeySettingLatticeArray) { if (!item) { continue; } UIFocusKeySettingLattice uiKeySettingLattice = item as UIFocusKeySettingLattice; int inputKey = uiKeySettingLattice.GetKeySettingInput();//输入的按键值 if (uiKeySettingLattice) { KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(inputKey); if (keyContactStructs.Length > 0) { uiKeySettingLattice.keyLatticeType = keyContactStructs[0].keyContactType; uiKeySettingLattice.id = keyContactStructs[0].id; } else { uiKeySettingLattice.keyLatticeType = EnumKeyContactType.None; uiKeySettingLattice.id = 0; } //初始化显示 uiKeySettingLattice.InitShow(); } } } }
/// <summary> /// 新游戏按钮按下事件 /// </summary> public void NewGameButtonClick() { if (isLoadedScene || entranceType != EnumEntranceType.Start) { return; } //切换场景 nowStartFocus = EventSystem.current.currentSelectedGameObject.GetComponent <UIFocus>(); List <Archive> archiveList = DataCenter.Instance.GetAllArchive();//获取所有存档名 Archive defaultArchive = archiveList.FirstOrDefault(temp => temp.ID == 1); if (defaultArchive == null) { DataCenter.Instance.Save(1, "存档", "默认存档"); DataCenter.Instance.LoadArchive(1); //设置默认数据 //设置默认的按键 1:1_183 KeyContactData keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); //设置采集键 Sprite collectSprite = SpriteManager.GetSrpite("1:1_183"); keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { keyContactType = EnumKeyContactType.Action, name = "采集", Sprite = collectSprite, id = 1 }, EnumKeyContactDataZone.Collect); //设置对话键 Sprite talkSprite = SpriteManager.GetSrpite("1:1_165"); keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { keyContactType = EnumKeyContactType.Action, name = "交谈", Sprite = talkSprite, id = 2 }, EnumKeyContactDataZone.Dialogue); //设置功能键 Sprite actionSprite = SpriteManager.GetSrpite("1:1_183"); keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { keyContactType = EnumKeyContactType.Action, name = "交互", Sprite = actionSprite, id = 3 }, EnumKeyContactDataZone.Action); //设置默认的等级 PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>(); playerState.Level = 1; playerState.Experience = 0; playerState.RoleOfRaceRoute = new List <RoleOfRace>(); //再次保存 DataCenter.Instance.Save(1, "存档", "默认存档"); #region 测试用添加的数据 /*测试代码*/ //添加技能点 EnumSkillType[] enumSkillTypes = Enum.GetValues(typeof(EnumSkillType)).OfType <EnumSkillType>().Where(temp => (temp <EnumSkillType.MagicCombinedLevel1End && temp> EnumSkillType.MagicCombinedLevel1Start) || (temp <EnumSkillType.MagicCombinedLevel2End && temp> EnumSkillType.MagicCombinedLevel2Start) || (temp <EnumSkillType.MagicCombinedLevel3End && temp> EnumSkillType.MagicCombinedLevel3Start) || (temp <EnumSkillType.MagicCombinedLevel4End && temp> EnumSkillType.MagicCombinedLevel4Start) ).ToArray(); enumSkillTypes = Enum.GetValues(typeof(EnumSkillType)).OfType <EnumSkillType>().Distinct().ToArray();//所有技能加1 foreach (var item in enumSkillTypes) { playerState.SkillPoint.Add(item, 1); } //playerState.SkillPoint.Add(EnumSkillType.MagicRelease, 1); playerState.FreedomPoint = 2; //添加按键 keyContactData = DataCenter.Instance.GetEntity <KeyContactData>(); keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { id = 199, key = (int)EnumInputType.A, keyContactType = EnumKeyContactType.Skill, name = "释放魔法" }); keyContactData.SetKeyContactStruct((int)EnumInputType.Up, new KeyContactStruct() { id = 1001, key = (int)EnumInputType.Up, keyContactType = EnumKeyContactType.Skill, name = "奥术弹" }); keyContactData.SetKeyContactStruct((int)EnumInputType.Right, new KeyContactStruct() { id = 1101, key = (int)EnumInputType.Right, keyContactType = EnumKeyContactType.Skill, name = "火元素" }); keyContactData.SetKeyContactStruct((int)EnumInputType.Left, new KeyContactStruct() { id = 1004, key = (int)EnumInputType.Left, keyContactType = EnumKeyContactType.Skill, name = "魔力导向" }); keyContactData.SetKeyContactStruct((int)EnumInputType.Down, new KeyContactStruct() { id = 1201, key = (int)EnumInputType.Down, keyContactType = EnumKeyContactType.Skill, name = "连续魔力导向" }); keyContactData.SetKeyContactStruct((int)EnumInputType.X, new KeyContactStruct() { id = 201, key = (int)EnumInputType.X, keyContactType = EnumKeyContactType.Skill, name = "普通攻击" }); keyContactData.SetKeyContactStruct((int)EnumInputType.Y, new KeyContactStruct() { id = (int)EnumSkillType.JAS03, /*key = (int)EnumInputType.Y,*/ keyContactType = EnumKeyContactType.Skill, name = "燕返" }); keyContactData.SetKeyContactStruct((int)EnumInputType.B, new KeyContactStruct() { id = (int)EnumSkillType.ZS03, keyContactType = EnumKeyContactType.Skill, name = "冲锋" }); int key = (int)(EnumInputType.A | EnumInputType.LB); keyContactData.SetKeyContactStruct(key, new KeyContactStruct() { id = (int)EnumSkillType.KZS03, key = key, keyContactType = EnumKeyContactType.Skill, name = "战吼" }); //添加装备 //int playGoodsID = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity<GameRunnedState>()); //Goods goods = new Goods(EnumGoodsType.XJJ, "测试武器", 1, 10, "123"); //goods.goodsAbilities.Add(new GoodsAbility() { AbilibityKind = EnumGoodsAbility.ASPD, Value = 10 }); //goods.SpriteName = "1:1_226"; //PlayGoods playGoods = new PlayGoods(playGoodsID, goods, GoodsLocation.Package); //playerState.PlayerAllGoods.Add(playGoods); //playerState.Sprice = 10000; /*****测试代码结束*****/ #endregion //隐藏该面板显示创建面板的种族选择面板 entranceType = EnumEntranceType.Transition; StartCoroutine(CrossoverMaskImageAlpha(1, () => { startRect.gameObject.SetActive(false); createRect.gameObject.SetActive(true); roleOfRaceRect.gameObject.SetActive(true); nameInputRect.gameObject.SetActive(false); StartCoroutine(CrossoverMaskImageAlpha(0, () => { entranceType = EnumEntranceType.Create_SelectRoleOfRace; InitCreateSelectRoleOfRace(); })); })); #region 老版的直接加载 //DataCenter.Instance.Save(1, "存档", "默认存档"); //DataCenter.Instance.LoadArchive(1); ////设置默认数据 ////设置默认的按键 1:1_183 //KeyContactData keyContactData = DataCenter.Instance.GetEntity<KeyContactData>(); ////设置采集键 //Sprite collectSprite = SpriteManager.GetSrpite("1:1_183"); //keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { keyContactType = EnumKeyContactType.Action, name = "采集", Sprite = collectSprite, id = 1 }, EnumKeyContactDataZone.Collect); ////设置对话键 //Sprite talkSprite = SpriteManager.GetSrpite("1:1_165"); //keyContactData.SetKeyContactStruct((int)EnumInputType.A, new KeyContactStruct() { keyContactType = EnumKeyContactType.Action, name = "交谈", Sprite = talkSprite, id = 2 }, EnumKeyContactDataZone.Dialogue); ////设置默认的等级 //PlayerState playerState = DataCenter.Instance.GetEntity<PlayerState>(); //playerState.Level = 1; //playerState.Experience = 0; //playerState.RoleOfRaceRoute = RoleOfRaceHelper.GetAllEvolvePath(RoleOfRace.Human).FirstOrDefault(); ////再次保存 //DataCenter.Instance.Save(1, "存档", "默认存档"); ////获取数据并切换场景 //GetArchiveData(); #endregion } }