Ejemplo n.º 1
0
        private async void ManagePVPEndGame(float _after_seconds, bool isGameOver)
        {
            string ID = functions.get_symb_for_IDs();

            for (float i = 0; i < _after_seconds; i += 0.1f)
            {
                foreach (Players CurrentPlayer in LocalPlayersPool.Values)
                {
                    CurrentPlayer.set_condition(CondType.co, 1007, ID, _after_seconds - i);

                    if (!CurrentPlayer.isDead)
                    {
                        if (i >= 5)
                        {
                            CurrentPlayer.is_reset_any_button = true;
                        }
                        CurrentPlayer.animation_id = 0;
                    }
                    else
                    {
                        CurrentPlayer.is_reset_any_button = true;
                        CurrentPlayer.animation_id        = 22;
                    }

                    CurrentPlayer.add_stop_to_spec_conditions(0);
                }

                await Task.Delay(100);
            }

            if (isGameOver)
            {
                KillSession(true);
            }
            else
            {
                foreach (Players CurrentPlayerCheck in LocalPlayersPool.Values)
                {
                    CurrentPlayerCheck.ResetData();
                    CurrentPlayerCheck.isDead = false;
                    CurrentPlayerCheck.is_reset_any_button = false;
                }

                isRoundChecked = false;
                CurrentTimerToStart.isCheckTimeOut = false;
            }
        }
Ejemplo n.º 2
0
        private async void KillSession(bool isSendDataToServer)
        {
            if (!isKillSessionStarted)
            {
                isKillSessionStarted = true;
            }
            else
            {
                return;
            }

            foreach (Players CurrentPlayerCheck in LocalPlayersPool.Values)
            {
                CurrentPlayerCheck.set_condition(CondType.co, 1009, functions.get_symb_for_IDs(), 9999);
            }

            if (isSendDataToServer)
            {
                SendResultToServer();
            }


            await Task.Delay(5000);

            Console.WriteLine(DateTime.Now + ": session ended and deleted - " + Session_id);
            isSessionStarted = false;

            //remember
            //bool result = mysql.ExecuteSQLInstruction($"DROP TABLE `{Session_id}`").Result;

            foreach (Players p in LocalPlayersPool.Values)
            {
                p.add_stop_to_spec_conditions(0);
                p.set_condition(CondType.co, 1007, "sessiondead", 1f);
            }

            _timer.Stop();
            _timer.Dispose();

            await Task.Delay(1000);

            isSessionStarted = false;
            LocalPlayersPool.Clear();
            starter.SessionsPool.Remove(Session_id);
        }