public override string Solve_2() { HandHeld hh; int last = int.MaxValue; while (last > 0) { hh = new HandHeld(_input); for (var i = hh.Operations.Count - 1; i >= 0; i--) { if (i < last && (hh.Operations[i].Type == HandHeld.OperationType.jmp || hh.Operations[i].Type == HandHeld.OperationType.nop)) { last = i; hh.Operations[i].Type = hh.Operations[i].Type == HandHeld.OperationType.jmp ? HandHeld.OperationType.nop : HandHeld.OperationType.jmp; break; } } hh.Run(); if (hh.Status == HandHeld.RunStatus.Done) { return($"{hh.Accumulator}"); } } return($"{-1}"); }
//------------------------------------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------------------------------------ public Menu(HandHeld handHeld) : base(1366, 768) { this.handHeld = handHeld; _backgroundMusic.Play(); menuSetup(); introductionSetup(); }
//---------------------------------------------------------------------------------------------------------------------- // CONSTRICTOR //---------------------------------------------------------------------------------------------------------------------- public Level(HandHeld handheld) { this.handheld = handheld; timer = new Timer(); s = File.ReadAllLines("Levels.txt"); maxIndex = s.Length; resetmapTile(handheld); }
public override string Solve_1() { var handheld = new HandHeld(_input); handheld.Run(); return($"{handheld.Accumulator}"); }
public MyGame() : base(1366, 768, true, false) // Create a window that's 800x600 and NOT fullscreen { targetFps = 60; HandHeld handheld = new HandHeld(); Menu menu = new Menu(handheld); AddChild(menu); }
public void resetmapTile(HandHeld handheld) { if (maplevel != null) { maplevel.LateDestroy(); maplevel = null; } maplevel = new MapLevel(s[index], this, timer, handheld); AddChild(maplevel); }
//------------------------------------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------------------------------------ public Player(MapLevel mapLevel, int w, int h, Level lvl, Timer timer, float newX, float newY) : base(mapLevel, "colors.png", 0) { x = newX; y = newY; SetOrigin(width / 2, height / 2); this.width = w; this.height = h; _jump = -h; this._mapLevel = mapLevel; this.handHeld = mapLevel.handHeld; _level = lvl; _timer = timer; initialiseSounds(); alpha = 0; }
protected void HandHeld_Add_SubmitBtn_Click(object sender, EventArgs e) { var user = (User)Session["User"]; HandHeld h = new HandHeld(); h.AhwalID = Convert.ToInt64(HandHeld_Add_Ahwal_ComboBox.SelectedItem.Value.ToString()); h.Serial = HandHeld_Add_Serial_txt.Text.Trim(); h.Defective = HandHeld_Add_Defective_checkbox.Checked ? Convert.ToByte(1) : Convert.ToByte(0); OperationLog result; if (Request.Form["HandHeldAddMethod"] == "UPDATE") { h.HandHeldID = Convert.ToInt64(Request.Form["HandHeldID"]); result = Core.Handler_HandHelds.Update_HandHeld(user, h); HandHeld_Add_PopUp.ShowOnPageLoad = false; //we need to hide popup after updating } else { result = Core.Handler_HandHelds.Add_HandHeldr(user, h); HandHeld_Add_PopUp.ShowOnPageLoad = true; } if (result.StatusID == Core.Handler_Operations.Opeartion_Status_Success) { HandHeld_Add_Serial_txt.Text = ""; // Patrol_Add_Model_txt.Text = ""; HandHeld_Add_Defective_checkbox.Checked = false; HandHeld_Add_StatusLabel.Text = result.Text; HandHeldsGrid.DataBind(); } else { HandHeld_Add_StatusLabel.Text = result.Text; } }
public static bool CheckCollidable(Sprite a, Sprite b) { if (a.inInteriorId != Guid.Empty) { if (b.inInteriorId == Guid.Empty) { return(false); } if (b.inInteriorId != a.inInteriorId) { return(false); } } if (a is IShip) { Ship ship = (Ship)a; // a ship doesn't collide with its any ship's sails if (b.GetType().BaseType == typeof(Gusto.Models.Animated.Sail)) { return(false); } if (b is ILand) { TilePiece t = (TilePiece)b; if (!(t.shorePiece)) { return(false); } } // ship doesn't collide with interior tiles if (b is IInteriorTile) { return(false); } // ship doesn't collide with its own cannon balls if (b.GetType().BaseType == typeof(Gusto.Models.Animated.Ammo)) { Ammo ball = (Ammo)b; if (ball.teamType == ship.teamType) { return(false); } } } else if (a is IPlayer) { PlayerPirate pirate = (PlayerPirate)a; // a player doesn't collide with its own shots if (b is IAmmo) { Ammo ball = (Ammo)b; if (ball.teamType == pirate.teamType) { return(false); } } else if (b.GetType().BaseType == typeof(Gusto.Models.Animated.Tree)) { return(false); } } else if (a.GetType().BaseType == typeof(Gusto.Models.Animated.Tower)) { BaseTower tower = (BaseTower)a; // a tower doesn't collide with its own shots if (b is IAmmo) { Ammo ball = (Ammo)b; if (ball.teamType == tower.teamType) { return(false); } } } // hand items only collide when they are being used else if (a is IHandHeld) { HandHeld inHand = (HandHeld)a; if (!inHand.usingItem && !inHand.onGround) { return(false); } } else if (a is IAmmo) { if (b.GetType().BaseType == typeof(Gusto.Models.TilePiece)) { return(false); } if (b.GetType().BaseType == typeof(Gusto.Models.Animated.Grass)) { return(false); } } else if (a is IGroundObject) { if (b is IGroundObject) { return(false); } if (b.GetType().BaseType == typeof(Gusto.Models.TilePiece)) { return(false); } if (b is IShip) { return(false); } } return(true); }
//---------------------------------------------------------------------------------------------------------------------- // CONSTRUCTOR //---------------------------------------------------------------------------------------------------------------------- public MapLevel(string s, Level level, Timer timer, HandHeld handHeld) { this.handHeld = handHeld; _doorsYellow = new List <Door>(); _doorsBlue = new List <Door>(); _objectList = new List <Sprite>(); _level = level; Map map = MapParser.ReadMap(s); _tileNewSize = game.height / map.Height; _width = map.Width * _tileNewSize; _height = map.Height * _tileNewSize; _timer = timer; backgroundSetup(); for (int l = 0; l < map.Layers.Length; l++) { //get string from file string layerData = map.Layers[l].Data.ToString(); //split string by the comma string[] tileData = layerData.Split(','); //create list for storing data List <int> data = new List <int>(); //go through all the strings in the tileData array (created by Split) for (int i = 0; i < tileData.Length; i++) { //get a single array entry string tile = tileData[i]; //try to convert entry to integer if (Int32.TryParse(tile, out int tileID)) { //if it works, add it to the list data.Add(tileID); } } foreach (int tile in data) { //Console.Write(String.Format( "{0}, ", tile)); if (tile > 0) { HandleMap(tile, map.Height); // Map Gets Created } posX = posX + 1; if (posX >= map.Width) { posX = 0; posY = posY + 1; } } SetupForwardObjects(); } }