public void ShouldReadSpriteSheetFile() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); spriteSheetData.FileFormatVersion.Should().Be("2"); spriteSheetData.FileGuid.Should().Be("9a3cf21915996f441b213e88de546e32"); }
public void ShouldPopulatePivot() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); SpriteData sd = spriteSheetData.SpritesMap["PL04_Left_Walk0"]; sd.Pivot.X.Should().Be(0.5f); sd.Pivot.Y.Should().Be(0); }
public void ShouldMapSpriteNames() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); spriteSheetData.NamesMap.Should().HaveCount(66); spriteSheetData.NamesMap["PL04_Left_Walk0"].Should().Be("21300000"); spriteSheetData.NamesMap["PL04_DownRight_Walk0"].Should().Be("21300022"); }
public void ShouldGetAnimationFramesATTStab() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); List <string> frames = spriteSheetData.GetAnimationFrames("PL04_UpLeft_ATTStab").ToList(); frames.Should().HaveCount(2); frames[0].Should().Be("PL04_UpLeft_ATTStab1"); frames[1].Should().Be("PL04_UpLeft_ATTStab2"); }
public void ShouldPopulateRect() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); SpriteData sd = spriteSheetData.SpritesMap["PL04_Left_Walk0"]; sd.Rect.X.Should().Be(5); sd.Rect.Y.Should().Be(473); sd.Rect.Width.Should().Be(10); sd.Rect.Height.Should().Be(35); }
public void ShouldGetAnimationFramesDownRight() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); List <string> frames = spriteSheetData.GetAnimationFrames("PL04_DownRight_Walk").ToList(); frames.Should().HaveCount(3); frames[0].Should().Be("PL04_DownRight_Walk0"); frames[1].Should().Be("PL04_DownRight_Walk1"); frames[2].Should().Be("PL04_DownRight_Walk2"); }
public void ShouldCreateSprite() { string rawFile = Helpers.Helpers.LoadFile(@"Player04.png.meta"); SpriteSheetData spriteSheetData = SpriteParser.Parse(rawFile); spriteSheetData.SpritesMap.Should().HaveCount(64); SpriteData sd = spriteSheetData.SpritesMap["PL04_Left_Walk0"]; sd.Name.Should().Be("PL04_Left_Walk0"); sd.SpriteID.Should().Be("2f9a5b012f5af2747902bba879ef1838"); sd.Alignment.Should().Be(7); sd = spriteSheetData.SpritesMap["PL04_DownLeft_ATTSwipe1"]; sd.Name.Should().Be("PL04_DownLeft_ATTSwipe1"); sd.SpriteID.Should().Be("a358f9531f7322f4881de90b59bd397d"); sd.Alignment.Should().Be(9); }
private static void Client_RawMessageRecieved(object s, ChatSharp.Events.RawMessageEventArgs e) { //Plugin.Log(e.Message); try { if (e.Message.StartsWith("@")) { string[] parts = e.Message.Split(new char[] { ' ' }, 2); string message = parts[1]; Dictionary <string, string> messageComponents = parts[0].Substring(1).Split(';').ToList().ToDictionary(x => x.Substring(0, x.IndexOf('=')), y => y.Substring(y.IndexOf('=') + 1)); if (System.Text.RegularExpressions.Regex.IsMatch(message, ":.*!.*@.*.tmi.twitch.tv")) { string msgSender = message.Substring(1, message.IndexOf('!') - 1); string msgPrefix = $":{msgSender}!{msgSender}@{msgSender}.tmi.twitch.tv "; if (message.StartsWith(msgPrefix)) { List <string> msgArray = message.Replace(msgPrefix, "").Split(new char[] { ' ' }, 3).ToList(); switch (msgArray[0]) { case "PRIVMSG": // Grab the info we care about from the current message MessageInfo messageInfo = GetMessageInfo(msgSender, messageComponents); // Remove the : from the beginning of the msg msgArray[2] = msgArray[2].Substring(1); // Parse any emotes in the message, download them, then queue it for rendering SpriteParser.Parse(new ChatMessage(Utilities.StripHTML(msgArray[2]), messageInfo), _chatHandler); break; } } } else { if (message.Contains("ROOMSTATE")) { Plugin.TwitchChannelID = messageComponents["room-id"]; Plugin.Log($"Channel room-id: {Plugin.TwitchChannelID}"); } else if (message.Contains("CLEARCHAT")) { _chatHandler.OnUserTimedOut(messageComponents["target-user-id"]); } else if (message.Contains("USERNOTICE")) { switch (messageComponents["msg-id"]) { case "sub": case "resub": case "subgift": MessageInfo messageInfo = GetMessageInfo(String.Empty, messageComponents); string newMsg = messageComponents["system-msg"].Replace("\\s", " "); SpriteParser.Parse(new ChatMessage($"<b>{newMsg.Substring(newMsg.IndexOf(" ") + 1)}</b>", messageInfo), _chatHandler); break; } } } } } catch (Exception) { //Plugin.Log($"Caught exception \"{ex.Message}\" from {ex.Source}"); //Plugin.Log($"Stack trace: {ex.StackTrace}"); } }