public void Verify(string fileName) { Logger logger = Service.Logger; logger.Debug("Using data path: " + fileName); string text = FileUtils.Read(FileUtils.GetAbsFilePathInMyDocuments(fileName, "/src/maps")); logger.Debug("Read json: " + text); CombatEncounter data = this.Deserialize(text); logger.Debug("De-serialized json to model..."); string text2 = this.Serialize(data); logger.Debug("Serialized model to json..."); FileUtils.Write(FileUtils.GetAbsFilePathInMyDocuments(fileName, "/src/maps"), text2); logger.Debug("Saved json: " + text2); text = text.Replace(" ", string.Empty).Trim(); text2 = text2.Replace(" ", string.Empty).Trim(); if (text.Equals(text2)) { logger.Debug("Verification passed"); return; } logger.Debug(text); logger.Debug(text2); logger.Debug("Verification failed"); }
private void OnRoundStarted(CombatEncounter combat) { foreach (var item in Items.Where(i => !i.IsEmpty)) { item.TickCooldown(); } }
private void OnAnyCombatTeamTurnStarted(CombatEncounter combat) { if (!gameObject.IsVisible() || combat.ActingTeamId != gameObject.GetComponent <UnitComponent>().TeamId) { return; } if (!this.isTicked) { this.isTicked = true; return; } this.counter -= 1; if (this.counter > 0) { return; } var health = GetComponent <HealthComponent>(); if (health.IsAlive) { health.Kill(gameObject); } }
public CombatEncounter GetCurrentCombatEncounter() { CombatEncounter combatEncounter = new CombatEncounter(); combatEncounter.map = new Map(); combatEncounter.map.Buildings = new List <Building>(); BoardController boardController = Service.BoardController; Board board = boardController.Board; LinkedList <BoardItem> children = board.Children; if (children != null) { foreach (BoardItem current in children) { BoardCell currentCell = current.CurrentCell; Entity data = current.Data; BuildingComponent buildingComponent = data.Get <BuildingComponent>(); if (buildingComponent != null) { Building building = new Building(); building.Key = buildingComponent.BuildingTO.Key; building.Uid = buildingComponent.BuildingType.Uid; building.X = Units.BoardToGridX(currentCell.X); building.Z = Units.BoardToGridZ(currentCell.Z); building.CurrentStorage = buildingComponent.BuildingTO.CurrentStorage; combatEncounter.map.Buildings.Add(building); } } } combatEncounter.map.Planet = Service.CurrentPlayer.Map.Planet; return(combatEncounter); }
// Use this for initialization void Start() { GameObject combatManager = new GameObject(); combatManager.AddComponent <CombatManager> (); CombatEncounter ce = new CombatEncounter(); ce.testInit(); }
public void LoadMeta(BattleTypeVO battle) { string json = FileUtils.Read(FileUtils.GetAbsFilePathInMyDocuments(battle.AssetName + ".json", "/src/starts-game-assets/develop/battles")); object obj = new JsonParser(json).Parse(); CombatEncounter combatEncounter = new CombatEncounter().FromObject(obj) as CombatEncounter; Service.CurrentPlayer.Map = combatEncounter.map; Service.WorldTransitioner.SetSkipTransitions(true); Service.WorldInitializer.PrepareWorld(combatEncounter.map); Service.EditBaseController.Enable(true); }
public void Load(string fileName) { string json = FileUtils.Read(FileUtils.GetAbsFilePathInMyDocuments(fileName, "/src/maps")); object obj = new JsonParser(json).Parse(); CombatEncounter combatEncounter = new CombatEncounter().FromObject(obj) as CombatEncounter; Service.CurrentPlayer.Map = combatEncounter.map; Service.WorldTransitioner.SetSkipTransitions(true); Service.WorldInitializer.PrepareWorld(combatEncounter.map); Service.EditBaseController.Enable(false); Service.EditBaseController.Enable(true); }
private void OnBattleFileLoaded(object asset, object cookie) { object obj = new JsonParser(asset as string).Parse(); CombatEncounter combatEncounter = new CombatEncounter().FromObject(obj) as CombatEncounter; this.UnloadAsset(); if (!string.IsNullOrEmpty(this.battle.Planet)) { combatEncounter.map.Planet = Service.Get <IDataController>().Get <PlanetVO>(this.battle.Planet); } if (this.onMapLoaded != null) { this.onMapLoaded(combatEncounter.map); } }
private void OnAnyCombatTeamTurnStarted(CombatEncounter combat) { if (combat.ActingTeamId != gameObject.GetComponent <UnitComponent>().TeamId) { return; } foreach (var behaviour in Behaviours.OrderBy(b => b.IsHarmful).ToList()) { behaviour.MaybeExpire(); if (behaviour.IsApplied) { behaviour.Tick(); } } }
public void Save(string fileName) { StaticDataController staticDataController = Service.StaticDataController; CombatEncounter currentCombatEncounter = this.GetCurrentCombatEncounter(); List <Building> buildings = currentCombatEncounter.map.Buildings; int i = 0; int count = buildings.Count; while (i < count) { buildings[i].Key = "bld_" + (i + 1); if (staticDataController.Get <BuildingTypeVO>(buildings[i].Uid).Type == BuildingType.Trap) { buildings[i].CurrentStorage = 1; } i++; } string text = this.Serialize(currentCombatEncounter); FileUtils.Write(FileUtils.GetAbsFilePathInMyDocuments(fileName, "/src/maps"), text); Service.Logger.Debug("Json Saved: " + text); }
public string Serialize(CombatEncounter data) { return(data.ToJson()); }
private void OnAnyCombatRoundStarted(CombatEncounter combat) { Restore(ResourceType.ActionPoint); }
private void OnRoundStarted(CombatEncounter arg) { LastUsedSkillThisRound = null; }
private void OnCombatEnded(CombatEncounter combat) { Combat = null; }
private void OnAnyCombatStarted(CombatEncounter combat) { this.enabled = true; Context.Combat = combat; }
public void CreateCombatEncounter(UnitView attacker, List <UnitView> defenders) { CombatEncounter combatEncounter = new CombatEncounter(attacker, defenders); combatEncounters.Add(combatEncounter); }
private void PopulateEncounterTargets( CombatEncounter encounter ) { encounter.Sort(); // this sort used to take a long time ListViewItem viewItem = null; this.activeAnalyzer = null; targetListView.Items.Clear(); foreach( CombatTarget target in encounter.Entities ) { if( this.grpSelf.IsChecked == true ) { if( !target.Entity.Id.IsPlayer && !(target.Entity.Parent != null && target.Entity.Parent.Id.IsPlayer) ) continue; } else if( this.grpGroup.IsChecked == true ) { if( !target.Entity.Id.IsPlayer && !target.Entity.Id.IsGroup ) continue; } else if( this.grpRaid.IsChecked == true ) { if( !target.Entity.Id.IsPlayer && !target.Entity.Id.IsRaid ) continue; } ListViewItem item = new ListViewItem(); item.Content = target.Analyzer; if( target.Entity.Id.IsPlayer || (target.Entity.Parent != null && target.Entity.Parent.Id.IsPlayer) ) item.Background = Brushes.Yellow; else if( target.Entity.Id.IsGroup ) item.Background = Brushes.LimeGreen; else if( target.Entity.Id.IsRaid ) item.Background = Brushes.LightGreen; if( target.Entity.Id.IsPlayer ) viewItem = item; targetListView.Items.Add( item ); } if( viewItem != null ) { this.targetListView.ScrollIntoView( viewItem ); viewItem.IsSelected = true; } }
private void OnRoundStarted(CombatEncounter combat) { this.rounds++; }
public void ParseLine( string line ) { try { if( string.IsNullOrEmpty( line ) ) return; if( line.Trim() == string.Empty ) return; // Regex expressions are slow, so we parse the // old-fashioned way. It's about 4x faster. string timeStampText = line.Substring( 0, 8 ); DateTime timeStamp = DateTime.ParseExact( timeStampText, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture ); // If timestamp wraps around, increase day number if( timeStamp < previousTimestamp ) { this.dayBump++; } this.previousTimestamp = timeStamp; timeStamp = timeStamp.AddDays( dayBump ); // Delineate the events between "Combat Begin" and "Combat End" // as "encounters." Within each encounter, we list all participants. // Not perfect, but not sure how else to do it. if( line.EndsWith( "Combat Begin" ) ) { this.currentEncounter = new CombatEncounter(); this.currentEncounter.TimeStamp = timeStamp; this.encounters.Add( this.currentEncounter ); } else if( line.EndsWith( "Combat End" ) ) { if( this.currentEncounter != null ) { // Analyze the encounter foreach( CombatTarget target in currentEncounter.Entities ) target.Analyzer.Calculate(); if( this.EncounterEnded != null ) this.EncounterEnded( this, new EncounterEndedArgs() { Encounter = currentEncounter } ); } this.currentEncounter = null; } // First split the line into parts, breaking on commas. string[] parts = line.Split( ',' ); if( parts.Length != 10 ) { // Should only be special cases "Combat Begin" or "Combat End" return; } // We now have an array that looks something like this: // [0] 00:37:43: ( 5 // [1] T=N#R=O#9223372041015909532 // [2] T=N#R=O#9223372041015909532 // [3] T=X#R=X#0 // [4] T=X#R=X#0 // [5] Corrupted Knight // [6] Corrupted Knight // [7] 0 // [8] 458094657 // [9] Soul Sickness ) Corrupted Knight's Soul Sickness heals Corrupted Knight for 0. // Sub-parse the first and last parts string categoryText = parts[0].Substring( 11 ).Trim(); int parenIndex = parts[9].IndexOf( ')' ); string abilityName = parts[9].Substring( 0, parenIndex - 1 ).Trim(); string logMessage = parts[9].Substring( parenIndex + 1 ).Trim(); // Fill in a log entry object CombatLogEntry entry = new CombatLogEntry(); entry.TimeStamp = timeStamp; entry.Category = int.Parse( categoryText ); entry.SourceId = new CombatId( parts[1].Trim() ); entry.TargetId = new CombatId( parts[2].Trim() ); entry.SourceParentId = new CombatId( parts[3].Trim() ); entry.TargetParentId = new CombatId( parts[4].Trim() ); entry.SourceName = parts[5].Trim(); entry.TargetName = parts[6].Trim(); entry.Damage = int.Parse( parts[7].Trim() ); // We don't do anything with the ability ID (parts[8]) entry.AbilityName = abilityName; entry.Message = logMessage; // Skip resurrects "Ekosan's Soul Walk heals Ekosan for 410." if( entry.IsHeal && entry.AbilityName == "Soul Walk" ) return; // Skip 'Weathered' whatever that is - "Smashy's Weathered heals Smashy for 558. (17 overheal)" if( entry.IsHeal && entry.AbilityName == "Weathered" ) return; if( entry.SourceName == string.Empty || entry.SourceName == "Unknown" ) return; if( entry.TargetName == string.Empty || entry.TargetName == "Unknown" ) return; if( logMessage.IndexOf( "Physical damage" ) >= 0 ) entry.DamageType = "Physical"; else if( logMessage.IndexOf( "Air damage" ) >= 0 ) entry.DamageType = "Air"; else if( logMessage.IndexOf( "Water damage" ) >= 0 ) entry.DamageType = "Water"; else if( logMessage.IndexOf( "Fire damage" ) >= 0 ) entry.DamageType = "Fire"; else if( logMessage.IndexOf( "Death damage" ) >= 0 ) entry.DamageType = "Death"; else if( logMessage.IndexOf( "Life damage" ) >= 0 ) entry.DamageType = "Life"; else if( logMessage.IndexOf( "Earth damage" ) >= 0 ) entry.DamageType = "Earth"; //if( entry.IsInformation ) return; Match m; // Collect information from the log message itself. // Test for existence of keywords before doing the regex. // It's much, much faster. if( logMessage.IndexOf( "absorbed)" ) >= 0 ) { m = Regex.Match( logMessage, @"\((\d+) absorbed\)" ); if( m.Success ) entry.Absorbed = int.Parse( m.Groups[1].Value ); } if( logMessage.IndexOf( "blocked)" ) >= 0 ) { m = Regex.Match( logMessage, @"\((\d+) blocked\)" ); if( m.Success ) entry.Blocked = int.Parse( m.Groups[1].Value ); } if( logMessage.IndexOf( "overkill)" ) >= 0 ) { m = Regex.Match( logMessage, @"\((\d+) overkill\)" ); if( m.Success ) entry.Overkill = int.Parse( m.Groups[1].Value ); } if( logMessage.IndexOf( "overheal)" ) >= 0 ) { m = Regex.Match( logMessage, @"\((\d+) overheal\)" ); if( m.Success ) entry.Overheal = int.Parse( m.Groups[1].Value ); } // Record the source and target entities. if( this.currentEncounter != null ) { // Add this log message into the current encounter. this.currentEncounter.Log.Add( entry ); this.allEncounter.Log.Add( entry ); } CombatEntity sourceEntity = this.CountEntity( entry.SourceId, entry.SourceName, entry.SourceParentId ); if( sourceEntity != null ) { if( sourceEntity.Class == null ) sourceEntity.Class = entry.SourceClass; if( entry.IsHit ) sourceEntity.TotalDamage += entry.Damage; if( entry.IsHeal ) sourceEntity.TotalHealing += entry.Damage; sourceEntity.Analyzer.Log.Add( entry ); if( this.currentEncounter != null ) { // Record source as a participant in current encounter if( !this.currentEncounter.ContainsEntity( sourceEntity ) ) this.currentEncounter.AddEntity( sourceEntity ); if( !this.allEncounter.ContainsEntity( sourceEntity ) ) this.allEncounter.AddEntity( sourceEntity ); } } if( entry.TargetId != entry.SourceId ) { CombatEntity targetEntity = this.CountEntity( entry.TargetId, entry.TargetName, entry.TargetParentId ); if( sourceEntity != null && targetEntity != null ) { targetEntity.Analyzer.Log.Add( entry ); CombatTarget target1 = sourceEntity.AddTarget( targetEntity ); if( target1 != null ) target1.Analyzer.Log.Add( entry ); CombatTarget target2 = targetEntity.AddTarget( sourceEntity ); if( target2 != null ) target2.Analyzer.Log.Add( entry ); } if( this.currentEncounter != null ) { // Record target as a participant in current encounter if( !this.currentEncounter.ContainsEntity( targetEntity ) ) this.currentEncounter.AddEntity( targetEntity ); if( !this.allEncounter.ContainsEntity( targetEntity ) ) this.allEncounter.AddEntity( targetEntity ); } } } catch( Exception ex ) { Console.WriteLine( line ); throw; } }
private void OnAnyCombatEnded(CombatEncounter combat) { this.enabled = false; Context.Combat = null; }
private void OnCombatStarted(CombatEncounter combat) { Combat = combat; }
private void Start() { Combat = CombatEncounter.Active; CombatEncounter.AnyCombatStarted += OnCombatStarted; CombatEncounter.AnyCombatEnded += OnCombatEnded; }
private void OnAnyCombatRoundStarted(CombatEncounter combat) { Context.TargetPoint = null; Context.TargetEntity = null; }