public void SetReadout(EncounterState state, EncounterZone zone, bool hasIntel) { GetNode <Label>("ReadoutContainer/NameEncounterBar/ZoneNameLabel").Text = zone.ZoneName; if (hasIntel) { GetNode <Label>("ReadoutContainer/NameEncounterBar/ZoneEncounterLabel").Text = zone.ReadoutEncounterName; } else { GetNode <Label>("ReadoutContainer/NameEncounterBar/ZoneEncounterLabel").Text = "NO INTEL"; } var itemsBar = GetNode <HBoxContainer>("ReadoutContainer/ItemsFeaturesBar"); if (hasIntel) { var itemsTextureSize = itemsBar.RectSize.y; foreach (var itemReadout in zone.ReadoutItems) { if (state.GetEntityById(itemReadout.EntityId) != null) { itemsBar.AddChild(BuildTextureRect(itemReadout.TexturePath, itemsTextureSize)); } else { itemsBar.AddChild(BuildTextureRect("res://resources/checkmark_18x18.png", itemsTextureSize)); } } } else { var noIntelLabel = new Label(); noIntelLabel.Text = "-?-"; itemsBar.AddChild(noIntelLabel); } var featuresBar = GetNode <HBoxContainer>("ReadoutContainer/ItemsFeaturesBar"); if (hasIntel) { var featuresTextureSize = featuresBar.RectSize.y; foreach (var featureReadout in zone.ReadoutFeatures) { if (state.GetEntityById(featureReadout.EntityId) != null) { featuresBar.AddChild(BuildTextureRect(featureReadout.TexturePath, featuresTextureSize)); } else { featuresBar.AddChild(BuildTextureRect("res://resources/checkmark_18x18.png", featuresTextureSize)); } } } else { var noIntelLabel = new Label(); noIntelLabel.Text = "-?-"; featuresBar.AddChild(noIntelLabel); } }
private static bool ResolveAutopilotBeginTravel(AutopilotBeginAction action, EncounterState state) { var playerPosition = state.Player.GetComponent <PositionComponent>().EncounterPosition; EncounterZone zone = state.GetZoneById(action.ZoneId); var foundPath = Pathfinder.AStarWithNewGrid(playerPosition, zone.Center, state, 9000); int autopilotTries = 0; while (foundPath == null && autopilotTries < 5) { foundPath = Pathfinder.AStarWithNewGrid(playerPosition, zone.RandomEmptyPosition(state.EncounterRand, state), state, 9000); autopilotTries++; } if (foundPath != null && autopilotTries > 0) { state.LogMessage(String.Format("Autopilot could not find path to center of [b]{0}[/b]; autopiloting to randomly chosen position in [b]{0}[/b].", zone.ZoneName)); state.Player.GetComponent <PlayerComponent>().LayInAutopilotPathForTravel(new EncounterPath(foundPath)); return(true); } else if (foundPath != null) { state.LogMessage(String.Format("Autopiloting to [b]{0}[/b]", zone.ZoneName)); state.Player.GetComponent <PlayerComponent>().LayInAutopilotPathForTravel(new EncounterPath(foundPath)); return(true); } else { state.LogMessage(String.Format("Autopilot failed to plot course to to [b]{0}[/b]", zone.ZoneName), failed: true); return(false); } }
public void FixedUpdate() { if (GetComponent <Animator>().GetBool("isWalking")) { Counter += Time.fixedDeltaTime; } if (Counter >= 1) { string type = Background.GetTile(new Vector3Int((int)(transform.position.x / 16), (int)(transform.position.y / 16), 0)).name; foreach (Collider2D contacts in Physics2D.OverlapPointAll(transform.position)) { EncounterZone zone = contacts.GetComponent <EncounterZone>(); if (zone != null) { Creature[] opposition = zone.RollEncounter(type); Debug.Log("Rolled for encounter on " + type); if (opposition != null) { GetComponent <Battle>().StartWildBattle(opposition); } else { Debug.Log("There was none"); } break; } } Counter -= 1; } }
public void PrepMenu(EncounterState state) { ResetZones(state); // You Are Here label var playerPosition = state.Player.GetComponent <PositionComponent>().EncounterPosition; EncounterZone closestZone = state.ClosestZone(playerPosition.X, playerPosition.Y); var youAreHereLabel = GetNode <RichTextLabel>("SidebarContainer/YouAreHereLabel"); if (closestZone.Contains(playerPosition.X, playerPosition.Y)) { youAreHereLabel.BbcodeText = string.Format("You are in [b]Sector {0}[/b], [b]{1}[/b]", state.DungeonLevel, closestZone.ZoneName); } else { youAreHereLabel.BbcodeText = string.Format("You are in [b]Sector {0}[/b], near [b]{1}[/b]", state.DungeonLevel, closestZone.ZoneName); } }
public void EncounterZoneSerializesAndDeserializes() { EncounterZone zone = new EncounterZone("some id", new EncounterPosition(10, 20), width: 20, height: 48, "some name"); zone.ReadoutEncounterName = "some encounter name"; var e1 = Entity.Create("e1 id", "e1 name"); e1.AddComponent(DisplayComponent.Create("e1 path", "", false, 1)); zone.AddFeatureToReadout(e1); var e2 = Entity.Create("e2 id", "e2 name"); e2.AddComponent(DisplayComponent.Create("e2 path", "", false, 1)); zone.AddItemToReadout(e2); var e3 = Entity.Create("e3 id", "e3 name"); e3.AddComponent(DisplayComponent.Create("e3 path", "", false, 1)); zone.AddFeatureToReadout(e3); var saved = JsonSerializer.Serialize(zone); var loaded = JsonSerializer.Deserialize <EncounterZone>(saved); Assert.Equal(zone.ZoneId, loaded.ZoneId); Assert.Equal(zone.Position, loaded.Position); Assert.Equal(zone.Width, loaded.Width); Assert.Equal(zone.Height, loaded.Height); Assert.Equal(zone.ZoneName, loaded.ZoneName); Assert.Equal(zone.ReadoutEncounterName, loaded.ReadoutEncounterName); Assert.Equal(zone._ReadoutFeatures[0].EntityId, loaded._ReadoutFeatures[0].EntityId); Assert.Equal(zone._ReadoutFeatures[0].EntityName, loaded._ReadoutFeatures[0].EntityName); Assert.Equal(zone._ReadoutFeatures[0].TexturePath, loaded._ReadoutFeatures[0].TexturePath); Assert.Equal(zone._ReadoutFeatures[1].EntityId, loaded._ReadoutFeatures[1].EntityId); Assert.Equal(zone._ReadoutFeatures[1].EntityName, loaded._ReadoutFeatures[1].EntityName); Assert.Equal(zone._ReadoutFeatures[1].TexturePath, loaded._ReadoutFeatures[1].TexturePath); Assert.Equal(zone._ReadoutItems[0].EntityId, loaded._ReadoutItems[0].EntityId); Assert.Equal(zone._ReadoutItems[0].EntityName, loaded._ReadoutItems[0].EntityName); Assert.Equal(zone._ReadoutItems[0].TexturePath, loaded._ReadoutItems[0].TexturePath); Assert.Equal(zone.Center, loaded.Center); }
public static Record CreateRecord(string Tag) { Record outRecord; switch (Tag) { case "TES4": outRecord = new Header(); break; case "GMST": outRecord = new GameSetting(); break; case "TXST": outRecord = new TextureSet(); break; case "MICN": outRecord = new MenuIcon(); break; case "GLOB": outRecord = new GlobalVariable(); break; case "CLAS": outRecord = new Class(); break; case "FACT": outRecord = new Faction(); break; case "HDPT": outRecord = new HeadPart(); break; case "HAIR": outRecord = new Hair(); break; case "EYES": outRecord = new Eyes(); break; case "RACE": outRecord = new Race(); break; case "SOUN": outRecord = new Sound(); break; case "ASPC": outRecord = new AcousticSpace(); break; case "MGEF": outRecord = new MagicEffect(); break; case "SCPT": outRecord = new Script(); break; case "LTEX": outRecord = new LandscapeTexture(); break; case "ENCH": outRecord = new ObjectEffect(); break; case "SPEL": outRecord = new ActorEffect(); break; case "ACTI": outRecord = new ESPSharp.Records.Activator(); break; case "TACT": outRecord = new TalkingActivator(); break; case "TERM": outRecord = new Terminal(); break; case "ARMO": outRecord = new Armor(); break; case "BOOK": outRecord = new Book(); break; case "CONT": outRecord = new Container(); break; case "DOOR": outRecord = new Door(); break; case "INGR": outRecord = new Ingredient(); break; case "LIGH": outRecord = new Light(); break; case "MISC": outRecord = new MiscItem(); break; case "STAT": outRecord = new Static(); break; case "SCOL": outRecord = new StaticCollection(); break; case "MSTT": outRecord = new MoveableStatic(); break; case "PWAT": outRecord = new PlaceableWater(); break; case "GRAS": outRecord = new Grass(); break; case "TREE": outRecord = new Tree(); break; case "FURN": outRecord = new Furniture(); break; case "WEAP": outRecord = new Weapon(); break; case "AMMO": outRecord = new Ammunition(); break; case "NPC_": outRecord = new NonPlayerCharacter(); break; case "CREA": outRecord = new Creature(); break; case "LVLC": outRecord = new LeveledCreature(); break; case "LVLN": outRecord = new LeveledNPC(); break; case "KEYM": outRecord = new Key(); break; case "ALCH": outRecord = new Ingestible(); break; case "IDLM": outRecord = new IdleMarker(); break; case "NOTE": outRecord = new Note(); break; case "COBJ": outRecord = new ConstructibleObject(); break; case "PROJ": outRecord = new Projectile(); break; case "LVLI": outRecord = new LeveledItem(); break; case "WTHR": outRecord = new Weather(); break; case "CLMT": outRecord = new Climate(); break; case "REGN": outRecord = new Region(); break; case "NAVI": outRecord = new NavigationMeshInfoMap(); break; case "DIAL": outRecord = new DialogTopic(); break; case "QUST": outRecord = new Quest(); break; case "IDLE": outRecord = new IdleAnimation(); break; case "PACK": outRecord = new Package(); break; case "CSTY": outRecord = new CombatStyle(); break; case "LSCR": outRecord = new LoadScreen(); break; case "ANIO": outRecord = new AnimatedObject(); break; case "WATR": outRecord = new Water(); break; case "EFSH": outRecord = new EffectShader(); break; case "EXPL": outRecord = new Explosion(); break; case "DEBR": outRecord = new Debris(); break; case "IMGS": outRecord = new ImageSpace(); break; case "IMAD": outRecord = new ImageSpaceAdapter(); break; case "FLST": outRecord = new FormList(); break; case "PERK": outRecord = new Perk(); break; case "BPTD": outRecord = new BodyPartData(); break; case "ADDN": outRecord = new AddonNode(); break; case "AVIF": outRecord = new ActorValueInformation(); break; case "RADS": outRecord = new RadiationStage(); break; case "CAMS": outRecord = new CameraShot(); break; case "CPTH": outRecord = new CameraPath(); break; case "VTYP": outRecord = new VoiceType(); break; case "IPCT": outRecord = new Impact(); break; case "IPDS": outRecord = new ImpactDataSet(); break; case "ARMA": outRecord = new ArmorAddon(); break; case "ECZN": outRecord = new EncounterZone(); break; case "MESG": outRecord = new Message(); break; case "RGDL": outRecord = new Ragdoll(); break; case "DOBJ": outRecord = new DefaultObjectManager(); break; case "LGTM": outRecord = new LightingTemplate(); break; case "MUSC": outRecord = new MusicType(); break; case "IMOD": outRecord = new ItemMod(); break; case "REPU": outRecord = new Reputation(); break; case "RCPE": outRecord = new Recipe(); break; case "RCCT": outRecord = new RecipeCategory(); break; case "CHIP": outRecord = new CasinoChip(); break; case "CSNO": outRecord = new Casino(); break; case "LSCT": outRecord = new LoadScreenType(); break; case "MSET": outRecord = new MediaSet(); break; case "ALOC": outRecord = new MediaLocationController(); break; case "CHAL": outRecord = new Challenge(); break; case "AMEF": outRecord = new AmmoEffect(); break; case "CCRD": outRecord = new CaravanCard(); break; case "CMNY": outRecord = new CaravanMoney(); break; case "CDCK": outRecord = new CaravanDeck(); break; case "DEHY": outRecord = new DehydrationStage(); break; case "HUNG": outRecord = new HungerStage(); break; case "SLPD": outRecord = new SleepDeprivationStage(); break; case "CELL": outRecord = new Cell(); break; case "WRLD": outRecord = new Worldspace(); break; case "LAND": outRecord = new GenericRecord(); break; case "NAVM": outRecord = new NavigationMesh(); break; case "INFO": outRecord = new DialogResponse(); break; case "REFR": outRecord = new Reference(); break; case "ACHR": outRecord = new PlacedNPC(); break; case "ACRE": outRecord = new PlacedCreature(); break; case "PGRE": outRecord = new PlacedGrenade(); break; case "PMIS": outRecord = new PlacedMissile(); break; default: Console.WriteLine("Encountered unknown record: " + Tag); outRecord = new GenericRecord(); break; } outRecord.Tag = Tag; return(outRecord); }