public void GetSnapshotFromClient(BaseEntity.RPCMessage msg) { BasePlayer basePlayer = msg.player; if (basePlayer == null || basePlayer != base.GetDriver()) { return; } if (this.GetSnapshotFromClientPerSecond.Calculate() > (long)30) { return; } this.GetSnapshotFromClientPerSecond.Increment(); ArcadeGame arcadeGame = Facepunch.Pool.Get <ArcadeGame>(); arcadeGame = ArcadeGame.Deserialize(msg.read); Connection connection = null; if (this.networkTrigger.entityContents != null) { foreach (BaseEntity entityContent in this.networkTrigger.entityContents) { base.ClientRPCPlayer <ArcadeGame>(connection, entityContent.GetComponent <BasePlayer>(), "GetSnapshotFromServer", arcadeGame); } } }
/// <summary> /// Execution function for Day 13 /// </summary> public void Execute13() { UserActionAsync(() => { WriteToConsole("Start execution of Day13"); var parser = GetInputParser("Day13Input.txt"); var originalCode = parser.GetIntCode(); var code = originalCode.ToList(); var game = new ArcadeGame(code); game.Start(); var blocks = game.Tiles.Where(t => t.Id == TileId.Block).Count(); var view = game.GetGameView(); RunInUiThread(() => { var dialog = new ImageDisplay(view); dialog.Show(); }); WriteToConsole($"The number of blocks in the game is {blocks}"); game = new ArcadeGame(code); game.PlayFree(); WriteToConsole($"The final score is {game.Score}"); }); }
public void Update() { //Just add a jump if up is pressed if (ArcadeKeymap.player1.up.isDown) { jumps.Add(new Jump { time = Time.time, randNum = Random.value }); } //If the user has pressed the a key, then push data //to firebase if (ArcadeKeymap.player1.A.isDown) { //Just push the data FirebaseManager.PushList <Jump>(firebaseSettings, jumps, (firebase, snapshot) => { //Log the response Debug.Log("<b>response:</b> " + snapshot.RawJson); }); } //Has escape been pressed? If so.. then exit if (ArcadeKeymap.player1.buttonExit.isDown) { ArcadeGame.exit(); } }
/// <summary> /// Pushes a list to firebase with a single line, instead of making a new instance /// and all that jazz /// </summary> /// <param name="settings">The settings (location) to push to</param> /// <param name="obj">The list</param> /// <param name="callback">The callback to call after pushing</param> public static void PushList <T>(FirebaseSettings settings, List <T> obj, System.Action <Firebase, DataSnapshot> callback = null) { //Make a new arcade game var game = new ArcadeGame(settings); //And just call push game.logger.pushList <T>(obj, callback); }
static void Main(string[] args) { Console.WriteLine("Please enter a game to play:"); var gameChoice = Console.ReadLine(); ArcadeGame gameToPlay = _games[gameChoice]; gameToPlay.Play(); }
// Exit the game public void ExitGame() { // Quit the game ArcadeGame.exit(); // Quit game Debug.Log("EXIT GAME HAS BEEN CALLED"); }
public virtual string Solve() { var program = Parser.GetData().Split(',').Select(long.Parse).ToList(); var arcade = new ArcadeGame(program); arcade.Go(); return(arcade.BlockTileCount.ToString()); }
public void Test_DayThirteen_PartTwo() { //< Git 'er done var source = Path.Combine(TestHelper.TestDir, "Day13.Input.txt"); //< Run.. the game var game = new ArcadeGame(source); game.RunGame(); //< Check the final score is correct Assert.IsTrue(game.Score == 21415); }
public override string Solve() { var program = Parser.GetData().Split(',').Select(long.Parse).ToList(); program[0] = 2; var arcade = new ArcadeGame(program, true); arcade.Go(); return(arcade.Score.ToString()); }
// Exit the game public void ExitGame() { // Fade out music StartCoroutine(FadeMusicOut(music)); // Quit the game ArcadeGame.exit(); // Quit game Debug.Log("EXIT GAME HAS BEEN CALLED"); }
public void Test_DayThirteen_PartOne() { //< Git 'er done var source = Path.Combine(TestHelper.TestDir, "Day13.Input.txt"); //< Instantiate the game and run it var game = new ArcadeGame(source); game.TestGame(); //< Get the count of 'Block' tiles (t = 2) var numBlocks = game.Grid.CountTiles(2); //< Make sure we ain't f**k it up Assert.IsTrue(numBlocks == 452); }
public void GetSnapshotFromClient(RPCMessage msg) { BasePlayer player = msg.player; if (player == null || player != GetDriver()) { return; } ArcadeGame arcadeGame = Facepunch.Pool.Get <ArcadeGame>(); arcadeGame = ArcadeGame.Deserialize(msg.read); Connection sourceConnection = null; if (networkTrigger.entityContents == null) { return; } foreach (BaseEntity entityContent in networkTrigger.entityContents) { BasePlayer component = entityContent.GetComponent <BasePlayer>(); ClientRPCPlayer(sourceConnection, component, "GetSnapshotFromServer", arcadeGame); } }
private void OnDestroy() { ins = null; }
public void SelfDestruction() { ins = null; ResetData(); }
void Awake() { ins = this; }
// Update is called once per frame void Update() { // Set the player controls diggingAttacking = Input.GetKeyDown(ArcadeKeymap.player1.A.key); enter = Input.GetKeyDown(ArcadeKeymap.player1.A.key); dropTNT = Input.GetKeyDown(ArcadeKeymap.player1.B.key); otherAction = Input.GetKeyDown(ArcadeKeymap.player1.C.key); // Set if the up / down / left / right up = ArcadeKeymap.player1.up.isDown; down = ArcadeKeymap.player1.down.isDown; left = ArcadeKeymap.player1.left.isDown; right = ArcadeKeymap.player1.right.isDown; // Set the horzontal and vertical if (up) { vertical = 1.0f; } if (down) { vertical = -1.0f; } if (left) { horizontal = -1.0f; } if (right) { horizontal = 1.0f; } // Catch the horizontal and vertical input horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); // Set if the player is digging diggingAttacking = Input.GetKeyDown(KeyCode.Space); dropTNT = Input.GetKeyDown(KeyCode.B); otherAction = Input.GetKeyDown(KeyCode.V); // Set if the up or down arrow has been pressed up = Input.GetKeyDown(KeyCode.UpArrow); down = Input.GetKeyDown(KeyCode.DownArrow); // Catch the horizontal and vertical input horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); // If the game is idle for 30 seconds exit if (!diggingAttacking && !dropTNT && !otherAction && !up && !down && !left && !right) { idleTimer += Time.deltaTime; } else { idleTimer = 0.0f; } if (idleTimer >= idleTime) { ArcadeGame.exit(); Debug.Log("GAME IDLE - EXIT CALLED"); } }