public void ConstructScene(MatchLogResponseParameter param) { BattleRandomer.Instance.SetSeed(param.RandomSeed); for (int i = 0; i < param.DropArmyCommands.Count; i++) { DropArmyResponseParameter army = param.DropArmyCommands[i]; this.m_DropCommands.Enqueue(army); } for (int i = 0; i < param.DropMercenaryCommands.Count; i++) { DropMercenaryResponseParameter mercenary = param.DropMercenaryCommands[i]; this.m_DropMercenaryCommands.Enqueue(mercenary); } for (int i = 0; i < param.UsePropsCommands.Count; i++) { UsePropsResponseParameter props = param.UsePropsCommands[i]; this.m_UsePropsCommands.Enqueue(props); } BattleSceneHelper.Instance.ClearObject(); this.m_SceneDirector.ClearAllActors(); Resources.UnloadUnusedAssets(); this.m_BuildingFactory.ConstructBuilding(param.RivalInformation); this.m_Map.SetMap(this.CurrentAge); BattleMapData.Instance.ConstructGridArray(); this.m_SceneDirector.GenerateActors(); BattleRecorder.Instance.ClearRecords(); }
void FixedUpdate() { if (this.m_IsReceivedInformation) { this.m_ReplayStartTick = TimeTickRecorder.Instance.CurrentTimeTick; this.m_IsReceivedInformation = false; this.m_SceneDirector.SendRunAway(); BattleSceneHelper.Instance.EnableBuildingAI(); this.m_IsReplayStart = true; } if (this.m_IsReplayStart) { int currentTick = TimeTickRecorder.Instance.CurrentTimeTick - this.m_ReplayStartTick; if (this.m_DropCommands.Count > 0) { while (this.m_DropCommands.Count > 0 && currentTick >= this.m_DropCommands.Peek().OperateTime) { DropArmyResponseParameter army = this.m_DropCommands.Dequeue(); this.m_CharacterFactory.ConstructArmy(army.ArmyType, army.Level, new Vector3(army.PositionX, army.PositionY, 0)); } } if (this.m_DropMercenaryCommands.Count > 0) { while (this.m_DropMercenaryCommands.Count > 0 && currentTick >= this.m_DropMercenaryCommands.Peek().OperateTime) { DropMercenaryResponseParameter mercenary = this.m_DropMercenaryCommands.Dequeue(); this.m_CharacterFactory.ConstructMercenary(mercenary.MercenaryType, new Vector3(mercenary.PositionX, mercenary.PositionY, 0)); } } if (this.m_UsePropsCommands.Count > 0) { while (this.m_UsePropsCommands.Count > 0 && currentTick >= this.m_UsePropsCommands.Peek().OperateTime) { UsePropsResponseParameter props = this.m_UsePropsCommands.Dequeue(); this.m_CharacterFactory.UseProps(props.PropsType, new Vector3(props.PositionX, props.PositionY, 0)); } } if (currentTick > this.m_TotalReplayTick) { this.ReplayOver(); } } }
void FixedUpdate() { if (this.m_IsCGStart) { int currentTick = TimeTickRecorder.Instance.CurrentTimeTick - this.m_CGStartTick; if (this.m_DropCommands.Count > 0) { while (this.m_DropCommands.Count > 0 && currentTick >= this.m_DropCommands.Peek().OperateTime) { DropArmyResponseParameter army = this.m_DropCommands.Dequeue(); this.m_CharacterFactory.ConstructArmy(army.ArmyType, army.Level, new Vector3(army.PositionX, army.PositionY, 0)); } } if (this.m_DropMercenaryCommands.Count > 0) { while (this.m_DropMercenaryCommands.Count > 0 && currentTick >= this.m_DropMercenaryCommands.Peek().OperateTime) { DropMercenaryResponseParameter mercenary = this.m_DropMercenaryCommands.Dequeue(); this.m_CharacterFactory.ConstructMercenary(mercenary.MercenaryType, new Vector3(mercenary.PositionX, mercenary.PositionY, 0)); } } if (this.m_UsePropsCommands.Count > 0) { while (this.m_UsePropsCommands.Count > 0 && currentTick >= this.m_UsePropsCommands.Peek().OperateTime) { UsePropsResponseParameter props = this.m_UsePropsCommands.Dequeue(); this.m_CharacterFactory.UseProps(props.PropsType, new Vector3(props.PositionX, props.PositionY, 0)); } } if (currentTick > this.m_TotalCGTick) { this.CGOver(); } } }
public MatchLogResponseParameter GetReplayData() { MatchLogResponseParameter result = new MatchLogResponseParameter(); result.RandomSeed = 0; result.RivalInformation = DataConvertor.ConvertJSONToParameter((Hashtable)(JSONHelper.jsonDecode(this.GetMapInformation()))); Hashtable battleInfo = (Hashtable)JSONHelper.jsonDecode(this.GetBattleInformation()); result.TotalTime = Convert.ToInt32(battleInfo[EditorConfigInterface.Instance.BattleTimeKey]); result.DropArmyCommands = new List <DropArmyResponseParameter>(); result.DropMercenaryCommands = new List <DropMercenaryResponseParameter>(); result.UsePropsCommands = new List <UsePropsResponseParameter>(); if (battleInfo.ContainsKey(EditorConfigInterface.Instance.BattleArmyKey)) { ArrayList dropArmies = (ArrayList)battleInfo[EditorConfigInterface.Instance.BattleArmyKey]; foreach (var army in dropArmies) { DropArmyResponseParameter param = new DropArmyResponseParameter(); Hashtable a = (Hashtable)army; param.ArmyType = (ArmyType)(Convert.ToInt32(a[EditorConfigInterface.Instance.DropTypeKey])); param.Level = Convert.ToInt32(a[EditorConfigInterface.Instance.ArmyLevelKey]); param.PositionX = float.Parse(a[EditorConfigInterface.Instance.DropPositionXKey].ToString()); param.PositionY = float.Parse(a[EditorConfigInterface.Instance.DropPositionYKey].ToString()); param.OperateTime = Convert.ToInt32(a[EditorConfigInterface.Instance.DropTimeKey]); result.DropArmyCommands.Add(param); } } if (battleInfo.ContainsKey(EditorConfigInterface.Instance.BattleMercenaryKey)) { ArrayList dropMercenaries = (ArrayList)battleInfo[EditorConfigInterface.Instance.BattleMercenaryKey]; foreach (var mercenary in dropMercenaries) { DropMercenaryResponseParameter param = new DropMercenaryResponseParameter(); Hashtable a = (Hashtable)mercenary; param.MercenaryType = (MercenaryType)(Convert.ToInt32(a[EditorConfigInterface.Instance.DropTypeKey])); param.PositionX = float.Parse(a[EditorConfigInterface.Instance.DropPositionXKey].ToString()); param.PositionY = float.Parse(a[EditorConfigInterface.Instance.DropPositionYKey].ToString()); param.OperateTime = Convert.ToInt32(a[EditorConfigInterface.Instance.DropTimeKey]); result.DropMercenaryCommands.Add(param); } } if (battleInfo.ContainsKey(EditorConfigInterface.Instance.BattlePropsKey)) { ArrayList useProps = (ArrayList)battleInfo[EditorConfigInterface.Instance.BattlePropsKey]; foreach (var props in useProps) { UsePropsResponseParameter param = new UsePropsResponseParameter(); Hashtable p = (Hashtable)props; param.PropsType = (PropsType)(Convert.ToInt32(p[EditorConfigInterface.Instance.DropTypeKey])); param.PositionX = float.Parse(p[EditorConfigInterface.Instance.DropPositionXKey].ToString()); param.PositionY = float.Parse(p[EditorConfigInterface.Instance.DropPositionYKey].ToString()); param.OperateTime = Convert.ToInt32(p[EditorConfigInterface.Instance.DropTimeKey]); result.UsePropsCommands.Add(param); } } return(result); }