protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner) { base.OnEnter(procedureOwner); //根据绝对路径设置与获取数据 DataNodeComponent dataComponent = GameEntry.GetComponent <DataNodeComponent>(); VarString var1 = new VarString(); var1.SetValue("Ellan"); dataComponent.SetData <VarString> ("Player.Name", var1); string playerName = dataComponent.GetData <LocalVariable <string> >("Player.Name").Value; Log.Info(playerName); //根据相对路径设置与获取数据 IDataNode playerNode = dataComponent.GetNode("Player"); VarInt var2 = new VarInt(); var2.SetValue(99); dataComponent.SetData <VarInt>("Level", var2, playerNode); int playerLevel = dataComponent.GetData <VarInt>("Level", playerNode).Value; Log.Info(playerLevel); //直接通过数据结点来操作 VarInt var3 = new VarInt(); var3.SetValue(1000); IDataNode playerExpNode = playerNode.GetOrAddChild("Exp"); playerExpNode.SetData(var3); int playerExp = playerExpNode.GetData <VarInt>().Value; Log.Info(playerExp); }
//设置玩家信息 public static void SetPlayerInfo(this DataNodeComponent dataNode, PlayerInfo player) { IDataNode playerNode = dataNode.GetOrAddNode(Constant.DataNode.PlayerNode); dataNode.SetData <VarPlayerInfo>(Constant.DataNode.PlayerInfo, player, playerNode); GameEntry.Event.Fire(dataNode, new PlayerStateChangedEventArgs(player)); }
//根据配置表加载全部地点 public static void LoadAllSiteByTable(this DataNodeComponent dataNode) { IDataNode siteNode = dataNode.GetOrAddNode(Constant.DataNode.SiteList); IDataTable <DRSite> dtSite = GameEntry.DataTable.GetDataTable <DRSite>(); DRSite[] drSites = dtSite.GetAllDataRows(); foreach (DRSite drSite in drSites) { dataNode.SetData <VarSiteInfo>(drSite.Id.ToString(), new SiteInfo(drSite.Id), siteNode); } }
public static void SetGameInfo(this DataNodeComponent dataNode) { IDataNode gameNode = dataNode.GetOrAddNode(Constant.DataNode.GameNode); GameInfo gameInfo = new GameInfo() { NowSite = 1, NowTime = 0 }; dataNode.SetGameInfo(gameInfo); dataNode.SetData <VarInt>("GameTest", 99, gameNode); }
//设置Game信息 public static void SetGameInfo(this DataNodeComponent dataNode, GameInfo game) { IDataNode gameNode = dataNode.GetOrAddNode(Constant.DataNode.GameNode); dataNode.SetData <VarGameInfo>(Constant.DataNode.GameInfo, game, gameNode); }