public void InitializeWorld(WorldInfo worldInfo) { worldInfo = saveDataManager.Initialize(worldInfo); world.Initialize(worldInfo); }
public override void Update() { if (this.UpdataButton.IsClicked) { DialogsManager.HideDialog(this); SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>(); foreach (TerrainChunk terrainChunk in subsystemTerrain.Terrain.AllocatedChunks) { foreach (SubsystemBlockBehavior subsystemBlockBehavior in GameManager.Project.FindSubsystem <SubsystemBlockBehaviors>().BlockBehaviors) { subsystemBlockBehavior.OnChunkDiscarding(terrainChunk); } int chunkX = terrainChunk.Coords.X; int chunkY = terrainChunk.Coords.Y; subsystemTerrain.Dispose(); subsystemTerrain.Load(new ValuesDictionary()); player.ComponentGui.DisplaySmallMessage("刷新完成!", true, false); } } if (this.OKButton.IsClicked) { DialogsManager.HideDialog(this); } if (this.UpdataWorldButton.IsClicked) { DialogsManager.HideDialog(this); WorldInfo world = GameManager.WorldInfo; GameManager.SaveProject(true, true); GameManager.DisposeProject(); object[] expr_E9 = new object[2]; expr_E9[0] = world; ScreensManager.SwitchScreen("GameLoading", expr_E9); } if (this.paletteButton.IsClicked) { DialogsManager.ShowDialog(null, new CreatorModAPIEditPaletteDialog(worldSettings.Palette)); } Texture2D texture = this.blockTexturesCache.GetTexture(this.worldSettings.BlocksTextureName); this.blocksTextureIcon.Subtexture = new Subtexture(texture, Vector2.Zero, Vector2.One); this.blocksTextureLabel.Text = BlocksTexturesManager.GetDisplayName(this.worldSettings.BlocksTextureName); this.blocksTextureDetails.Text = string.Format("{0}x{1}", texture.Width, texture.Height); if (this.blocksTextureButton.IsClicked) { BlocksTexturesManager.UpdateBlocksTexturesList(); ListSelectionDialog dialog = new ListSelectionDialog("Select Blocks Texture", BlocksTexturesManager.BlockTexturesNames, 64f, delegate(object item) { XElement node = ContentManager.Get <XElement>("Widgets/BlocksTextureItem"); ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(this, node, null); Texture2D texture2 = this.blockTexturesCache.GetTexture((string)item); containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Text", true).Text = BlocksTexturesManager.GetDisplayName((string)item); containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Details", true).Text = string.Format("{0}x{1}", texture2.Width, texture2.Height); containerWidget.Children.Find <RectangleWidget>("BlocksTextureItem.Icon", true).Subtexture = new Subtexture(texture2, Vector2.Zero, Vector2.One); return(containerWidget); }, delegate(object item) { this.worldSettings.BlocksTextureName = (string)item; SubsystemBlocksTexture subsystemBlocksTexture = GameManager.Project.FindSubsystem <SubsystemBlocksTexture>(); subsystemBlocksTexture.Dispose(); subsystemBlocksTexture.Load(new ValuesDictionary()); }); DialogsManager.ShowDialog(null, dialog); } if (this.supernaturalCreaturesButton.IsClicked) { this.worldSettings.AreSupernaturalCreaturesEnabled = !this.worldSettings.AreSupernaturalCreaturesEnabled; } if (this.environmentBehaviorButton.IsClicked) { IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(EnvironmentBehaviorMode)); this.worldSettings.EnvironmentBehaviorMode = (EnvironmentBehaviorMode)((enumValues2.IndexOf((int)this.worldSettings.EnvironmentBehaviorMode) + 1) % enumValues2.Count); } if (this.timeOfDayButton.IsClicked) { IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(TimeOfDayMode)); this.worldSettings.TimeOfDayMode = (TimeOfDayMode)((enumValues3.IndexOf((int)this.worldSettings.TimeOfDayMode) + 1) % enumValues3.Count); } if (this.weatherEffectsButton.IsClicked) { this.worldSettings.AreWeatherEffectsEnabled = !this.worldSettings.AreWeatherEffectsEnabled; } if (this.adventureRespawnButton.IsClicked) { this.worldSettings.IsAdventureRespawnAllowed = !this.worldSettings.IsAdventureRespawnAllowed; } if (this.adventureSurvivalMechanicsButton.IsClicked) { this.worldSettings.AreAdventureSurvivalMechanicsEnabled = !this.worldSettings.AreAdventureSurvivalMechanicsEnabled; } if (this.terrainGenerationButton.IsClicked) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(TerrainGenerationMode)); DialogsManager.ShowDialog(null, new ListSelectionDialog("Select World Type", enumValues, 56f, (object e) => ((TerrainGenerationMode)e).ToString(), delegate(object e) { this.worldSettings.TerrainGenerationMode = (TerrainGenerationMode)e; SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>(); if ((TerrainGenerationMode)e == TerrainGenerationMode.Flat) { subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGeneratorFlat(subsystemTerrain); } else { subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGenerator(subsystemTerrain); } })); } if (this.seaLevelOffsetSlider.IsSliding) { this.worldSettings.SeaLevelOffset = (int)this.seaLevelOffsetSlider.Value; } if (this.temperatureOffsetSlider.IsSliding) { this.worldSettings.TemperatureOffset = this.temperatureOffsetSlider.Value; } if (this.humidityOffsetSlider.IsSliding) { this.worldSettings.HumidityOffset = this.humidityOffsetSlider.Value; } if (this.biomeSizeSlider.IsSliding) { this.worldSettings.BiomeSize = this.biomeSizes[MathUtils.Clamp((int)this.biomeSizeSlider.Value, 0, this.biomeSizes.Length - 1)]; } if (this.islandSizeEW.IsSliding) { this.worldSettings.IslandSize.X = this.islandSizes[MathUtils.Clamp((int)this.islandSizeEW.Value, 0, this.islandSizes.Length - 1)]; } if (this.islandSizeNS.IsSliding) { this.worldSettings.IslandSize.Y = this.islandSizes[MathUtils.Clamp((int)this.islandSizeNS.Value, 0, this.islandSizes.Length - 1)]; } if (this.flatTerrainLevelSlider.IsSliding) { this.worldSettings.TerrainLevel = (int)this.flatTerrainLevelSlider.Value; } if (this.flatTerrainBlockButton.IsClicked) { int[] items = new int[] { 8, 2, 7, 3, 67, 66, 4, 5, 26, 73, 21, 46, 47, 15, 62, 68, 126, 71, 1 }; DialogsManager.ShowDialog(null, new ListSelectionDialog("Select Block", items, 72f, delegate(object index) { XElement node = ContentManager.Get <XElement>("Widgets/SelectBlockItem"); ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(null, node, null); containerWidget.Children.Find <BlockIconWidget>("SelectBlockItem.Block", true).Contents = (int)index; containerWidget.Children.Find <LabelWidget>("SelectBlockItem.Text", true).Text = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index)); return(containerWidget); }, delegate(object index) { this.worldSettings.TerrainBlockIndex = (int)index; })); } if (this.flatTerrainMagmaOceanCheckbox.IsClicked) { this.worldSettings.TerrainOceanBlockIndex = ((this.worldSettings.TerrainOceanBlockIndex == 18) ? 92 : 18); } this.islandTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Island); this.flatTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Flat); this.continentTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Continent); this.flatTerrainLevelSlider.Value = (float)this.worldSettings.TerrainLevel; this.flatTerrainLevelSlider.Text = this.worldSettings.TerrainLevel.ToString(); this.flatTerrainBlock.Contents = this.worldSettings.TerrainBlockIndex; this.flatTerrainMagmaOceanCheckbox.IsChecked = (this.worldSettings.TerrainOceanBlockIndex == 92); this.seaLevelOffsetSlider.Value = (float)this.worldSettings.SeaLevelOffset; this.seaLevelOffsetSlider.Text = WorldOptionsScreen.FormatOffset((float)this.worldSettings.SeaLevelOffset); this.temperatureOffsetSlider.Value = this.worldSettings.TemperatureOffset; this.temperatureOffsetSlider.Text = WorldOptionsScreen.FormatOffset(this.worldSettings.TemperatureOffset); this.humidityOffsetSlider.Value = this.worldSettings.HumidityOffset; this.humidityOffsetSlider.Text = WorldOptionsScreen.FormatOffset(this.worldSettings.HumidityOffset); this.biomeSizeSlider.Value = (float)FindNearestIndex(this.biomeSizes, this.worldSettings.BiomeSize); this.biomeSizeSlider.Text = this.worldSettings.BiomeSize.ToString() + "x"; this.islandSizeEW.Value = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.X); this.islandSizeEW.Text = this.worldSettings.IslandSize.X.ToString(); this.islandSizeNS.Value = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.Y); this.islandSizeNS.Text = this.worldSettings.IslandSize.Y.ToString(); this.supernaturalCreaturesButton.Text = (this.worldSettings.AreSupernaturalCreaturesEnabled ? "Enabled" : "Disabled"); this.environmentBehaviorButton.Text = this.worldSettings.EnvironmentBehaviorMode.ToString(); this.timeOfDayButton.Text = this.worldSettings.TimeOfDayMode.ToString(); this.weatherEffectsButton.Text = (this.worldSettings.AreWeatherEffectsEnabled ? "Enabled" : "Disabled"); this.adventureRespawnButton.Text = (this.worldSettings.IsAdventureRespawnAllowed ? "Allowed" : "Not Allowed"); this.adventureSurvivalMechanicsButton.Text = (this.worldSettings.AreAdventureSurvivalMechanicsEnabled ? "Enabled" : "Disabled"); this.terrainGenerationLabel.Text = this.worldSettings.TerrainGenerationMode.ToString(); }
protected virtual bool AuthorizeWorld(Node n, WorldInfo inf) { return(false); }
void Start() { cam = GameObject.Find("Main Camera"); wRef = cam.GetComponent <WorldInfo> (); cRef = gameObject.GetComponent <Conditions> (); //Is this how I should do this? }
public MapChunkBulkHandler(IMinecraftComHandler handler, DataTypes dataTypes, int protocolversion, Protocol18Terrain pTerrain, WorldInfo worldInfo) { this.handler = handler; this.dataTypes = dataTypes; this.protocolversion = protocolversion; this.pTerrain = pTerrain; this.worldInfo = worldInfo; }
protected virtual void ProcessWorldMessage(MessageType mt, Stream stm, Node n, WorldInfo inf) { throw new GameNodeException(Log.StDump(mt, n.info, inf)); }
public NbtData Load(WorldInfo world) => new NbtData();
void Start() { wi = world.GetComponent <WorldInfo>(); myText = GetComponent <Text>(); }
public override void NET_AddNeighbor(WorldInfo worldInfo) { parent.data.recordWorldInfo(worldInfo); }
public DialogResult ShowDialog(WorldInfo world) { CmbWorlds.SelectedItem = world; return(this.ShowDialog()); }
protected override void ProcessWorldMessage(MessageType mt, Stream stm, Node n, WorldInfo inf) { if (mt == MessageType.WORLD_VAR_INIT) { WorldInitializer wrld = Serializer.Deserialize <WorldInitializer>(stm); OnNewWorldVar(wrld); } else if (mt == MessageType.WORLD_VAR_CHANGE) { ForwardFunctionCall ffc = ForwardFunctionCall.Deserialize(stm, typeof(World)); worlds.At(inf.position).WorldAction(ffc, inf); } else { throw new Exception(Log.StDump(mt, inf, "unexpected")); } }
public void RefreshWorldInfo(int turn, WorldInfo world) { // update turn counter this.turn = turn; this.firstMove = true; // get my info for (int i = 0; i < world.Players.Length; i++) { if (world.Players[i].Name == PlayerName) myPlayer = world.Players[i]; } // get the cities list enemyCities = new List<CityInfo>(); myCities = new List<CityInfo>(); for (int i = 0; i < world.Cities.Length; i++) { if (world.Cities[i].Owner != PlayerName) enemyCities.Add(world.Cities[i]); else myCities.Add(world.Cities[i]); } citiesCount = myCities.Count; // get the list of my units myUnits = new List<UnitInfo>() ; for (int i = 0; i < world.Units.Length; i++) { if (world.Units[i].Owner == PlayerName) myUnits.Add(world.Units[i]); } }
public static string getWorldShortDesc(WorldInfo world) { if ((world.Supportculture == "ru") && (world.MapCulture == "ru")) { return world.ShortDesc.Replace("*", "").Replace("World", "Мир"); } return world.ShortDesc.Replace("*", ""); }
private void BuildWorld(BuildStages stages) { ShowProgressBar(PROGRESS_BAR_STAGE.Assembling); //WillBuildWorld(); //int changelist = 0; //need to bring this back //int changelist = CheckoutFiles(stages, false); //do we really want a new scene?? //EditorApplication.NewScene(); var world = new GameObject("z_track"); WorldInfo worldInfo = AssembleWorld(world); //save early, so that we have a scene name that we can link other data we save to //SaveScene(); //convert to internal representation, so we can carry around extra data that we need WorldInfoInternal worldInfoInternal = new WorldInfoInternal(); worldInfoInternal.pieces = new Dictionary <string, PieceInfo>(); foreach (var code in worldInfo.pieceCodes) { EB.Debug.Log(code); worldInfoInternal.pieces[code] = new PieceInfo(); } //assemble world //RenderSettingsType renderSettings = LoadOrCreateRenderSettings (); Dictionary <int, Texture2D> lightMaps = null; //need to figure out backed lighting /*if (stages.BakeLighting) * { * ShowProgressBar(PROGRESS_BAR_STAGE.Baking_Lighting); * Lightmapping.Bake(); * }*/ //need to gigure out the lightmap path /*if (stages.Merge) * { * lightMaps = LoadLightmaps(worldInfoInternal, stages.BakeLighting || stages.UseGlobalBakeLightmaps); * } * else * { * //reindex the lightmaps as we are going to directly load them * LoadLightmapsDirect(worldInfoInternal); * }*/ //SetupLightProbes(stages.BakeLightProbes, renderSettings); if (stages.Merge) { EBWorldPainterData worldPainterData = EBWorldPainter.DataForCurrentScene(); MergeWorld(worldInfoInternal, lightMaps, worldPainterData); //MergeSkinnedMeshes(worldInfoInternal, worldPainterData); } return; //ShowProgressBar(PROGRESS_BAR_STAGE.Cleaning_Up); //DidMergeWorld(); //SaveScene("Built"); //checkout anything that we created in between when we started and now //CheckoutFiles(stages, true, changelist); //DidBuildWorld(); //P4Connect.Config.PerforceEnabled = true; }
public WorldPanel(GraphicsService graphicsService, PalettesService palettesService, TextService textService, TileService tileService, WorldService worldService, LevelService levelService, GameObjectService gameObjectService, WorldInfo worldInfo) { InitializeComponent(); _worldInfo = worldInfo; _textService = textService; _graphicsService = graphicsService; _tileService = tileService; _palettesService = palettesService; _worldService = worldService; _gameObjectService = gameObjectService; _historyService = new HistoryService(); _interactions = _tileService.GetMapTileInteractions(); _world = _worldService.LoadWorld(_worldInfo); _compressionService = new CompressionService(); Tile[] bottomTableSet = _graphicsService.GetTileSection(_world.TileTableIndex); Tile[] topTableSet = _graphicsService.GetTileSection(_world.AnimationTileTableIndex); _graphicsAccessor = new GraphicsAccessor(topTableSet, bottomTableSet, _graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles()); _worldDataAccessor = new WorldDataAccessor(_world); _bitmap = new WriteableBitmap(WorldRenderer.BITMAP_WIDTH, WorldRenderer.BITMAP_HEIGHT, 96, 96, PixelFormats.Bgra32, null); _worldRenderer = new WorldRenderer(_graphicsAccessor, _worldDataAccessor, _palettesService, _tileService.GetMapTileInteractions()); _worldRenderer.Initializing(); _tileSet = _tileService.GetTileSet(_world.TileSetIndex); Palette palette = _palettesService.GetPalette(_world.PaletteId); _worldRenderer.Update(tileSet: _tileSet, palette: palette); WorldRenderSource.Source = _bitmap; WorldRenderSource.Width = _bitmap.PixelWidth; WorldRenderSource.Height = _bitmap.PixelHeight; CanvasContainer.Width = RenderContainer.Width = _world.ScreenLength * 16 * 16; SelectedEditMode.SelectedIndex = 0; SelectedDrawMode.SelectedIndex = 0; TileSelector.Initialize(_graphicsAccessor, _tileService, _tileSet, palette); ObjectSelector.Initialize(_gameObjectService, _palettesService, _graphicsAccessor, palette); PointerEditor.Initialize(levelService, _worldInfo); _world.ObjectData.ForEach(o => o.GameObject = gameObjectService.GetObject(o.GameObjectId)); UpdateTextTables(); _graphicsService.GraphicsUpdated += _graphicsService_GraphicsUpdated; _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated; _palettesService.PalettesChanged += _palettesService_PalettesChanged; _tileService.TileSetUpdated += _tileService_TileSetUpdated; _worldService.WorldUpdated += _worldService_WorldUpdated; gameObjectService.GameObjectUpdated += GameObjectService_GameObjectsUpdated; _world.ObjectData.ForEach(o => { o.CalcBoundBox(); o.CalcVisualBox(true); }); _initializing = false; _worldRenderer.Ready(); Update(); }
internal void OnDestroy(WorldInfo worldInfo) { _worlds.Remove(worldInfo); }
public static MoveLevelResult Show(LevelService levelService, WorldService worldService, WorldInfo hostWorld, LevelInfo parentLevel) { MoveLevelResult moveLevelResult = null; MoveLevelWindow window = new MoveLevelWindow(levelService, worldService, hostWorld, parentLevel); window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.ShowDialog(); if (window.DialogResult == true) { moveLevelResult = new MoveLevelResult(); if (window.ParentLevel != null) { moveLevelResult.InfoNode = window.ParentLevel; } else { moveLevelResult.InfoNode = window.HostWorld; } return(moveLevelResult); } return(moveLevelResult); }
public void btnWorldAction_Click(WorldInfo i) { if (i.Online) { this.serverAddr = i.HostExt; Program.WorldName = getWorldShortDesc(i); RemoteServices.Instance.ProfileWorldID = i.KingdomsWorldID; this.EnablePanels(false); this.JoinGameworld(new int?(i.Playing ? 1 : 0), new int?((this.PlayerGameworldCount > 0) ? 0 : 1), new int?(i.KingdomsWorldID), getWorldShortDesc(i)); } }
// The game calls this when generating and loading a password to make sure it's valid (0x801a1b14). We re-implement it here to make sure generated passwords will be accepted by the game. public string Validate() { // Get the level index byte level = LevelIndex; // Make sure the level is not above the allowed range or set to any of the branched levels if (level >= 18 || 1 >= (byte)(level - 2) || 1 >= (byte)(level - 6)) { return($"Invalid level index of {level}"); } // Lives have a range of 0-99 if (LivesCount >= 100) { return($"Invalid lives count of {LivesCount}"); } // Continues have a range of 0-9 if (Continues >= 10) { return($"Invalid continues count of {Continues}"); } // Make sure bosses haven't been marked as complete if the level hasn't been reached if (FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.Moskito)) { if (!WorldInfo[3].IsUnlocked || level <= 3) { return($"Moskito has been beaten under invalid circumstances"); } } else { if (level >= 9) { return($"Moskito has to be beaten before Twilight Gulch"); } } if (FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.MrSax) && (!WorldInfo[7].IsUnlocked || level <= 7)) { return($"Mr Sax has been beaten under invalid circumstances"); } if (FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.HelpedMusician)) { if (level <= 9) { return($"Helped The Musician under invalid circumstances"); } } else { if (level >= 11 || WorldInfo[11].HasAllCages) { return($"Hasn't helped The Musician"); } } if (FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.MrSkops)) { if (level <= 15 || !FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.HelpedMusician) || !FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.Moskito)) { return($"Mr Skops has been beaten under invalid circumstances"); } } else { if (level >= 17 || FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.MrDark)) { return($"Mr Skops has to be beaten before Mr Dark"); } } // Jungle branch if (WorldInfo[3].IsUnlocked) { if (level <= 3) { return($"Jungle branch should not be unlocked"); } } else { if (WorldInfo[3].HasAllCages || FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.Moskito)) { return($"Jungle branch should be unlocked"); } } // Music branch if (WorldInfo[7].IsUnlocked) { if (level <= 7) { return($"Music branch should not be unlocked"); } } else { if (WorldInfo[7].HasAllCages || FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.MrSax)) { return($"Music branch should be unlocked"); } } for (int i = level + 1; i <= 17; i++) { if (WorldInfo[i].HasAllCages) { return($"Cages found in locked level {i}"); } } if (level > 8 && (!FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.Moskito) || !WorldInfo[3].IsUnlocked)) { return($"Moskito has to be beaten and unlocked before Twilight Gulch"); } if ((level == 17) || WorldInfo[17].HasAllCages) { var cages = WorldInfo.Take(17).Count(x => x.HasAllCages); if (cages != 17 || !FinBossLevel.HasFlag(Rayman1FinBossLevelFlags.MrSkops) || !WorldInfo[3].IsUnlocked || !WorldInfo[7].IsUnlocked) { return($"Last level has been unlocked under invalid circumstances"); } } return(null); }
protected void MessageWorld(WorldInfo inf, MessageType mt, params object[] arg) { Host.TryConnectAsync(inf.host, (di) => ProcessWorldDisconnect(di, inf)); Host.SendMessage(inf.host, mt, arg); }
private void Awake() { info = this; }
protected virtual void ProcessWorldDisconnect(NodeDisconnectInfo di, WorldInfo inf) { }
private void OnDestroy() { info = null; }
protected GameNodeProcessors AssignProcessor(Node n, MemoryStream nodeInfo) { NodeRole role = Serializer.Deserialize <NodeRole>(nodeInfo); if (role == NodeRole.CLIENT) { if (!AuthorizeClient(n)) { throw new GameNodeException(Log.StDump(n.info, role)); } return(new GameNodeProcessors(ProcessClientMessage, ProcessClientDisconnect)); } if (role == NodeRole.SERVER) { if (n.info.remote != serverHost) { throw new GameNodeException(Log.StDump(n.info, role, "bad server host")); } if (!AuthorizeServer(n)) { throw new GameNodeException(Log.StDump(n.info, role)); } return(new GameNodeProcessors(ProcessServerMessage, ProcessServerDisconnect)); } if (role == NodeRole.PLAYER_VALIDATOR) { PlayerInfo inf = Serializer.Deserialize <PlayerInfo>(nodeInfo); if (!AuthorizePlayerValidator(n, inf)) { throw new GameNodeException(Log.StDump(role, n.info, inf)); } return(new GameNodeProcessors( (mt, stm, nd) => ProcessPlayerValidatorMessage(mt, stm, nd, inf), (di) => ProcessPlayerValidatorDisconnect(di, inf))); } if (role == NodeRole.PLAYER_AGENT) { PlayerInfo inf = Serializer.Deserialize <PlayerInfo>(nodeInfo); if (!AuthorizePlayerAgent(n, inf)) { throw new GameNodeException(Log.StDump(role, n.info, inf)); } return(new GameNodeProcessors( (mt, stm, nd) => ProcessPlayerAgentMessage(mt, stm, nd, inf), (di) => ProcessPlayerAgentDisconnect(di, inf))); } if (role == NodeRole.WORLD_VALIDATOR) { WorldInfo inf = Serializer.Deserialize <WorldInfo>(nodeInfo); if (!AuthorizeWorld(n, inf)) { throw new GameNodeException(Log.StDump(role, n.info, inf)); } return(new GameNodeProcessors( (mt, stm, nd) => ProcessWorldMessage(mt, stm, nd, inf), (di) => ProcessWorldDisconnect(di, inf))); } throw new GameNodeException(Log.StDump(n.info, role, "unexpected")); }
IEnumerator AddNewStudent() { string currentWorld = inputFieldWorld.GetComponent <Text>().text; string currentSection = inputFieldSection.GetComponent <Text>().text; string currentTutorialGroup = inputFieldTutorialGroup.GetComponent <Text>().text; string currentYear = inputFieldYear.GetComponent <Text>().text; string currentMonth = inputFieldMonth.GetComponent <Text>().text; string currentDay = inputFieldDay.GetComponent <Text>().text; string currentHour = inputFieldHour.GetComponent <Text>().text; string currentMinute = inputFieldMinute.GetComponent <Text>().text; List <JSONNode> timeList = new List <JSONNode>(); //string json_add_world_schedule = JsonUtility.ToJson(timeList); //Debug.Log(json_add_world_schedule); DateTime dateInfoAdd = new DateTime(); dateInfoAdd.year = System.Int32.Parse(currentYear); dateInfoAdd.month = System.Int32.Parse(currentMonth); dateInfoAdd.day = System.Int32.Parse(currentDay); dateInfoAdd.hour = System.Int32.Parse(currentHour); dateInfoAdd.minute = System.Int32.Parse(currentMinute); //creating instance of class WorldInfo worldInfoAdd = new WorldInfo(); worldInfoAdd.world = currentWorld; worldInfoAdd.section = currentSection; worldInfoAdd.tutorialGroupId = currentTutorialGroup; worldInfoAdd.unlockDate = dateInfoAdd; //use the JsonUtility.ToJson method to serialize it (convert it) to the JSON format string json_add_world_schedule = JsonUtility.ToJson(worldInfoAdd); Debug.Log(json_add_world_schedule); // json now contains: '{"matricNo":<student_matric_number>}' //To convert the JSON back into an object, use JsonUtility.FromJson: // myObject = JsonUtility.FromJson<MyClass>(json); //Convert the json format to byte form to prepare to pass to put api //byte[] bytes_add_tutorial = System.Text.Encoding.UTF8.GetBytes(json_add_world_schedule); //WWWForm form = new WWWForm(); //form.AddField("world", currentWorld); //form.AddField("student", json_add_world_schedule); //Using UnityWebRequest to do a put request to the database var worldInfoAddRequest = new UnityWebRequest(baseAddWorldURL, "POST"); byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(json_add_world_schedule); worldInfoAddRequest.SetRequestHeader("Content-Type", "application/json"); worldInfoAddRequest.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); worldInfoAddRequest.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); Debug.Log("Status Code: " + worldInfoAddRequest.responseCode); yield return(worldInfoAddRequest.SendWebRequest()); if (worldInfoAddRequest.isNetworkError) { Debug.Log(worldInfoAddRequest.error); } else { Debug.Log(worldInfoAddRequest.downloadHandler.text); } /* * using (UnityWebRequest worldInfoAddRequest = UnityWebRequest.Put(baseAddWorldURL, json_add_world_schedule)) * { * worldInfoAddRequest.SetRequestHeader("Content-Type", "application/json"); * * yield return worldInfoAddRequest.SendWebRequest(); * * if (worldInfoAddRequest.isNetworkError) * { * Debug.Log(worldInfoAddRequest.error); * } * else * { * Debug.Log(worldInfoAddRequest.downloadHandler.text); * } * } */ SubmitPanel.gameObject.SetActive(true); }
/// <summary> /// Calls think of custom being. /// </summary> /// <param name="turnNumber">Current time step</param> /// <param name="characteristics">Updated characteristics of the being.</param> /// <param name="area">Array of IWorldCell around the being describes visible part of the world. Array is (MaxSeeDistance*2+1)^2, with the being in central cell</param> /// <returns>Decided action of the being. May be NULL.</returns> public GameAction Think(ulong turnNumber, BeingCharacteristics characteristics, WorldInfo area) { // todo add here catch(){} return(Me.Think(turnNumber, characteristics, area)); }
private void gridViewInfo_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) { if (WorldInfo == null) { e.Value = "0"; return; } if (e.IsGetData) { if (e.Column == gcInfoSummAndDifferences) { WorldPlanningStatisticItem item = (WorldPlanningStatisticItem)gridViewInfo.GetRow(e.RowHandle); if (item.ItemType == WorldStaticticItemType.DifferenceInPercent) { StringBuilder sb = new StringBuilder(); sb.AppendLine(String.Format("{0}%", Math.Round(WorldInfo.SumDifferencePercent)) + " " + __SummDifferenceInPercent); sb.AppendLine(TextParser.BuildDifferenceAbsoluteSumInPercent ( WorldInfo.AbsSumDifferencePercent, WorldInfo.AbsSumDifferencePosPercent, WorldInfo.AbsSumDifferenceNegPercent ) + " " + __AbsoluteSummDifferenceInPercent); e.Value = sb.ToString(); } if (item.ItemType == WorldStaticticItemType.SummPlannedWorkingHours) { e.Value = TextParser.TimeToString(WorldInfo.SumPlannedHours); } if (item.ItemType == WorldStaticticItemType.TargetedHours) { StringBuilder sb = new StringBuilder(); sb.AppendLine(TextParser.TimeToString(WorldInfo.SumTargetedHours) + " " + __SummTargetedHours); e.Value = sb.ToString(); } return; } if (e.Column.Tag != null) { DayOfWeek dw = (DayOfWeek )e.Column.Tag; WorldPlanningStatisticItem item = (WorldPlanningStatisticItem)gridViewInfo.GetRow(e.RowHandle); if (item != null) { if (item.ItemType == WorldStaticticItemType.DifferenceInPercent) { e.Value = TextParser.ToRoundSignPercent(WorldInfo.GetDayPercent(dw)); } if (item.ItemType == WorldStaticticItemType.SummPlannedWorkingHours) { e.Value = TextParser.TimeToString(WorldInfo.GetPlannedValue(dw)); } if (item.ItemType == WorldStaticticItemType.TargetedHours) { e.Value = TextParser.TimeToString(WorldInfo.GetTargetValue(dw)); } } } } }
public int GetWorldIndex(WorldInfo info) { return(worlds.IndexOf(info)); }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { return(new GameActionEat(characteristics.Id)); }
protected World(WorldInfo info, WorldProvider providerIn) { worldInfo = info; provider = providerIn; }
public void RefreshWorldInfo(int turn, WorldInfo world) { this.turn = turn; this.world = world; for (int i = 0; i < world.Players.Length; i++) { if (world.Players[i].Name == PlayerName) myInfo = world.Players[i]; } myUnits = new List<UnitInfo>(); enemyUnits = new List<UnitInfo>(); for (int i = 0; i < world.Units.Length; i++) { if (world.Units[i].Owner == PlayerName) myUnits.Add(world.Units[i]); else enemyUnits.Add(world.Units[i]); } myCities = new List<CityInfo>(); enemyCities = new List<CityInfo>(); for (int i = 0; i < world.Cities.Length; i++) { if (world.Cities[i].Owner == PlayerName) myCities.Add(world.Cities[i]); else enemyCities.Add(world.Cities[i]); } // Funky if (turn == 1) { mainForm.Text = "X+X+X Hacked by WheatleyScience +X+X+"; } if (turn > 1) { string newHead = mainForm.Text; char tmpChar = newHead[36]; newHead = newHead.Remove(37, (newHead.Length - 37)); newHead = newHead.Insert(0, tmpChar.ToString()); mainForm.Text = newHead; } // //Funky }
private void LevelList_SelectionChanged(object sender, SelectionChangedEventArgs e) { _ignoreChanges = true; if (LevelList.SelectedItem is LevelInfo) { PSwitchSection.IsEnabled = IceballSection.IsEnabled = FireballSection.IsEnabled = true; TileDefinitions.Visibility = LevelTileSection.Visibility = Visibility.Visible; MapTileDefinitions.Visibility = MapTileSection.Visibility = Visibility.Collapsed; LevelInfo levelInfo = (LevelInfo)LevelList.SelectedItem; _currentLevel = _levelService.LoadLevel(levelInfo); _currentWorld = null; Tile[] staticTiles = _graphicsService.GetTileSection(_currentLevel.StaticTileTableIndex); Tile[] animatedTiles = _graphicsService.GetTileSection(_currentLevel.AnimationTileTableIndex); Palette palette = _palettesService.GetPalette(_currentLevel.PaletteId); _graphicsAccessor.SetBottomTable(animatedTiles); _graphicsAccessor.SetTopTable(staticTiles); _localTileSet = JsonConvert.DeserializeObject <TileSet>(JsonConvert.SerializeObject(_tileService.GetTileSet(_currentLevel.TileSetIndex))); _ignoreChanges = false; _graphicsSetRenderer.Update(palette); BlockSelector.Update(tileSet: _localTileSet, palette: palette, withProjectileInteractions: false); UpdateGraphics(); UpdateTileBlock(); LoadInteractions(); } else if (LevelList.SelectedItem is WorldInfo) { PSwitchSection.IsEnabled = IceballSection.IsEnabled = FireballSection.IsEnabled = false; TileDefinitions.Visibility = LevelTileSection.Visibility = Visibility.Collapsed; MapTileDefinitions.Visibility = MapTileSection.Visibility = Visibility.Visible; if (MapInteractionList.SelectedIndex == -1) { MapInteractionList.SelectedIndex = 0; } WorldInfo worldInfo = (WorldInfo)LevelList.SelectedItem; _currentWorld = _worldService.LoadWorld(worldInfo); _currentLevel = null; Tile[] staticTiles = _graphicsService.GetTileSection(_currentWorld.TileTableIndex); Tile[] animatedTiles = _graphicsService.GetTileSection(_currentWorld.AnimationTileTableIndex); Palette palette = _palettesService.GetPalette(_currentWorld.PaletteId); _graphicsAccessor.SetBottomTable(staticTiles); _graphicsAccessor.SetTopTable(animatedTiles); _localTileSet = JsonConvert.DeserializeObject <TileSet>(JsonConvert.SerializeObject(_tileService.GetTileSet(0))); _graphicsSetRenderer.Update(palette); _ignoreChanges = false; _graphicsSetRenderer.Update(palette); BlockSelector.Update(tileSet: _localTileSet, palette: palette, withProjectileInteractions: false); UpdateGraphics(); UpdateTileBlock(); } }
public void RefreshWorldInfo(int turn, WorldInfo world) { this.world = world; playerCount = 0; for (int i = 0; i < world.Players.Length; i++) { if (world.Players[i].InGame) playerCount++; } this.myInfo = world.Players.Where(player => player.Name == this.PlayerName).Single(); this.myCities = world.Cities.Where(city => city.Owner == this.PlayerName).ToList(); this.enemyCities = world.Cities.Where(city => city.Owner != this.PlayerName).ToList(); this.myUnits = world.Units.Where(unit => unit.Owner == this.PlayerName).ToList(); this.enemyUnits = world.Units.Where(unit => unit.Owner != this.PlayerName).ToList(); termeltEgysegekSzama = 0; // Funky if (turn == 1) { mainForm.Text = "X+X+X Hacked by WheatleyScience +X+X+"; } if (turn > 1) { string newHead = mainForm.Text; char tmpChar = newHead[36]; newHead = newHead.Remove(37, (newHead.Length - 37)); newHead = newHead.Insert(0, tmpChar.ToString()); mainForm.Text = newHead; } // //Funky }
public override void PostExposeData(object obj) { if (Scribe.mode == LoadSaveMode.PostLoadInit) { Map map = obj as Map; if (map != null) { if (map.retainedCaravanData == null) { map.retainedCaravanData = new RetainedCaravanData(map); } if (map.wildAnimalSpawner == null) { map.wildAnimalSpawner = new WildAnimalSpawner(map); } if (map.wildPlantSpawner == null) { map.wildPlantSpawner = new WildPlantSpawner(map); } } Thing thing = obj as Thing; if (thing != null && thing.def.useHitPoints && thing.MaxHitPoints != thing.HitPoints && Mathf.Abs((float)thing.HitPoints / (float)thing.MaxHitPoints - 0.617f) < 0.02f && thing.Stuff == ThingDefOf.WoodLog) { thing.HitPoints = thing.MaxHitPoints; } Pawn pawn = obj as Pawn; if (pawn != null && !pawn.Destroyed && !pawn.Dead && pawn.needs == null) { Log.Error(pawn.ToStringSafe() + " has null needs tracker even though he's not dead. Fixing..."); pawn.needs = new Pawn_NeedsTracker(pawn); pawn.needs.SetInitialLevels(); } History history = obj as History; if (history != null && history.archive == null) { history.archive = new Archive(); } WorldInfo worldInfo = obj as WorldInfo; if (worldInfo != null && worldInfo.persistentRandomValue == 0) { worldInfo.persistentRandomValue = Rand.Int; } Caravan caravan = obj as Caravan; if (caravan != null) { if (caravan.forage == null) { caravan.forage = new Caravan_ForageTracker(caravan); } if (caravan.needs == null) { caravan.needs = new Caravan_NeedsTracker(caravan); } if (caravan.carryTracker == null) { caravan.carryTracker = new Caravan_CarryTracker(caravan); } if (caravan.beds == null) { caravan.beds = new Caravan_BedsTracker(caravan); } } PlaySettings playSettings = obj as PlaySettings; if (playSettings != null) { playSettings.defaultCareForColonyHumanlike = MedicalCareCategory.Best; playSettings.defaultCareForColonyAnimal = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForColonyPrisoner = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForNeutralFaction = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForNeutralAnimal = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForHostileFaction = MedicalCareCategory.HerbalOrWorse; } } if (Scribe.mode == LoadSaveMode.LoadingVars) { Hediff hediff = obj as Hediff; if (hediff != null) { Scribe_Values.Look(ref hediff.temp_partIndexToSetLater, "partIndex", -1); } Bill_Medical bill_Medical = obj as Bill_Medical; if (bill_Medical != null) { Scribe_Values.Look(ref bill_Medical.temp_partIndexToSetLater, "partIndex", -1); } FactionRelation factionRelation = obj as FactionRelation; if (factionRelation != null) { bool value = false; Scribe_Values.Look(ref value, "hostile", defaultValue: false); if (value || factionRelation.goodwill <= -75) { factionRelation.kind = FactionRelationKind.Hostile; } else if (factionRelation.goodwill >= 75) { factionRelation.kind = FactionRelationKind.Ally; } } HediffComp_GetsPermanent hediffComp_GetsPermanent = obj as HediffComp_GetsPermanent; if (hediffComp_GetsPermanent != null) { bool value2 = false; Scribe_Values.Look(ref value2, "isOld", defaultValue: false); if (value2) { hediffComp_GetsPermanent.isPermanentInt = true; } } if (obj is World) { UniqueIDsManager target = null; Scribe_Deep.Look(ref target, "uniqueIDsManager"); if (target != null) { Current.Game.uniqueIDsManager = target; } } WorldFeature worldFeature = obj as WorldFeature; if (worldFeature != null && worldFeature.maxDrawSizeInTiles == 0f) { Vector2 value3 = Vector2.zero; Scribe_Values.Look(ref value3, "maxDrawSizeInTiles"); worldFeature.maxDrawSizeInTiles = value3.x; } } if (Scribe.mode != LoadSaveMode.ResolvingCrossRefs) { return; } Hediff hediff2 = obj as Hediff; if (hediff2 != null && hediff2.temp_partIndexToSetLater >= 0 && hediff2.pawn != null) { if (hediff2.temp_partIndexToSetLater == 0) { hediff2.Part = hediff2.pawn.RaceProps.body.GetPartAtIndex(hediff2.temp_partIndexToSetLater); } else { hediff2.pawn.health.hediffSet.hediffs.Remove(hediff2); } hediff2.temp_partIndexToSetLater = -1; } Bill_Medical bill_Medical2 = obj as Bill_Medical; if (bill_Medical2 != null) { if (bill_Medical2.temp_partIndexToSetLater == 0) { bill_Medical2.Part = bill_Medical2.GiverPawn.RaceProps.body.GetPartAtIndex(bill_Medical2.temp_partIndexToSetLater); } else { bill_Medical2.GiverPawn.BillStack.Bills.Remove(bill_Medical2); } bill_Medical2.temp_partIndexToSetLater = -1; } }
public ServerEditScript(WorldInfo info) { this.info = info; }
public WorldInfo() { Debug.LogError("[WORLD INFO] WorldInfo"); instance = this; }
private void openInfoOverlay(WorldInfo info) { string text = ProfileLoginWindow.getWorldShortDesc(info); this.infoOverlay.Visible = true; if (InfoOverlayHeadings[info.KingdomsWorldID] == null) { Image image = WebStyleButtonImage.Generate(260, this.WebButtonheight + 4, text, this.WebTextFontBoldCond, ARGBColors.White, this.WebButtonRed, this.WebButtonRadius); InfoOverlayHeadings[info.KingdomsWorldID] = image; } this.infoOverlayHeading.Image = (Image) InfoOverlayHeadings[info.KingdomsWorldID]; this.infoOverlayDurationValue.Text = "?"; this.infoOverlayGameAgeValue.Text = "?"; this.infoOverlayHousesValue.Text = "?"; this.infoOverlayActivePlayersValue.Text = "?"; if (InfoOverlayData[info.KingdomsWorldID] == null) { URLs.GameRPCAddress = info.HostExt; RemoteServices.Instance.init(URLs.GameRPC); RemoteServices.Instance.set_WorldInfo_UserCallBack(new RemoteServices.WorldInfo_UserCallBack(this.WorldInfoCallback)); RemoteServices.Instance.WorldInfo(); } else { this.infoOverlayFillinData((WorldInfoData) InfoOverlayData[info.KingdomsWorldID]); } }