Exemplo n.º 1
0
        public void CalculateFinalRating()
        {
            Rating = (int)Math.Min(Math.Round(SectionRatings.Average() + ControllerPlugin.RoundPercentage() * 20), 100);
            TimeSinceRatingChange = 0;
            //Console.WriteLine(Rating);
            //send it to the object

            if (ControllerClient != null)
            {
                ControllerClient.SendOBJEvent(new VMEODEvent(1, (short)Rating));
            }
        }
Exemplo n.º 2
0
        public override void Tick()
        {
            base.Tick();
            Fresh.Tick();
            //push out ratings when we have a real client
            //under event 1
            if (ControllerPlugin == null)
            {
                ControllerPlugin = Server.vm.EODHost.GetFirstHandler <VMEODNightclubControllerPlugin>();
            }
            else if (ControllerClient != null)
            {
                if (TimeToRating-- == 0)
                {
                    TimeToRating = 5 * 30;
                    //todo: periodic send
                    bool newPatternCorrect = false;
                    for (int i = 0; i < 4; i++)
                    {
                        if (PatternDirty[i])
                        {
                            var p    = Patterns[i];
                            var ind  = (short)((p[0] - '0') * 16 + (p[1] - '0') * 4 + (p[2] - '0'));
                            var dist = ControllerPlugin.CurrentWinningDJPattern[i] - ind;

                            if (dist == 0 && !PatternCorrect[i])
                            {
                                PatternCorrect[i] = true;
                                newPatternCorrect = true;
                            }
                            Fresh.SendCommand(ind, i);

                            var distPct = 1 - Math.Abs(dist / 64f);

                            PatternRatings[i] = (distPct) * (distPct);
                            PatternDirty[i]   = false;
                        }
                    }
                    //recalculate our rating. send it out too!
                    var avg = PatternRatings.Average();

                    Rating = (int)Math.Min(100, Math.Round(100 * (0.8f * avg * Fresh.GoodScoreFreshness + 0.25f * ControllerPlugin.RoundPercentage())));
                    ControllerClient.SendOBJEvent(new VMEODEvent(1, (short)Rating));

                    if (newPatternCorrect)
                    {
                        var stationPos = ControllerClient.Invoker.Position;
                        ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Arrow,
                                                                ControllerPlugin.DanceFloor.GetDirection(new Point(stationPos.TileX, stationPos.TileY)), 0, GroupID);
                    }
                    else if (LastRating != Rating && LastRating != -1)
                    {
                        if (LastRating > Rating)
                        {
                            ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Colder, 0, 0, GroupID);
                        }
                        else
                        {
                            var rand = new Random();
                            ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Line, (float)(rand.Next(8) * Math.PI / 4), 0, GroupID);
                        }
                    }
                    LastRating = Rating;
                }
            }
        }