static void Main(string[] args) { //powtarzamy czynnosci az nam się uda while (true) { //nie rozumiem ponizszego - po co przekazywac metode nasluchujaca ?? agentTomek = new AgentAPI(Listen); //tworzymy nowe AgentAPI, podając w parametrze naszą metodę nasłuchującą // pobieramy parametry połączenia i agenta z klawiatury Console.Write("Podaj IP serwera: "); String ip = Console.ReadLine(); Console.Write("Podaj nazwe druzyny: "); String groupname = Console.ReadLine(); Console.Write("Podaj haslo: "); String grouppass = Console.ReadLine(); Console.Write("Podaj nazwe swiata: "); String worldname = Console.ReadLine(); Console.Write("Podaj imie: "); String imie = Console.ReadLine(); try { //łączymy się z serwerem. Odbieramy parametry świata i wyświetlamy je cennikSwiata = agentTomek.Connect(ip, 6008, groupname, grouppass, worldname, imie); Console.WriteLine(cennikSwiata.initialEnergy + " - Maksymalna energia"); Console.WriteLine(cennikSwiata.maxRecharge + " - Maksymalne doładowanie"); Console.WriteLine(cennikSwiata.sightScope + " - Zasięg widzenia"); Console.WriteLine(cennikSwiata.hearScope + " - Zasięg słyszenia"); Console.WriteLine(cennikSwiata.moveCost + " - Koszt chodzenia"); Console.WriteLine(cennikSwiata.rotateCost + " - Koszt obrotu"); Console.WriteLine(cennikSwiata.speakCost + " - Koszt mówienia"); //ustawiamy nasza energie na poczatkowa energie kazdego agenta w danym swiecie energy = cennikSwiata.initialEnergy; //przechodzimy do obslugi zdarzen z klawiatury. Zamiast tej funkcji wstaw logikę poruszania się twojego agenta. KeyReader(); //na koncu rozlaczamy naszego agenta agentTomek.Disconnect(); Console.ReadKey(); break; } //w przypadku mało poważnego błędu, jak podanie złego hasła, rzucany jest wyjątek NonCriticalException; zaczynamy od nowa catch (NonCriticalException ex) { Console.WriteLine(ex.Message); } // w przypadku każdego innego wyjątku niż NonCriticalException powinniśmy zakończyć program; taki wyjątek nie powinien się zdarzyć catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); } } }
public GameController(Rectangle worldBoundary, GameSettings pGameSettings) { ballManager = new GraphicalManager(); stickFigureManager = new GraphicalManager(); ballManager.Collided += BallManagerOnCollided; particleSystem = new ParticleSystem(); worldParameters = new WorldParameters(GRAVITY, DAMPING, worldBoundary); Vector2 startLocation = new Vector2(worldBoundary.X + worldBoundary.Width / 2, worldBoundary.Y + worldBoundary.Height - 25); playerTurret = new Turret(startLocation, TURRET_START_ANGLE, TURRET_START_LENGTH, TURRET_BASE_WIDTH, TURRET_BASE_HEIGHT, TURRET_WIDTH); ballRadius = BALL_RADIUS; blastSound = new SoundPlayer(Resources.Blast); flyAwaySound = new SoundPlayer(Resources.Comical_sounds_1); gameSettings = pGameSettings; AllowThrow = true; RightArrowPressed = false; LeftArrowPressed = false; PlaySounds = true; ShouldFire = false; Paused = false; selectedBall = null; rightClickedBall = null; mouseLocation = new Vector2(0, 0); selectedVector = new Vector2(0, 0); }
public static float GetParameterValue(WorldParameters parameter, int firstIndex, int secondIndex, float lerpAmount) { float valueOne = worldParametersList[parameter][firstIndex]; float valueTwo = worldParametersList[parameter][secondIndex]; return(MathHelper.Lerp(valueOne, valueTwo, lerpAmount)); }
static void IocBind(WorldParameters param) { _worldParameters = param; if (string.IsNullOrEmpty(_settingsManager.Settings.DatabasePath)) { _settingsManager.Settings.DatabasePath = Path.Combine(XmlSettingsManager.GetFilePath("", SettingsStorage.ApplicationData), "Server", "MultiPlayer", param.Seed.ToString(), "ServerWorld.db"); } Console.WriteLine("Database path is " + _settingsManager.Settings.DatabasePath); _sqLiteStorageManager = new SqliteStorageManager(_settingsManager.Settings.DatabasePath, null, param); IWorldProcessor processor = null; IEntitySpawningControler entitySpawningControler = null; switch (param.Configuration.WorldProcessor) { case WorldConfiguration.WorldProcessors.Flat: processor = new FlatWorldProcessor(); break; case WorldConfiguration.WorldProcessors.Utopia: processor = new UtopiaProcessor(param, _serverFactory, new LandscapeBufferManager()); entitySpawningControler = new UtopiaEntitySpawningControler((UtopiaWorldConfiguration)param.Configuration); break; default: break; } _worldGenerator = new WorldGenerator(param, processor); _worldGenerator.EntitySpawningControler = entitySpawningControler; }
private void readWorldParameters() { using (StreamReader r = new StreamReader("./Raw/WorldGeneration.json")) { string jsonParameters = r.ReadToEnd(); worldParameters = JsonConvert.DeserializeObject <WorldParameters>(jsonParameters); } }
public SinglePlayerComponent(Game game, D3DEngine engine, MainScreen screen, SandboxCommonResources commonResources, WorldParameters currentWorldParameter, RealmRuntimeVariables var, GuiManager guiManager) : base(game, engine, screen, commonResources) { _engine = engine; _guiManager = guiManager; _vars = var; _currentWorldParameter = currentWorldParameter; }
public IWorldParameters ToObject(IWorldBindableParameters wrapper) { WorldParameters p = new WorldParameters(); p.BitmapResolutionString = wrapper.BitmapResolutionString; p.ErosionStrength = wrapper.ErosionStrength; p.RiverAmount = wrapper.RiverAmount; return(p); }
public World(WorldParameters parameters) { _unitHandler = new WorldUnitHandler(this); Parameters = parameters; Helper = new Helper(this); new WorldGenerator().Generate(this); }
public SavedGamePanel(SandboxCommonResources commonResources, WorldParameters currentWorldParameter, RealmRuntimeVariables vars) { _vars = vars; _currentWorldParameter = currentWorldParameter; _commonResources = commonResources; InitializeComponent(); this.IsVisible = true; this.IsRendable = false; }
void RecreateWorld(WorldParameters worldParams) { DestroyWorld(); _world = GameObject.Instantiate(WorldPrefab, transform); _world.name = "World"; _world.Initialize(worldParams); Camera.transform.position = _world.Center + Vector3.up * 10; Camera.transform.LookAt(_world.Center); }
public override void Update(WorldParameters worldParameters) { base.Update(worldParameters); foreach (IGraphicalItem graphicalItem in destroyedItems) { RemoveItem(graphicalItem); } destroyedItems.Clear(); }
private static WorldParameters ExtractInformationData(string DBPath, out DateTime fileTimeStamp) { WorldParameters worldParameters = null; FileInfo fi = new FileInfo(DBPath); fileTimeStamp = fi.LastWriteTime; SQLiteConnectionStringBuilder csb = new SQLiteConnectionStringBuilder { SyncMode = SynchronizationModes.Off, DataSource = DBPath, ReadOnly = true }; SQLiteConnection connection = new SQLiteConnection(csb.ConnectionString); try { connection.Open(); using (var cmd = connection.CreateCommand()) { cmd.CommandText = "SELECT * FROM WorldParameters"; using (var dataReader = cmd.ExecuteReader()) { dataReader.Read(); //RealmConfiguration configuration = new RealmConfiguration(); //using (var ms = new MemoryStream((byte[])dataReader.GetValue(2))) //{ // configuration.Load(new BinaryReader(ms)); //} //Load configuration File from file (not from DB) WorldConfiguration configuration = WorldConfiguration.LoadFromFile(Path.GetDirectoryName(DBPath) + @"\" + Path.GetFileNameWithoutExtension(DBPath) + ".realm"); worldParameters = new WorldParameters() { WorldName = dataReader.GetString(0), SeedName = dataReader.GetString(1), Configuration = configuration }; } } connection.Close(); connection.Dispose(); } catch (Exception e) { logger.Error("Error ({1}) loading single player world data information for file {0}", DBPath, e.Message); } return(worldParameters); }
public void Update(WorldParameters parameters) { Velocity.Y += parameters.Gravity; Location += Velocity; LifeSpan = Math.Max(LifeSpan - 1, 0); if (LifeSpan <= 0 && !Immortal) { Destroy(); } }
public VisualWorldParameters(WorldParameters worldParameters, IDynamicEntity player, Vector2I visibleChunkInWorld, CubeTexturesManager cubeTextureManager) { CubeTextureManager = cubeTextureManager; VisibleChunkInWorld = visibleChunkInWorld; WorldParameters = worldParameters; //Find the chunk location int X = (MathHelper.Floor(player.Position.X / 16) * 16) - ((VisibleChunkInWorld.X / 2) * 16); int Z = (MathHelper.Floor(player.Position.Z / 16) * 16) - ((VisibleChunkInWorld.Y / 2) * 16); WorldChunkStartUpPosition = new Vector3I(X, 0, Z); }
public UtopiaProcessor(WorldParameters worldParameters, EntityFactory entityFactory, LandscapeBufferManager landscapeEntityManager) { _worldParameters = worldParameters; _entityFactory = entityFactory; _config = (UtopiaWorldConfiguration)worldParameters.Configuration; _biomeHelper = new BiomeHelper(_config); _worldGeneratedHeight = _config.ProcessorParam.WorldGeneratedHeight; _landscapeBufferManager = landscapeEntityManager; LandscapeEntities = new LandscapeEntities(_landscapeBufferManager, _worldParameters); _spawnControler = new UtopiaEntitySpawningControler(_config); landscapeEntityManager.Processor = this; }
/// <summary> /// Creates new instance of SQLite storage manager /// </summary> /// <param name="filePath"></param> /// <param name="factory"></param> public SqliteStorageManager(string filePath, EntityFactory factory, WorldParameters worldParam) : base(filePath) { CreateQueryTemplates(); if (_isDataBaseCreated) { //Create Database file with configuration information InsertWorldParametersData(worldParam, filePath); } _factory = factory; }
/// <summary> /// Initializes instance of world generator /// </summary> /// <param name="worldParameters">World parameters object</param> /// <param name="processors">Arbitrary amount of world processors</param> public WorldGenerator(WorldParameters worldParameters, params IWorldProcessor[] processors) { if (worldParameters == null) { throw new ArgumentNullException("worldParameters"); } WorldParameters = worldParameters; foreach (var processor in processors) { _processors.Add(processor); if (processor is IWorldProcessorBuffered) { _bufferedProcessors.Add(processor as IWorldProcessorBuffered); } } }
public Tile SpawnTile(WorldParameters worldParameters, int column, int row) { var position = new Vector2(column, row); var instance = GameObject.Instantiate(worldParameters.Data.Prefabs.Tile, worldParameters.Root); instance.name = string.Format("Tile {0}/{1}", column, row); instance.transform.SetGridPosition(position); instance.Initialize(Helper); _tiles.Add(position, instance); TileAdded?.Invoke(instance); return(instance); }
public void Initialize(WorldParameters worldParams) { Debug.Assert(_params == null); _params = worldParams; _cellsRoot = CreateGroup("Cells"); _unitsRoot = CreateGroup("Units"); for (int x = 0; x < worldParams.Width; ++x) { for (int z = 0; z < worldParams.Height; ++z) { GameObject.Instantiate( CellPrefab, new Vector3(x, 0, z), Quaternion.identity, _cellsRoot); } } }
/// <summary> /// ファイル読込を押したときの処理 /// </summary> private void button_input_Click(object sender, EventArgs e) { // 音声ファイル選択用のダイアログを表示 OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "音声(.wav,.mp3)|*.wav;*.mp3"; if (ofd.ShowDialog() == DialogResult.OK) { // 音声分析 wp = WorldAnalysis.Analyse(ofd.FileName); // ピッチをグラフに表示 chart1.Series[0].Points.Clear(); foreach (var f in wp.f0) { chart1.Series[0].Points.Add(f); } numericUpDown1.Maximum = wp.f0_length - 1; } }
private void InsertWorldParametersData(WorldParameters worldParam, string filePath) { _worldParametersInsertCmd.Parameters[0].Value = worldParam.WorldName; _worldParametersInsertCmd.Parameters[1].Value = worldParam.SeedName; //Binary serialize the Configuration object into an array of byte[] //using (var ms = new MemoryStream()) //{ // var writer = new BinaryWriter(ms); // worldParam.Configuration.Save(writer); // byte[] ConfigurationBytes = ms.ToArray(); // _worldParametersInsertCmd.Parameters[2].Value = ConfigurationBytes; //} //Save also the RealmConfiguration as binary file worldParam.Configuration.SaveToFile(Path.GetDirectoryName(filePath) + @"\" + Path.GetFileNameWithoutExtension(filePath) + ".realm"); //Launch the insert _worldParametersInsertCmd.ExecuteNonQuery(); }
void DebugLocation(int x, int y) { WorldParameters wp = UniversalWorldParameters; float DistorsionX = Mathf.Lerp(-wp.FrequencyDistortionRange, wp.FrequencyDistortionRange, Mathf.PerlinNoise(x * wp.FrequencyDistortionFreq, y * wp.FrequencyDistortionFreq)); float DistorsionY = Mathf.Lerp(-wp.FrequencyDistortionRange, wp.FrequencyDistortionRange, Mathf.PerlinNoise(x * wp.FrequencyDistortionFreq + 90, y * wp.FrequencyDistortionFreq + 50)); float Distorsion2X = Mathf.Lerp(-wp.FrequencyDistortion2Range, wp.FrequencyDistortion2Range, Mathf.PerlinNoise(x * wp.FrequencyDistortion2Freq + DistorsionX, y * wp.FrequencyDistortion2Freq + DistorsionY)); float Distorsion2Y = Mathf.Lerp(-wp.FrequencyDistortion2Range, wp.FrequencyDistortion2Range, Mathf.PerlinNoise(x * wp.FrequencyDistortion2Freq + DistorsionX + 90, y * wp.FrequencyDistortion2Freq + DistorsionY + 50)); float Distorsion3X = Mathf.Lerp(-wp.FrequencyDistortion3Range, wp.FrequencyDistortion3Range, Mathf.PerlinNoise(x * wp.FrequencyDistortion3Freq + Distorsion2X, y * wp.FrequencyDistortion3Freq + Distorsion2Y)); float Distorsion3Y = Mathf.Lerp(-wp.FrequencyDistortion3Range, wp.FrequencyDistortion3Range, Mathf.PerlinNoise(x * wp.FrequencyDistortion3Freq + Distorsion2X + 90, y * wp.FrequencyDistortion3Freq + Distorsion2Y + 50)); float Frequency = Mathf.Lerp(wp.Frequency + Distorsion3X, wp.Frequency + Distorsion3Y, Mathf.PerlinNoise(x * wp.FrequencyFreq, y * wp.FrequencyFreq)); float Amplitude = Mathf.Lerp(wp.AmplitudeMin, wp.AmplitudeMax, Mathf.PerlinNoise(x * wp.AmplitudeFreq, y * wp.AmplitudeFreq)); float Lacunarity = Mathf.Lerp(wp.LacunarityMin, wp.LacunarityMax, Mathf.PerlinNoise(x * wp.LacunarityFreq, y * wp.LacunarityFreq)); float AltitudeErosion = Mathf.Lerp(wp.AltitudeErosionMin, wp.AltitudeErosionMax, Mathf.PerlinNoise(x * wp.AltitudeErosionFreq, y * wp.AltitudeErosionFreq)); float RidgeErosion = Mathf.Lerp(wp.RidgeErosionMin, wp.RidgeErosionMax, Mathf.PerlinNoise(x * wp.RidgeErosionFreq, y * wp.RidgeErosionFreq)); float SlopeErosion = Mathf.Lerp(wp.SlopeErosionMin, wp.SlopeErosionMax, Mathf.PerlinNoise(x * wp.SlopeErosionFreq, y * wp.SlopeErosionFreq)); float Gain = Mathf.Lerp(wp.GainMin, wp.GainMax, Mathf.PerlinNoise(x * wp.GainFreq, y * wp.GainFreq)); float Sharpness = Mathf.Lerp(wp.SharpnessMin, wp.SharpnessMax, Mathf.SmoothStep(0, 1f, Mathf.PerlinNoise(x * wp.SharpnessFreq, y * wp.SharpnessFreq))); //float FeatureAmplifier = Mathf.Lerp(0f, 0.09f, Mathf.PerlinNoise(x*0.0043f,y*0.0043f)); float[] octfeatureamplifer = new float[8]; for (int i = 0; i < 8; i++) { octfeatureamplifer[i] = Mathf.Lerp(wp.OctavesParams[i].FeatureAmplifierMin, wp.OctavesParams[i].FeatureAmplifierMax, Mathf.PerlinNoise(x * wp.OctavesParams[i].FeatureAmplifierFreq, y * wp.OctavesParams[i].FeatureAmplifierFreq)); } XnaGeometry.Vector3 n = OTNM.Tools.Accessing.GetUberNoise(new XnaGeometry.Vector2(x * Frequency, y * Frequency), fn, 0, 8, Sharpness, octfeatureamplifer, AltitudeErosion, RidgeErosion, SlopeErosion, Lacunarity, Gain, wp.SlopeGainKeeper) * Amplitude; Debug.Log("--DEBUG NOISE PROGRAM--"); Debug.Log("RESULTS: nx(" + n.x + "), ny(" + n.y + "), nz(" + n.z + ")"); Debug.Log("SEED: " + 0); Debug.Log("OCTAVES: " + 8); Debug.Log("TERRAIN SHAPES: altErosion(" + AltitudeErosion + "), ridgeErosion(" + RidgeErosion + "), slopeErosion(" + SlopeErosion + ")"); Debug.Log("MAIN NOISE PARAMETERS: gain(" + Gain + "), lacunarity(" + Lacunarity + "), ampl(" + Amplitude + ", baseFreq(" + Frequency + ")"); }
void CalcOrientation(float travelT, float horzDeviationT, WorldParameters worldParams, out Vector3 actorPosition, out Quaternion actorRotation) { // travelT ranges from [0,1] float ringAngle = 720f * travelT; float axialAngle = 360f * travelT; Quaternion ringRotation = Quaternion.AngleAxis(ringAngle, (positive ? Vector3.right : Vector3.left)); Vector3 up = ringRotation * Vector3.up; Vector3 fwd = ringRotation * (positive ? Vector3.forward : Vector3.back); Quaternion axialRotation = Quaternion.AngleAxis(axialAngle, (positive ? Vector3.back : Vector3.forward)); actorRotation = ringRotation * axialRotation * (positive ? Quaternion.identity : Quaternion.AngleAxis(180f, Vector3.up)); Vector3 majorOffset = up * worldParams.majorRadius; Vector3 localMinorOffset = (Vector3.up * worldParams.halfThickness) + (Vector3.right * worldParams.halfWidth * horzDeviationT); Vector3 minorOffset = actorRotation * localMinorOffset; actorPosition = majorOffset + minorOffset; }
static void Main(string[] args) { //powtarzamy czynnosci az nam się uda while (true) { agentVLuke_Jones = new AgentAPI(Listen); //tworzymy nowe AgentAPI, //podając w parametrze naszą metodę nasłuchującą // pobieramy parametry połączenia i agenta z klawiatury Console.Write("Wczytano IP serwera.\n"); String ip = "atlantyda.vm.wmi.amu.edu.pl"; Console.Write("Wczytano nazwe druzyny.\n"); groupname = "VLuke_Jones"; Console.Write("Wprowadzono haslo.\n"); String grouppass = "******"; Console.Write("Podaj nazwe swiata: "); String worldname = Console.ReadLine(); Console.Write("Podaj imie: "); imie = Console.ReadLine(); try { //łączymy się z serwerem. Odbieramy parametry świata i wyświetlamy je cennikSwiata = agentVLuke_Jones.Connect(ip, 6008, groupname, grouppass, worldname, imie); Console.WriteLine(cennikSwiata.initialEnergy + " - Maksymalna energia"); Console.WriteLine(cennikSwiata.maxRecharge + " - Maksymalne doładowanie"); Console.WriteLine(cennikSwiata.sightScope + " - Zasięg widzenia"); Console.WriteLine(cennikSwiata.hearScope + " - Zasięg słyszenia"); Console.WriteLine(cennikSwiata.moveCost + " - Koszt chodzenia"); Console.WriteLine(cennikSwiata.rotateCost + " - Koszt obrotu"); Console.WriteLine(cennikSwiata.speakCost + " - Koszt mówienia"); smallestCost = cennikSwiata.moveCost; if (smallestCost > cennikSwiata.rotateCost) smallestCost = cennikSwiata.rotateCost; if (smallestCost > cennikSwiata.speakCost) smallestCost = cennikSwiata.speakCost; kosztDoZrodla = -1; Console.Write("Wybierz tryb:\n(0)Random\n(1)SmartBot\n(2)Klawiatura\n"); String tryb = Console.ReadLine(); pozycjaRozmowcy = new int[2]; pozycjaRozmowcy[0] = -1000; pozycjaRozmowcy[1] = -1000; kierunekRozmowcy = 0; czyRozmawiam = false; gracz = false; myBot = new AIMLbot.Bot(); myBot.loadSettings(); myBot.loadAIMLFromFiles(); //ustawiamy nasza energie na poczatkowa energie kazdego agenta w danym swiecie myEnergy = cennikSwiata.initialEnergy; if (tryb == "0") Zachowanie("Random"); if (tryb == "1") Zachowanie("SmartBot"); if (tryb == "2") { gracz = true; KeyReader(); } //na koncu rozlaczamy naszego agenta try { agentVLuke_Jones.Disconnect(); } catch (Exception e) { Console.WriteLine("Disconnected with problems! " + e.Message); } Console.ReadKey(); break; } //w przypadku mało poważnego błędu, jak podanie złego hasła, //rzucany jest wyjątek NonCriticalException; zaczynamy od nowa catch (NonCriticalException ex) { Console.WriteLine(ex.Message); } // w przypadku każdego innego wyjątku niż NonCriticalException //powinniśmy zakończyć program; taki wyjątek nie powinien się zdarzyć catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); } } }
static void Main(string[] args) { try { // Tworzymy instancję naszego agenta agent = new AgentAPI(Listen); // Dane do świata String ip = "atlantyda.vm.wmi.amu.edu.pl"; String groupname = "VGrupa1"; String grouppass = "******"; String worldname = "VGrupa1"; Random r = new Random(); String imie = agentName = "Sasha" + r.Next(1, 999); // Próbujemy się połączyć z serwerem worldParameters = agent.Connect(ip, 6008, groupname, grouppass, worldname, imie); // Inicjalizacja energii energy = worldParameters.initialEnergy; // Uruchamiamy agenta bez zbędnych komunikatów debugMode = true; Console.WriteLine("Wcisnij dowolny klawisz, aby uruchomic agenta."); Console.ReadKey(); while (true) { try { DoBestMovement(); } catch (NonCriticalException ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); break; } //System.Threading.Thread.Sleep(2000); } // Kończymy agent.Disconnect(); } catch { Console.WriteLine("Wystapily jakies bledy przy podlaczaniu do swiata! :("); } Console.ReadKey(); }
public WorldGenerator(WorldParameters worldParameters, IWorldProcessorConfig processorsConfig) : this(worldParameters, processorsConfig.WorldProcessors) { }
static void Main(string[] args) { Console.WriteLine("0 - atlantyda.vm, 1 - localhost"); String ktory = Console.ReadLine(); int liczba = Int32.Parse(ktory); punkty.Add(new MapPoint(0, 0, true, 0, false, 0, 2)); while (true) { agentTomek = new AgentAPI(Listen); String ip = Settings.serverIP; String groupname = Settings.groupname; String grouppass = Settings.grouppass; if (liczba == 0) ip = "atlantyda.vm.wmi.amu.edu.pl"; else ip = "localhost"; groupname = "ZeloweMisie"; if (liczba == 0) grouppass = "******"; else grouppass = "******"; Console.Write("Podaj nazwe swiata: "); String worldname = Console.ReadLine(); Console.Write("Podaj imie: "); imie = Console.ReadLine(); string fileName = "Default.aiml"; string sourcePath = @".\aiml\schemat\"; string targetPath = @".\aiml\"; if (File.Exists("aiml\\" + imie + ".aiml")) File.Delete("aiml\\" + imie + ".aiml"); string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, imie + ".aiml"); File.Copy(sourceFile, destFile); DoAIML aiml = new DoAIML(imie + ".aiml"); aiml.zapis("imie", imie); myBot = new cBot(false); try { cennikSwiata = agentTomek.Connect(ip, 6008, groupname, grouppass, worldname, imie); Console.WriteLine(cennikSwiata.initialEnergy + " - Maksymalna energia"); Console.WriteLine(cennikSwiata.maxRecharge + " - Maksymalne doładowanie"); Console.WriteLine(cennikSwiata.sightScope + " - Zasięg widzenia"); Console.WriteLine(cennikSwiata.hearScope + " - Zasięg słyszenia"); Console.WriteLine(cennikSwiata.moveCost + " - Koszt chodzenia"); Console.WriteLine(cennikSwiata.rotateCost + " - Koszt obrotu"); Console.WriteLine(cennikSwiata.speakCost + " - Koszt mówienia"); energy = cennikSwiata.initialEnergy; KeyReader(); agentTomek.Disconnect(); Console.ReadKey(); break; } catch (NonCriticalException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); break; } } }
public LandscapeEntities(LandscapeBufferManager entityManager, WorldParameters worldParameters) { _entityManager = entityManager; _worldParameters = worldParameters; }
static void Main(string[] args) { while (true) { agentTomek = new AgentAPI(Listen); String ip = Settings.serverIP; String groupname = Settings.groupname; String grouppass = Settings.grouppass; if (ip == null) { Console.Write("Podaj IP serwera: "); ip = Console.ReadLine(); } if (groupname == null) { Console.Write("Podaj nazwe druzyny: "); groupname = "VGrupaX";// Console.ReadLine(); } if (grouppass == null) { Console.Write("Podaj haslo: "); grouppass = "******"; //Console.ReadLine(); } Console.Write("Podaj nazwe swiata: "); String worldname = "VGrupaX"; //Console.ReadLine(); Console.Write("Podaj imie: "); String imie = Console.ReadLine(); try { cennikSwiata = agentTomek.Connect(ip, 6008, groupname, grouppass, worldname, imie); Console.WriteLine(cennikSwiata.initialEnergy + " - Maksymalna energia"); Console.WriteLine(cennikSwiata.maxRecharge + " - Maksymalne doładowanie"); Console.WriteLine(cennikSwiata.sightScope + " - Zasięg widzenia"); Console.WriteLine(cennikSwiata.hearScope + " - Zasięg słyszenia"); Console.WriteLine(cennikSwiata.moveCost + " - Koszt chodzenia"); Console.WriteLine(cennikSwiata.rotateCost + " - Koszt obrotu"); Console.WriteLine(cennikSwiata.speakCost + " - Koszt mówienia"); energy = cennikSwiata.initialEnergy; lookMatrixW = cennikSwiata.sightScope; lookMatrixW = lookMatrixW * lookMatrixW + 1; lookMatrix = new String[lookMatrixW][]; for (int i = 0; i < lookMatrixW; i++) lookMatrix[i] = new String[lookMatrixW]; Alive(); agentTomek.Disconnect(); Console.ReadKey(); break; } catch (NonCriticalException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); break; } } }
public void injectRenderCmds(Pass pass) { if (myEditor.active == true) { if (myMultiSelect == true) { foreach (NodeLocation n in mySelectedNodes) { StatelessRenderCommand cmd = new RenderWireframeCubeCommand(n.min(), n.min() + new Vector3(n.size() + 0.001f), Color4.Blue); cmd.pipelineState.culling.enabled = false; cmd.pipelineState.depthTest.enabled = true; cmd.pipelineState.depthTest.depthFunc = DepthFunction.Lequal; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); } } if (myCurrentHit != null) { switch (myEditor.activeMode) { case "Block Mode": { StatelessRenderCommand cmd = new RenderWireframeCubeCommand(myClampedLocation.worldLocation(), myClampedLocation.worldLocation() + new Vector3(WorldParameters.sizeAtDepth(myEditor.cursorDepth) + 0.001f), Color4.OrangeRed); cmd.pipelineState.culling.enabled = false; cmd.pipelineState.depthTest.enabled = true; cmd.pipelineState.depthTest.depthFunc = DepthFunction.Lequal; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); if (myCurrentHit.face != Face.NONE) { Vector3[] verts = getFaceVerts(myClampedLocation, myCurrentHit.face); cmd = new RenderTexturedQuadCommand(verts, mySelectTexture); cmd.pipelineState.culling.enabled = false; cmd.pipelineState.depthTest.enabled = false; cmd.renderState.polygonOffset.enableType = PolygonOffset.EnableType.FILL; cmd.renderState.polygonOffset.factor = 1.0f; cmd.renderState.polygonOffset.units = 1.0f; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); } break; } case "Edge Mode": { if (myCurrentHit.face != Face.NONE && myCurrentHit.edge == -1) { Vector3[] verts = getFaceVerts(myClampedLocation, myCurrentHit.face); StatelessRenderCommand cmd = new RenderTexturedQuadCommand(verts, mySelectTexture); cmd.pipelineState.culling.enabled = false; cmd.pipelineState.depthTest.enabled = false; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); } if (myCurrentHit.edge != -1) { Vector3[] verts = getEdgeVerts(myClampedLocation, myCurrentHit.edge); StatelessRenderCommand cmd = new RenderLineCommand(verts[0], verts[1], Color4.Aquamarine); cmd.pipelineState.depthTest.enabled = false; cmd.pipelineState.depthWrite.enabled = false; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); } if (myCurrentHit.vert != -1) { Vector3 vert = getVert(myClampedLocation, myCurrentHit.vert); RenderCommand cmd = new RenderSphereCommand(vert, myClampedLocation.node.size() / 12, Color4.Red); pass.postCommands.Add(cmd); } break; } case "Face Mode": { if (myCurrentHit.face != Face.NONE) { foreach (NodeLocation n in mySelectedNodes) { Vector3[] verts = getFaceVerts(n, myCurrentHit.face); StatelessRenderCommand cmd = new RenderQuadCommand(verts, Color4.Blue); cmd.pipelineState.culling.enabled = false; cmd.pipelineState.depthTest.enabled = false; cmd.pipelineState.generateId(); cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); cmd.renderState.wireframe.enabled = true; cmd.renderState.polygonOffset.enableType = PolygonOffset.EnableType.FILL; cmd.renderState.polygonOffset.factor = -1.0f; cmd.renderState.polygonOffset.units = 1.0f; cmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(cmd); } Vector3[] mverts = getFaceVerts(myClampedLocation, myCurrentHit.face); StatelessRenderCommand mcmd = new RenderQuadCommand(mverts, Color4.LightBlue); mcmd.pipelineState.culling.enabled = false; mcmd.pipelineState.depthTest.enabled = false; mcmd.pipelineState.generateId(); mcmd.renderState.wireframe.enabled = true; mcmd.renderState.polygonOffset.enableType = PolygonOffset.EnableType.FILL; mcmd.renderState.polygonOffset.factor = -1.0f; mcmd.renderState.polygonOffset.units = 1.0f; mcmd.renderState.setUniformBuffer(myEditor.camera.uniformBufferId(), 0); pass.postCommands.Add(mcmd); } break; } } } } }
// Use this for initialization void Start() { if (FindObjectOfType<EventSystem>() == null) { var es = new GameObject("EventSystem", typeof(EventSystem)); es.AddComponent<StandaloneInputModule>(); es.AddComponent<TouchInputModule>(); } canvas = FindObjectOfType<Canvas>(); if (canvas == null) { var canvasObject = new GameObject("Canvas"); canvas = canvasObject.AddComponent<Canvas>(); canvasObject.AddComponent<GraphicRaycaster>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; } var panel = Instantiate(panelPrefab) as RectTransform; panel.transform.SetParent(canvas.transform); panel.anchoredPosition = Vector2.zero; panel.sizeDelta = Vector2.zero; panel.anchorMin = Vector2.zero; panel.anchorMax = Vector2.one * 0.5f; parameters = GetComponent<WorldParameters>(); Type t = parameters.GetType(); int i = 0; FieldInfo[] fs = t.GetFields(); foreach (FieldInfo ff in fs) { FieldInfo f = ff; object val = f.GetValue(parameters); if (AriscoTools.IsNumeric(ref val)) { bool isInt = AriscoTools.IsNumeric(ref val); Slider obj = Instantiate(sliderPrefab) as Slider; obj.transform.SetParent(panel.transform); if(isInt){ obj.wholeNumbers = true; } FieldAttributes fa = f.Attributes; var rect = obj.GetComponent<RectTransform>(); rect.anchoredPosition = Vector2.zero; rect.sizeDelta = Vector2.zero; rect.anchorMin = new Vector2(0, 0); rect.anchorMax = new Vector2(1, 0); rect.pivot = new Vector2(.5f, 0); rect.sizeDelta = new Vector2(0, 20); rect.anchoredPosition = new Vector2(0, 20 * i); f.SetValue(obj.value, val); obj.onValueChanged.AddListener((value) => { print(f.Name); f.SetValue(parameters, value); }); } i++; } }
protected LandscapeManager(WorldParameters wp) { _wp = wp; }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; logger.Info("Utopia Realms game server v{1} Protocol: v{0}", ServerConnection.ProtocolVersion, Assembly.GetExecutingAssembly().GetName().Version); DllLoadHelper.LoadUmnanagedLibrary("sqlite3.dll"); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "main.realm"); if (!File.Exists(path)) { if (args.Length == 0) { logger.Fatal("Could not find the realm file. Specify realm configuration file path."); return; } path = args[0]; if (!File.Exists(path)) { logger.Fatal("Could not find the realm file at " + path); return; } } _serverFactory = new EntityFactory(); EntityFactory.InitializeProtobufInheritanceHierarchy(); WorldConfiguration conf; try { conf = WorldConfiguration.LoadFromFile(path); _serverFactory.Config = conf; logger.Info("Realm file {0} loaded", path); } catch (Exception ex) { logger.Fatal("Exception when trying to load configuration:\n" + ex.Message); return; } System.Net.ServicePointManager.Expect100Continue = false; var configFileName = "server.config"; var port = 0; string desc = null; for (int i = 0; i < args.Length; i++) { var argument = args[i]; if (argument == "-conf" && args.Length > i + 1) { configFileName = args[i + 1]; } if (argument == "-port" && args.Length > i + 1) { port = int.Parse(args[i + 1]); } if (argument == "-desc" && args.Length > i + 1) { desc = args[i + 1]; } } _settingsManager = new XmlSettingsManager <ServerSettings>(@"Server\" + configFileName); _settingsManager.Load(); if (port != 0 && _settingsManager.Settings.ServerPort != port) { _settingsManager.Settings.ServerPort = port; _settingsManager.Save(); } if (string.IsNullOrEmpty(_settingsManager.Settings.Seed)) { Console.WriteLine(); Console.WriteLine("Please enter the seed:"); Console.Write("> "); _settingsManager.Settings.Seed = Console.ReadLine(); _settingsManager.Save(); } if (string.IsNullOrEmpty(_settingsManager.Settings.ServerName) || _settingsManager.Settings.ServerName == "unnamed server") { Console.WriteLine(); Console.WriteLine("Please enter the name of the server:"); Console.Write("> "); _settingsManager.Settings.ServerName = Console.ReadLine(); _settingsManager.Save(); } if (string.IsNullOrEmpty(_settingsManager.Settings.ServerDescription)) { if (desc != null) { _settingsManager.Settings.ServerDescription = desc; } else { Console.WriteLine(); Console.WriteLine("Please enter the server description:"); Console.Write("> "); _settingsManager.Settings.ServerDescription = Console.ReadLine(); _settingsManager.Save(); } } var wp = new WorldParameters { WorldName = "Utopia", SeedName = _settingsManager.Settings.Seed, Configuration = conf }; IocBind(wp); _serverWebApi = new ServerWebApi(); _server = new ServerCore( _settingsManager, _worldGenerator, new ServerUsersStorage(_sqLiteStorageManager, _serverWebApi), _sqLiteStorageManager, _sqLiteStorageManager, _sqLiteStorageManager, _serverFactory, wp ); _serverFactory.LandscapeManager = _server.LandscapeManager; _serverFactory.DynamicEntityManager = _server.AreaManager; _serverFactory.GlobalStateManager = _server.GlobalStateManager; _serverFactory.ScheduleManager = _server.Scheduler; _serverFactory.ServerSide = true; _gameplay = new ServerGameplayProvider(_server, conf); _server.ConnectionManager.Listen(); _server.LoginManager.PlayerEntityNeeded += LoginManagerPlayerEntityNeeded; _server.LoginManager.PlayerLogged += LoginManager_PlayerLogged; _server.UsersStorage.DefaultRole = _server.CustomStorage.GetVariable("DefaultRole", UserRole.Guest); // send alive message each 5 minutes _reportAliveTimer = new Timer(CommitServerInfo, null, 0, 1000 * 60 * 5); _server.EntityManager.LoadNpcs(); while (Console.ReadLine() != "exit") { Console.WriteLine("Type 'exit' to quit"); } _server.Dispose(); }
public ServerLandscapeManager(ServerCore server, IChunksStorage chunksStorage, WorldGenerator generator, EntityFactory factory, int chunkLiveTimeMinutes, int cleanUpInterval, int saveInterval, int chunksLimit, WorldParameters wp) : base(wp) { ChunkLiveTimeMinutes = chunkLiveTimeMinutes; CleanUpInterval = cleanUpInterval; SaveInterval = saveInterval; ChunkCountLimit = chunksLimit; EntityFactory = factory; if (chunksStorage == null) { throw new ArgumentNullException("chunksStorage"); } if (generator == null) { throw new ArgumentNullException("generator"); } _server = server; _chunksStorage = chunksStorage; _generator = generator; _server.ConnectionManager.ConnectionAdded += ConnectionManagerConnectionAdded; _server.ConnectionManager.ConnectionRemoved += ConnectionManagerConnectionRemoved; _cleanUpTimer = new Timer(CleanUp, null, CleanUpInterval, CleanUpInterval); _saveTimer = new Timer(SaveChunks, null, SaveInterval, SaveInterval); }
/// <summary> /// Create new instance of the Server class /// </summary> public ServerCore( XmlSettingsManager <ServerSettings> settingsManager, WorldGenerator worldGenerator, IUsersStorage usersStorage, IChunksStorage chunksStorage, IEntityStorage entityStorage, ICustomStorage customStorage, EntityFactory entityFactory, WorldParameters wp ) { // dependency injection SettingsManager = settingsManager; UsersStorage = usersStorage; EntityStorage = entityStorage; CustomStorage = customStorage; EntityFactory = entityFactory; WorldParameters = wp; if (SettingsManager.Settings == null) { SettingsManager.Load(); } var settings = SettingsManager.Settings; ConnectionManager = new ConnectionManager(SettingsManager.Settings.ServerPort); Scheduler = new ScheduleManager(); UtopiaTime startTime = CustomStorage.GetVariable <UtopiaTime>("GameTimeElapsed"); Clock = new Clock(this, startTime, TimeSpan.FromMinutes(20)); LandscapeManager = new ServerLandscapeManager( this, chunksStorage, worldGenerator, EntityFactory, settings.ChunkLiveTimeMinutes, settings.CleanUpInterval, settings.SaveInterval, settings.ChunksCountLimit, wp); EntityManager = new EntityManager(this); AreaManager = new AreaManager(this); DynamicIdHelper.SetMaxExistsId(EntityStorage.GetMaximumId()); Services = new ServiceManager(this); PerformanceManager = new PerformanceManager(AreaManager); CommandsManager = new CommandsManager(this); ChatManager = new ChatManager(this); GlobalStateManager = new GlobalStateManager(this); LoginManager = new LoginManager(this, EntityFactory); EntitySpawningManager = new EntitySpawningManager(this, worldGenerator.EntitySpawningControler); EntityGrowingManager = new Managers.EntityGrowingManager(this); }