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); }
//根据ID获取地点信息 public static SiteInfo GetSiteById(this DataNodeComponent dataNode, int siteId) { IDataNode siteNode = dataNode.GetNode(Constant.DataNode.SiteList); if (siteNode == null) { dataNode.LoadAllSiteByTable(); siteNode = dataNode.GetNode(Constant.DataNode.SiteList); } return(dataNode.GetData <VarSiteInfo>(siteId.ToString(), siteNode)); }
//获取玩家信息 public static PlayerInfo GetPlayerInfo(this DataNodeComponent dataNode) { IDataNode playerNode = dataNode.GetNode(Constant.DataNode.PlayerNode); if (playerNode == null) { Log.Error("Player Node is empty"); return(null); } PlayerInfo playerInfo = dataNode.GetData <VarPlayerInfo>(Constant.DataNode.PlayerInfo, playerNode); if (playerInfo == null) { Log.Error("Player Info is empty"); return(null); } return(playerInfo); }
//获取Game信息 public static GameInfo GetGameInfo(this DataNodeComponent dataNode) { IDataNode gameNode = dataNode.GetNode(Constant.DataNode.GameNode); if (gameNode == null) { Log.Error("gameNode data is empty"); return(null); } GameInfo gameInfo = dataNode.GetData <VarGameInfo>(Constant.DataNode.GameInfo, gameNode); if (gameInfo == null) { Log.Error("playerInfo data is empty"); return(null); } return(gameInfo); }