Exemple #1
0
        public void OnTick()
        {
            if (_CoreTicks == 0)
            {
                SpawnInvaders(CurrentLevel.SpawnAmount);
            }

            if (_CoreTicks > 60 && _CoreTicks % 30 == 0)
            {
                if (Invaders.Count != CurrentLevel.SpawnAmount)
                {
                    SpawnInvaders(CurrentLevel.SpawnAmount - Invaders.Count);
                }
            }

            if (_CoreTicks % 600 == 0)
            {
                CommandHandlers.BroadcastMessage(AccessLevel.Player, 33,
                                                 "Defenders are needed to halt the " + InvasionName + ".");
            }

            if (_CoreTicks >= (int)CurrentLevel.TimeLimit.TotalSeconds && CurrentLevel.KillAmount == 0 ||
                (int)CurrentLevel.TimeLimit.TotalSeconds == 0 && CurrentLevel.KillAmount > 0 &&
                CurrentLevelKills >= CurrentLevel.KillAmount
                ||
                _CoreTicks < (int)CurrentLevel.TimeLimit.TotalSeconds && CurrentLevel.KillAmount > 0 &&
                CurrentLevelKills >= CurrentLevel.KillAmount)
            {
                if (Levels.Last() == CurrentLevel || Levels.Count == 1)
                {
                    FinishInvasion();
                    _CoreTimer.Stop();
                    return;
                }
                else
                {
                    IncrementLevel();
                    return;
                }
            }

            if (CurrentLevel != null && (int)CurrentLevel.TimeLimit.TotalSeconds > 0 &&
                _CoreTicks >= (int)CurrentLevel.TimeLimit.TotalSeconds && CurrentLevel.KillAmount > 0 &&
                CurrentLevelKills < CurrentLevel.KillAmount)
            {
                FinishInvasion();
                _CoreTimer.Stop();
                return;
            }

            ++_CoreTicks;
        }
Exemple #2
0
 private void tsbStop_Click(object sender, EventArgs e)
 {
     tsbStart.Enabled   = true;
     tsbStop.Enabled    = false;
     tsbRefresh.Enabled = true;
     PollTimer.Stop();
 }
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                databaseDriver.Execute("UPDATE profiles SET status=0, sesskey = NULL");
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Tell the base to dispose all free objects
            Dispose();
        }
Exemple #4
0
 public void Unhook()
 {
     if (PollTimer != null)
     {
         PollTimer.Stop();
         PollTimer.Dispose();
     }
 }
Exemple #5
0
 private void tsbClear_Click(object sender, EventArgs e)
 {
     tsbStart.Enabled   = true;
     tsbStop.Enabled    = false;
     tsbRefresh.Enabled = true;
     PollTimer.Stop();
     PollListView.Items.Clear();
 }
Exemple #6
0
        protected override void OnDeleted()
        {
            if (_FlagEffectTimer != null)
            {
                _FlagEffectTimer.Stop();
                _FlagEffectTimer = null;
            }

            base.OnDeleted();
        }
Exemple #7
0
        public void OnTick()
        {
            if (_CoreTicks == 0)
            {
                SpawnMobs();
                SpawnCrystals();
            }

            if (Mobs.Count == 0 && !BossSpawned)
            {
                BossSpawned = true;
                string msg = "The master of the portal has begun to awaken!";
                Message(msg);
                if (ValidSpawnPoints.Count == 0)
                {
                    Region r = Region.Regions.Find(x => x.Name == RegionName);
                    ValidSpawnPoints = GenerateSpawnLocations(r);
                }
                Point3D loc = ValidSpawnPoints.GetRandom();
                FlameSpirtal(loc);
                Timer.DelayCall(TimeSpan.FromMinutes(0.1), SpawnBoss, loc);
            }


            if (_CoreTicks == Portals.CSOptions.PortalCloseTime * 3600)
            {
                string msg = "The attempt to seal the portal has failed.  The portal will close in 2 minutes.";
                Message(msg);
                GenerateScoreboards();

                _CoreTimer.Stop();

                Status = PortalStatus.Failed;

                Timer.DelayCall(TimeSpan.FromMinutes(2), FinishPortal);
            }

            ++_CoreTicks;
        }
Exemple #8
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            base.IgnoreNewConnections = true;
            Exiting = true;

            // Unregister events so we dont get a shit ton of calls
            GpcmClient.OnSuccessfulLogin -= GpcmClient_OnSuccessfulLogin;
            GpcmClient.OnDisconnect      -= GpcmClient_OnDisconnect;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                using (Database.GamespyDatabase db = new Database.GamespyDatabase())
                    db.Execute("UPDATE player SET online=0");
            }
            catch (Exception e)
            {
                Program.ErrorLog.Write("WARNING: [GpcmServer.Shutdown] Failed to update client database: " + e.Message);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Shutdown the listener socket
            base.ShutdownSocket();

            // Tell the base to dispose all free objects
            base.Dispose();
        }
Exemple #9
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;


            // Unregister events so we dont get a shit ton of calls
            GPCMClient.OnSuccessfulLogin -= ClientSuccessfulLogin;
            GPCMClient.OnDisconnect      -= ClientDisconnected;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                LoginQuery.ResetStatusAndSessionKey();
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            DB.Dispose();

            // Tell the base to dispose all free objects
            Dispose();
        }
Exemple #10
0
 protected override void Dispose(bool disposingManagedResources)
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     if (disposingManagedResources)
     {
     }
     PollTimer?.Stop();
     PollTimer?.Dispose();
     StatusTimer?.Stop();
     StatusTimer?.Dispose();
     // Disconnected all connected clients
     Console.WriteLine("Disconnecting all users...");
     //Parallel.ForEach(LoggedInSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //Parallel.ForEach(InLoginSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //LoginQuery.ResetAllStatusAndSessionKey();
     LoggedInSession.Clear();
     DB.Dispose();
     base.Dispose(disposingManagedResources);
 }
Exemple #11
0
 private void PollView_FormClosing(object sender, FormClosingEventArgs e)
 {
     PollTimer.Stop();
     tsbStart.Enabled = true;
     tsbStop.Enabled  = false;
 }