public void S_SetAnimation(short evt, VMEODClient client) { var temps = client.Invoker.Thread.TempRegisters; var anim = (VMEODNCAnimTypes)temps[0]; //arrow and line types have been replaced by our particle system. Color = (byte)temps[1]; if (anim == VMEODNCAnimTypes.Line || anim == VMEODNCAnimTypes.Arrow) { return; } Animation = (VMEODNCAnimTypes)temps[0]; if (Animation > VMEODNCAnimTypes.Random) { TempTimer = 0; } Direction = temps[2]; }
public void DrawAnimation(int frame) { // mat = Matrix.CreateRotationZ(frame / 20f); var repeat = frame % ScreenDiag; var lit = (frame / 10) % 2; var col = (byte)(Color + lit); switch (Animation) { case VMEODNCAnimTypes.Off: ClearScreen(0); break; case VMEODNCAnimTypes.Fill: ClearScreen(col); break; case VMEODNCAnimTypes.DancersBonus: ClearScreen(10); DrawImage(ScreenWidth / 2 - 4, ScreenHeight / 2 - 4, HeartImage, col); if (TempTimer++ > 75) { Animation = VMEODNCAnimTypes.Random; } break; case VMEODNCAnimTypes.DJsBonus: ClearScreen(10); DrawImage(ScreenWidth / 2 - 4, ScreenHeight / 2 - 4, DiamondImage, col); if (TempTimer++ > 75) { Animation = VMEODNCAnimTypes.Random; } break; case VMEODNCAnimTypes.AllBonus: ClearScreen(10); DrawImage(ScreenWidth / 2 - 4, ScreenHeight / 2 - 4, StarImage, col); if (TempTimer++ > 75) { Animation = VMEODNCAnimTypes.Random; } break; default: //random var controller = Server.vm.EODHost.GetFirstHandler <VMEODNightclubControllerPlugin>(); var rand = new Random(); if (frame % (10 * 6) == 0) { RandomAnimation = (VMEODNCRandomAnims)rand.Next(5); switch (RandomAnimation) { case VMEODNCRandomAnims.Text: var bank = 0; var avgRating = Ratings.Average(); if (avgRating < 25) { bank = 2; } else if (avgRating > 75) { bank = 1; } TextMessage = TextMessages[rand.Next(4) + bank]; break; case VMEODNCRandomAnims.RainbowTunnel: for (int i = 0; i < 6; i++) { PatternMemory[i] = 0; } break; default: for (int i = 0; i < 6; i++) { PatternMemory[i] = rand.Next(int.MaxValue); } break; } } var sumRating = Ratings.Sum() + 50; switch (RandomAnimation) { case VMEODNCRandomAnims.Circles: var first = (repeat <= ScreenDiag / 2) ? 3 : 0; var second = 3 - first; var fr = (repeat <= ScreenDiag / 2) ? ((frame + ScreenDiag / 2) % ScreenDiag) : repeat; var sr = (repeat > ScreenDiag / 2) ? ((frame + ScreenDiag / 2) % ScreenDiag) : repeat; if (repeat == 0) { PatternMemory[0] = RandomCol(rand, sumRating); //color PatternMemory[1] = rand.Next(ScreenWidth); //x PatternMemory[2] = rand.Next(ScreenHeight); //y } if (repeat == ScreenDiag / 2) { PatternMemory[3] = RandomCol(rand, sumRating); //color PatternMemory[4] = rand.Next(ScreenWidth); //x PatternMemory[5] = rand.Next(ScreenHeight); //y } for (int y = 0; y < ScreenHeight; y++) { for (int x = 0; x < ScreenWidth; x++) { var dx = x - PatternMemory[1 + first]; var dy = y - PatternMemory[2 + first]; if (Math.Sqrt(dx * dx + dy * dy) <= fr) { ScreenData[x + y * ScreenWidth] = (byte)(lit + PatternMemory[0 + first]); } dx = x - PatternMemory[1 + second]; dy = y - PatternMemory[2 + second]; if (Math.Sqrt(dx * dx + dy * dy) <= sr) { ScreenData[x + y * ScreenWidth] = (byte)(lit + PatternMemory[0 + second]); } } } break; case VMEODNCRandomAnims.RandomDissolve: for (int y = 0; y < ScreenHeight; y++) { for (int x = 0; x < ScreenWidth; x++) { if (rand.Next(4) == 0) { var dist = rand.Next(sumRating); byte color = 0; for (int i = 0; i < 4; i++) { if (dist < Ratings[i]) { color = (byte)(i * 2 + 1); break; } dist -= Ratings[i]; if (i == 3) { color = 9; } } ScreenData[x + y * ScreenWidth] = (byte)(color + 1); //color } } } break; case VMEODNCRandomAnims.RainbowTunnel: /* * if (repeat == 0) * { * PatternMemory[0] = rand.Next(5) * 2 + 1; //color * PatternMemory[1] = rand.Next(ScreenWidth); //x * PatternMemory[2] = rand.Next(ScreenHeight); //y * }*/ for (int y = 0; y < ScreenHeight; y++) { for (int x = 0; x < ScreenWidth; x++) { var dx = x - ScreenWidth / 2; var dy = y - ScreenHeight / 2; var dist = Math.Sqrt(dx * dx + dy * dy); dist -= frame / 3f; var color = -((int)((dist - ScreenDiag) / 2) % 5); ScreenData[x + y * ScreenWidth] = (byte)(color * 2 + 1 + lit); } } break; case VMEODNCRandomAnims.Matrix: var fallDist = ScreenHeight + 4; for (int x = 0; x < ScreenWidth; x++) { var fallFreq = ScreenHeight + ((PatternMemory[x % 6] + x) % 9) - 4; var fallDelta = (PatternMemory[x % 6] + x) % ScreenHeight; var fallPosition = (((frame % fallFreq) * fallDist) / fallFreq) % fallDist; var color = (byte)((x % 5) * 2 + 1); for (int y = 0; y < ScreenHeight; y++) { if (y <= fallPosition - 3) { ScreenData[x + y * ScreenWidth] = 0; } else if (y < fallPosition && y > fallPosition - 3) { ScreenData[x + y * ScreenWidth] = (byte)(color + 1); } else if (y == fallPosition) { ScreenData[x + y * ScreenWidth] = color; } } } break; case VMEODNCRandomAnims.Text: ClearScreen((byte)((10 + lit) % 11)); var s = TextMessage ?? "FreeSO"; var scrollX = TileWrap % (ScreenWidth + (s.Length + 1) * 4); DrawString(s, ScreenWidth - scrollX, (ScreenHeight - 1) / 2 - 2, col); var border = ScreenHeight / 2 - 3; DrawRect(new Rectangle(0, 0, ScreenWidth, border), col); DrawRect(new Rectangle(0, ScreenHeight - border, ScreenWidth, border), col); break; } //var s = "FreeSO Nightclub"; //var scrollX = TileWrap % (ScreenWidth + (s.Length + 1) * 4); //DrawString(s, ScreenWidth - scrollX, (ScreenHeight - 1) / 2 - 2, 1); break; } //var s = "FreeSO Nightclub"; //var scrollX = TileWrap % (ScreenWidth + (s.Length + 1) * 4); //DrawString(s, ScreenWidth - scrollX, (ScreenHeight - 1) / 2 - 2, 1); for (int i = 0; i < Particles.Count; i++) { var p = Particles[i]; if (!p.Tick(this)) { Particles.RemoveAt(i--); } else { p.Frame++; } } Server.vm.SendCommand(new VMNetBatchGraphicCmd() { Objects = ScreenTiles, Graphics = ScreenData }); }