/// <summary> /// Creates a new NPCServer /// </summary> internal Framework(string OptionsFile = "settings.ini") { // Default PM this.NCMsg = CString.tokenize ("I am the npcserver for\nthis game server. Almost\nall npc actions are controled\nby me."); // Create Compiler Compiler = new GameCompiler (this); // Create Player Manager PlayerManager = new Players.PlayerList (this, GSConn); AppSettings settings = AppSettings.GetInstance (); settings.Load (OptionsFile); // Connect to GServer GSConn = new GServerConnection (this); this.ConnectToGServer(); // Setup NPC-Control Listener cNCAccept = new AsyncCallback (NCControl_Accept); this.UPnPOpenPort(); NCListen = new TcpListener (IPAddress.Parse (this.LocalIPAddress ()), settings.NCPort); NCListen.Start (); NCListen.BeginAcceptSocket (cNCAccept, NCListen); settings.Save (); // Setup Timer //timeBeginPeriod(50); //TimerHandle = new TimerEventHandler(RunServer); //TimerId = timeSetEvent(50, 0, TimerHandle, IntPtr.Zero, EVENT_TYPE); }
/// <summary> /// Unloads all data used by this instance. (For example: compiled game) /// </summary> public void Unload() { AppDomain.Unload(processingDomain); processingDomain = null; gameCompiler = null; }
public override bool GameUpdate() { // controla o movimento age += Time.deltaTime; Vector3 p = launchPoint + launchVelocity * age; p.y -= 0.5f * 9.81f * age * age; if (p.y <= 0f) { // atingiu o solo -> detona try { Game.SpawnExplosion().Initialize(targetPoint, blastRadius, damage); } catch { GameCompiler.SpawnExplosion().Initialize(targetPoint, blastRadius, damage); } OriginFactory.Reclaim(this); return(false); } transform.localPosition = p; Vector3 d = launchVelocity; d.y -= 9.81f * age; transform.localRotation = Quaternion.LookRotation(d); try { Game.SpawnExplosion().Initialize(p, 0.1f); } catch { GameCompiler.SpawnExplosion().Initialize(p, 0.1f); } return(true); }
public void CompileNextLevel() { if (GrammarGenerator._FullGameScript != null) { generatorText = GrammarGenerator._FullGameScript; StopAllCoroutines(); _program = GameCompiler.Compile(GrammarGenerator._FullGameScript); StartCoroutine(_program.Run()); } }
public static GameProgram Compile(string source) { AntlrInputStream antlerStream = new AntlrInputStream(source); GameSetupLexer lexer = new GameSetupLexer(antlerStream); CommonTokenStream tokenStream = new CommonTokenStream(lexer); GameSetupParser parser = new GameSetupParser(tokenStream); parser.prog(); // <-- compile happens here (see .g4 file) GameCompiler compiler = parser.Compiler; GameProgram program = new GameProgram(compiler.Elements); return(program); }
public void Launch(TargetPoint target) { Vector3 launchPoint = mortar.position; Vector3 targetPoint = target.Position; targetPoint.y = 0f; Vector2 dir; dir.x = targetPoint.x - launchPoint.x; dir.y = targetPoint.z - launchPoint.z; float x = dir.magnitude; float y = -launchPoint.y; dir /= x; float g = 9.81f; float s = launchSpeed; float s2 = s * s; float r = s2 * s2 - g * (g * x * x + 2f * y * s2); Debug.Assert(r >= 0f, "Launch velocity insufficient for range!"); float tanTheta = (s2 + Mathf.Sqrt(r)) / (g * x); float cosTheta = Mathf.Cos(Mathf.Atan(tanTheta)); float sinTheta = cosTheta * tanTheta; mortar.localRotation = Quaternion.LookRotation(new Vector3(dir.x, tanTheta, dir.y)); try { Game.SpawnShell().Initialize( launchPoint, targetPoint, new Vector3(s * cosTheta * dir.x, s * sinTheta, s * cosTheta * dir.y), shellBlastRadius, shellDamage ); } catch { GameCompiler.SpawnShell().Initialize( launchPoint, targetPoint, new Vector3(s * cosTheta * dir.x, s * sinTheta, s * cosTheta * dir.y), shellBlastRadius, shellDamage ); } }
public void CompileAndRun() { if (GameObject.Find("ScriptDisplay") != null) { grammarDisplay = GameObject.Find("ScriptDisplay").GetComponent <Text>(); } if (GrammarGenerator._FullGameScript == null || GrammarGenerator._FullGameScript.Equals("")) { grammarDisplay.text = "Remember to press 'Generate Script' before creating the game!"; } else { generatorText = GrammarGenerator._FullGameScript; StopAllCoroutines(); _program = GameCompiler.Compile(GrammarGenerator._FullGameScript); StartCoroutine(_program.Run()); } }
/// <summary> /// Compiles the game from the specified source code in C#. /// </summary> /// <remarks> /// Debug build: the game is compiled and stored in the memory. The game can be later run by <see cref="RunGame"/> method. /// Release build: the game is compiled and is saved to the output directory. /// </remarks> /// <param name="sourceFilename">The filename where is to source code of the game.</param> /// <param name="buildType">Type of the build.</param> /// <param name="outputDirectory">The output directory where to save the game, if Release build.</param> /// <param name="verbose">If set to true building will be verbose via standard <see cref="Messages"/> system.</param> /// <exception cref="TargetInvocationException">Compile error.</exception> public void BuildGame(string sourceFilename, BuildType buildType, string outputDirectory = null, bool verbose = false) { if (processingDomain == null) { processingDomain = AppDomain.CreateDomain("CompilingGame:" + Guid.NewGuid(), null, AppDomain.CurrentDomain.SetupInformation); Type gameCompilerType = typeof(GameCompiler); gameCompiler = (GameCompiler)processingDomain.CreateInstanceAndUnwrap(gameCompilerType.Assembly.FullName, gameCompilerType.FullName); } if (verbose) { Messages.ShowInfo("Compiling game."); } gameCompiler.Compile(sourceFilename, buildType, outputDirectory); if (verbose) { Messages.ShowInfo("Compiling game completed."); } }
public float Progress(float deltaTime) { cooldown += deltaTime; while (cooldown >= sequence.cooldown) { cooldown -= sequence.cooldown; if (count >= sequence.amount) { return(cooldown); } count += 1; if (sequence.enemy != null) { GameCompiler.SpawnEnemy(sequence.factory, sequence.enemy); } else { // inimigo default medium GameCompiler.SpawnEnemy(sequence.factory, EnemyType.Medium); } } return(-1f); }
void OnEnable() { instance = this; }