private void Walk(CommandAlias action) { //convert letter-number coordinate input from action.alias[0] to bytepair BytePair coord = BytePair.StringListToCoordinates(action.Alias, GameManager.instance.MapHandler.MapHeight - 1, -1); if (coord.x == 255 || coord.y == 255) { print("Invalid coordinate"); return; } TargetPosition = coord; transferer.MoveTo(TargetPosition.ToPositionVector2()); }
public void OnLobbyMenuStart() { //Generate available spawn points List <BytePair> newPlayerSpawnPoints = BytePair.CreateBytePairList(mapWidth, mapHeight); newPlayerSpawnPoints.Shuffle(); playerSpawnPoints = new Stack <BytePair>(newPlayerSpawnPoints); List <BytePair> newHoleSpawnPoints = BytePair.CreateBytePairList(mapWidth, mapHeight); newHoleSpawnPoints.Shuffle(); holeSpawnPoints = new Stack <BytePair>(newHoleSpawnPoints); }
/// <summary> /// Converts letter+number coordinate into BytePair /// Y-axis = letter, X-axis = number /// In case of error, 255 is returned as value /// </summary> /// <param name="w">Letter+number coordinate</param> /// <param name="aValue">Coordinate value for 'a'</param> /// <param name="dir">1 if value is ascending, -1 if decending</param> public static BytePair StringListToCoordinates(List <string> w, int aValue, int dir) { //TODO improve to support higher values and spacebar BytePair result = new BytePair(255, 255); if (char.IsLetter(w[0][0]) && char.IsDigit(w[0][1])) { result.y = Extensions.CharToCoordinate(w[0][0], aValue, dir); result.x = byte.Parse("" + w[0][1]); } else if (char.IsLetter(w[0][1]) && char.IsDigit(w[0][0])) { result.y = Extensions.CharToCoordinate(w[0][1], aValue, dir); result.x = byte.Parse("" + w[0][0]); } return(result); }
private void Shoot(CommandAlias action) { //convert letter-number coordinate input from action.alias[0] to bytepair BytePair coord = BytePair.StringListToCoordinates(action.Alias, GameManager.instance.MapHandler.MapHeight - 1, -1); if (coord.x == 255 || coord.y == 255) { print("Invalid coordinate"); return; } Snowball newBall = (Snowball)Pool.instance.GetFromPool("Assorted", "Snowball"); newBall.SetTargetAndShoot(this, coord); newBall.Setup(); Act(); }
private bool IsPrt(Stream s) { var start = s.Position; var h = new PrtFile() { ID = s.ReadASCII(4), PalCount = s.ReadInt32(), }; if (h.ID != "CPAL") { s.Position = start; return(false); } h.PalData = new Ppal[h.PalCount]; // Parse palettes for (var i = 0; i < h.PalCount; i++) { var ppal = new Ppal { ID = s.ReadASCII(4), Size = s.ReadInt32(), HeadID = s.ReadASCII(4), BytesPerEntry = s.ReadInt32(), Unknown = s.ReadInt32(), DataID = s.ReadASCII(4), PalSize = s.ReadInt32() }; if (ppal.ID != "PPAL" || ppal.HeadID != "head" || ppal.DataID != "data") { s.Position = start; return(false); } var numPaletteEntries = ppal.PalSize / ppal.BytesPerEntry; ppal.PaletteData = new RgbQuad[numPaletteEntries]; // Populate palette for (var j = 0; j < numPaletteEntries; j++) { var rgba = new RgbQuad { Red = s.ReadByte(), Green = s.ReadByte(), Blue = s.ReadByte(), Reserved = s.ReadByte(), }; ppal.PaletteData[j] = rgba; } h.PalData[i] = ppal; } h.ImageCount = s.ReadInt32(); h.ImageHeader = new Op2Image[h.ImageCount]; for (var i = 0; i < h.ImageCount; i++) { var img = new Op2Image { SizeScanline = s.ReadInt32(), }; img.ImgData = s.ReadBytes(img.SizeScanline); img.SizeX = s.ReadInt32(); img.SizeY = s.ReadInt32(); img.Unknown = s.ReadInt16(); img.Palette = s.ReadInt16(); h.ImageHeader[i] = img; } h.AllGroupCount = s.ReadInt32(); h.AllFrameCount = s.ReadInt32(); h.AllPicCount = s.ReadInt32(); h.AllExtInfoCount = s.ReadInt32(); h.Groups = new ImageGroup[h.AllGroupCount]; for (var i = 0; i < h.AllGroupCount; i++) { var img = new ImageGroup { Unknown1 = s.ReadInt32(), SelLeft = s.ReadInt32(), SelTop = s.ReadInt32(), SelRight = s.ReadInt32(), SelBottom = s.ReadInt32(), CenterX = s.ReadInt32(), CenterY = s.ReadInt32(), Unknown8 = s.ReadInt32(), FrameCount = s.ReadInt32() }; img.Frames = new Op2Frame[img.FrameCount]; for (var j = 0; j < img.FrameCount; j++) { var frame = new Op2Frame { PicCount = s.ReadUInt8(), Unknown = s.ReadUInt8(), }; frame.ExtUnknown1 = new BytePair[frame.PicCount >> 7]; for (var k = 0; k < frame.PicCount >> 7; k++) { var bp = new BytePair { Byte1 = s.ReadUInt8(), Byte2 = s.ReadUInt8(), }; frame.ExtUnknown1[k] = bp; } frame.ExtUnknown2 = new BytePair[frame.Unknown >> 7]; for (var k = 0; k < frame.Unknown >> 7; k++) { var bp = new BytePair { Byte1 = s.ReadUInt8(), Byte2 = s.ReadUInt8(), }; frame.ExtUnknown2[k] = bp; } frame.Pictures = new Op2Picture[frame.PicCount & 0x7F]; for (var k = 0; k < frame.Pictures.Length; k++) { var pic = new Op2Picture { ImgNumber = s.ReadInt16(), Reserved = s.ReadUInt8(), PicOrder = s.ReadUInt8(), PosX = s.ReadInt16(), PosY = s.ReadInt16() }; frame.Pictures[k] = pic; } img.Frames[j] = frame; } img.GroupExtCount = s.ReadInt32(); img.Extended = new GroupExt[img.GroupExtCount]; for (var j = 0; j < img.GroupExtCount; j++) { var ext = new GroupExt { Unknown1 = s.ReadInt32(), Unknown2 = s.ReadInt32(), Unknown3 = s.ReadInt32(), Unknown4 = s.ReadInt32(), }; img.Extended[j] = ext; } h.Groups[i] = img; } file = h; return(true); }
public void SetTarget(Player _shooter, BytePair _target) { shooter = _shooter; target = _target; base.SetLocalPosition(StartPointFromTo(_shooter.transform.position, target.ToPositionVector2(), SpawnMagnitude(_shooter.Col, col))); }
/// <summary> /// Launch method for the snowball /// </summary> public void SetTargetAndShoot(Player _shooter, BytePair _target) { SetTarget(_shooter, _target); transferer.MoveTo(target.ToPositionVector2()); }