Пример #1
0
        public byte Reward(byte OrbId, Keys victim)
        {
            byte temp;

            lock (MVP.RecordsLock) {
                lock (lock_reward) {
                    if (killed.Contains(victim) || HEADS[victim].Died)
                    {
                        return(0);
                    }
                    else if (!KingOfTheHill)
                    {
                        killed.Add(victim);
                    }

                    if (ChaosMode && Leader == victim)
                    {
                        Leader = this.KeyCode;
                    }

                    OnReward?.Invoke();
                    temp = this.Points;
                    Kills++;
                    this.Points += KingOfTheHill? (byte)1 : Kills;
                    if (HEADS[victim].isBounty)
                    {
                        this.Points++;
                    }
                    if (HEADS[victim].isDoubleBounty)
                    {
                        this.Points++;
                    }
                    this.Points += Orb.All[OrbId].KillStreak++;
                    key.Add(this.Points - temp);
                    key.points = Points;

                    if (Orb.All[OrbId].KillStreak > 1)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("Collateral!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.COLLATERAL, DisplayKey, Orb.All[OrbId].KillStreak.ToString());
                        }
                    }

                    if (Died)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("GhostKill!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.GHOSTKILL, DisplayKey);
                        }
                    }
                }
            }

            if (KingOfTheHill)
            {
                Map.Sort();
                IKey.UpdateAll();
                bool leader = true;
                int  second = 0;

                lock (ActiveLock)
                    foreach (Head head in HEADS.Values)
                    {
                        if (head.KeyCode == KeyCode)
                        {
                            continue;
                        }
                        if (this.Points < head.Points)
                        {
                            leader = false;
                        }
                        if (second < head.Points)
                        {
                            second = head.Points;
                        }
                    }

                if (leader)
                {
                    Leader = this.KeyCode;
                }

                if (this.Points >= Map.MaxPoints && Points - second > 1 && Map.phase != Phases.ENDGAME)
                {
                    MVP.Show(MVP.WinMessage(this.DisplayKey));
                    new Thread(Map.EndGame).Start();
                }
                else if (Kills >= 5 && !isBounty)
                {
                    MVP.Flash($"{DisplayKey} killstreak");
                    this.isBounty = true;
                }
                else if (this.Points >= Map.MaxPoints - 1 && !isBounty)
                {
                    this.isBounty = true;
                    MVP.Flash("Matchpoint!");
                }

                else if (isBounty && Kills >= 5 && this.Points >= Map.MaxPoints - 1 && !isDoubleBounty)
                {
                    MVP.Flash("Double Bounty!");
                    this.isDoubleBounty = true;
                }
            }
            return((byte)(Points - temp));
        }
Пример #2
0
        public void Die()
        {
            lock (lock_die) {
                if (Died)
                {
                    return;
                }
                this.act = Activities.DEAD;
            }

            OnUpdate -= e_update;
            if (AnimationsEnabled)
            {
                window.DrawHead -= draw_event;
            }

            if (Tick < 60 + Map.StartRoundTime)
            {
                MVP.Add(MVPTypes.EARLY_KILL, DisplayKey);
            }

            lock (ActiveLock) {
                ActiveKeys.Remove(this.KeyCode);
                if (KingOfTheHill)
                {
                    InactiveKeys.Add(this.KeyCode);
                }
                else
                {
                    InactiveKeys.Insert(0, this.KeyCode);
                }
            }
            key.Die();
            tail.Die();
            z            = 0;
            DashHideText = false;

            if (isBounty)
            {
                new Animation(pos, 30, HeadR - 1, HeadR - 5, 5, 0, Color.Red, Color.Red, AnimationTypes.CUBED);
            }

            isBounty       = false;
            isDoubleBounty = false;

            if (AnimationsEnabled && ActiveKeys.Count <= 12 && !(Map is BotArena))
            {
                _ = new Animation(pos, 80, 0, W, HeadR, (float)PHI * HeadR, Color.FromArgb(150, this.color), 0);
            }
            if (AnimationsEnabled)
            {
                _ = new Animation(pos, 12, 0, 0, HeadR, HeadR, this.color, 32, AnimationTypes.CUBED);
            }
            else
            {
                window.writeln(DisplayKey + " died: " + Points + " pts");
            }



            if (KingOfTheHill)
            {
                IKey.UpdateAll();
                new Thread(() => {
                    int tick = Tick;
                    SpinWait.SpinUntil(() => Tick >= tick + 120 || Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning);
                    if (Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning)
                    {
                        return;
                    }
                    new Coin(IPoint.Center + 3 * IVector.Random(), "3", this.color);

                    SpinWait.SpinUntil(() => Tick >= tick + 180 || Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning);
                    if (Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning)
                    {
                        return;
                    }
                    new Coin(IPoint.Center + 3 * IVector.Random(), "2", this.color);

                    SpinWait.SpinUntil(() => Tick >= tick + 240 || Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning);
                    if (Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning)
                    {
                        return;
                    }
                    new Coin(IPoint.Center + 3 * IVector.Random(), "1", this.color);

                    SpinWait.SpinUntil(() => Tick >= tick + 300 || Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning);
                    if (Map.phase != Phases.NONE || state == States.NEWGAME || !ApplicationRunning)
                    {
                        return;
                    }
                    lock (updatinglocker) {
                        this.clear();
                        this.Revive();
                        this.act = Activities.DEFAULT;
                        lock (ActiveLock) {
                            ActiveKeys.Add(KeyCode);
                            InactiveKeys.Remove(KeyCode);
                        }
                        this.INVINCIBLE = true;
                    }
                    SpinWait.SpinUntil(() => (Tick >= tick + 360 && !is_about_to_die()) || !ApplicationRunning);
                    this.INVINCIBLE = false;

                    SpinWait.SpinUntil(() => (Tick >= tick + 372 || Died) || !ApplicationRunning);
                    if (Tick <= tick + 372 && Died)
                    {
                        MVP.Flash("Spawnkill!");
                    }
                }).Start();
            }
            else
            {
                Map.Sort();
                IKey.UpdateAll();
                if (ActiveKeys.Count == 1 && Map.phase != Phases.ENDROUND)
                {
                    new Thread(Map.EndRound).Start();
                }
            }

            if (OnDie != null)
            {
                Parallel.Invoke(OnDie);
            }
        }