当前位置: 首页>>代码示例>>C#>>正文


C# SchedulerTask.Stop方法代码示例

本文整理汇总了C#中fCraft.SchedulerTask.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# SchedulerTask.Stop方法的具体用法?C# SchedulerTask.Stop怎么用?C# SchedulerTask.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fCraft.SchedulerTask的用法示例。


在下文中一共展示了SchedulerTask.Stop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Interval

 public void Interval( SchedulerTask task )
 {
     //check to stop Interval
     if ( _world.gameMode != GameMode.ZombieSurvival || _world == null ) {
         _world = null;
         task.Stop();
         return;
     }
     if ( !_started ) {
         if ( startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 1 ) {
             /*if (_world.Players.Length < 3){
                 _world.Players.Message("&WThe game failed to start: 2 or more players need to be in the world");
                 Stop(null);
                 return;
             }*/
             ShufflePlayerPositions();
             _started = true;
             RandomPick();
             lastChecked = DateTime.Now;
             return;
         }
     }
     //calculate humans
     _humanCount = _world.Players.Where( p => p.iName != _zomb ).Count();
     //check if zombies have won already
     if ( _started ) {
         if ( _humanCount == 1 && _world.Players.Count() == 1 ) {
             _world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
             Stop( null );
             return;
         }
         if ( _humanCount == 0 ) {
             _world.Players.Message( "&WThe Humans have failed to survive... &9ZOMBIES WIN!" );
             Stop( null );
             return;
         }
     }
     //check if 5mins is up and all zombies have failed
     if ( _started && startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 6 ) {
         _world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
         Stop( null );
         return;
     }
     //if no one has won, notify players of their status every 31s
     if ( lastChecked != null && ( DateTime.Now - lastChecked ).TotalSeconds > 30 ) {
         _world.Players.Message( "&WThere are {0} humans", _humanCount.ToString() );
         foreach ( Player p in _world.Players ) {
             if ( p.iName == _zomb ) p.Message( "&8You are " + _zomb );
             else p.Message( "&8You are a Human" );
         }
         lastChecked = DateTime.Now;
     }
 }
开发者ID:727021,项目名称:800craft,代码行数:53,代码来源:ZombieGame.cs

示例2: Interval

 public static void Interval(SchedulerTask task)
 {
     //check to stop Interval
     if (_world.gameMode != GameMode.ZombieSurvival || _world == null)
     {
         _world = null;
         task.Stop();
         return;
     }
     if (!_started)
     {
         if (startTime != null && (DateTime.Now - startTime).TotalMinutes > 1)
         {
             /*if (_world.Players.Length < 3){
                 _world.Players.Message("&WThe game failed to start: 2 or more players need to be in the world");
                 Stop(null);
                 return;
             }*/
             foreach (Player p in _world.Players)
             {
                 int x = rand.Next(2, _world.Map.Width);
                 int y = rand.Next(2, _world.Map.Length);
                 int z1 = 0;
                 for (int z = _world.Map.Height - 1; z > 0; z--)
                 {
                     if (_world.Map.GetBlock(x, y, z) != Block.Air)
                     {
                         z1 = z + 3;
                         break;
                     }
                 }
                 p.TeleportTo(new Position(x, y, z1 + 2).ToVector3I().ToPlayerCoords());
             }
             _started = true;
             RandomPick();
             lastChecked = DateTime.Now;
             return;
         }
     }
     //calculate humans
     _humanCount = _world.Players.Where(p => p.iName != _zomb).Count();
     //check if zombies have won already
     if (_humanCount == 0)
     {
         _world.Players.Message("&WThe Humans have failed to survive... &9ZOMBIES WIN!");
         Stop(null);
         return;
     }
     //check if 5mins is up and all zombies have failed
     if (_started && startTime != null && (DateTime.Now - startTime).TotalMinutes > 6)
     {
         _world.Players.Message("&WThe Zombies have failed to infect everyone... &9HUMANS WIN!");
         Stop(null);
         return;
     }
     //if no one has won, notify players of their status every 31s
     if (lastChecked != null && (DateTime.Now - lastChecked).TotalSeconds > 30)
     {
         _world.Players.Message("&WThere are {0} humans", _humanCount.ToString());
         foreach (Player p in _world.Players)
         {
             if (p.iName == _zomb) p.Message("&8You are " + _zomb);
             else p.Message("&8You are a Human");
         }
         lastChecked = DateTime.Now;
     }
 }
开发者ID:zINaPalm,项目名称:LegendCraftSource,代码行数:67,代码来源:ZombieGame.cs

示例3: Interval

        public static void Interval(SchedulerTask task)
        {
            //check to stop Interval
            if (world_ == null)
            {
                task.Stop();
                return;
            }
            if (world_.gameMode != GameMode.FFA) //bug checking
            {
                task.Stop();
                world_ = null;
                return;
            }

            //remove announcement after 5 seconds
            if ((DateTime.Now - announced).TotalSeconds >= 5)
            {
                foreach (Player p in world_.Players)
                {
                    if (p.ClassiCube && Heartbeat.ClassiCube())
                    {
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f"));//super hacky way to remove announcement, simply send a color code and call it a day
                    }
                }
            }

            if (!started)//first time running the interval
            {
                if (world_.Players.Count() < 2) //in case players leave the world or disconnect during the start delay
                {
                    world_.Players.Message("&WFFA&s requires at least 2 people to play.");
                    task.Stop();
                    return;
                }
                if (startTime != null && (DateTime.Now - startTime).TotalSeconds > timeDelay)
                {
                    foreach (Player p in world_.Players)
                    {
                        int x = rand.Next(2, world_.Map.Width);
                        int y = rand.Next(2, world_.Map.Length);
                        int z1 = 0;
                        for (int z = world_.Map.Height - 1; z > 0; z--)
                        {
                            if (world_.Map.GetBlock(x, y, z) != Block.Air)
                            {
                                z1 = z + 3;
                                break;
                            }
                        }
                        p.TeleportTo(new Position(x, y, z1 + 2).ToVector3I().ToPlayerCoords()); //teleport players to a random position
                        InitializePlayer(p);
                        if (!p.GunMode)
                        {
                            p.GunMode = true; //turns on gunMode automatically if not already on
                            GunGlassTimer timer = new GunGlassTimer(p);
                            timer.Start();
                        }

                        if (p.Info.IsHidden) //unhides players automatically if hidden (cannot shoot guns while hidden)
                        {
                            p.Info.IsHidden = false;
                            Player.RaisePlayerHideChangedEvent(p);
                        }

                        //send an announcement
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&cLet the Games Begin!"));

                        //set player health
                        p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f[&a--------&f]"));

                        //set leader
                        p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&eCurrent Leader&f: None"));
                    }
                    started = true;   //the game has officially started
                    if (!world_.gunPhysics)
                    {
                        world_.EnableGunPhysics(Player.Console, true); //enables gun physics if they are not already on
                    }
                    lastChecked = DateTime.Now;     //used for intervals
                    announced = DateTime.Now; //set when the announcement was launched
                    return;
                }
            }

            //check if one of the players has won
            foreach (Player p in world_.Players)
            {
                if (started && startTime != null && (DateTime.Now - startTime).TotalSeconds >= timeDelay && p.Info.gameKillsFFA >= scoreLimit)
                {
                    Stop(p);
                    return;
                }
            }

            //check if time is up
            if (started && startTime != null && (DateTime.Now - startTime).TotalSeconds >= (totalTime))
            {
                Player winner = GetScoreList()[0];
                if (world_.Players.Count() < 2)
//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:FFA.cs

示例4: StartFeed

 private void StartFeed( SchedulerTask task )
 {
     if ( !started ) { task.Stop(); return; }
     if ( !done ) return;
     try {
         done = false;
         RemoveText();
         if ( ChangeMessage ) {
             switch ( direction ) {
                 case Direction.one:
                 case Direction.two:
                     EndPos.X = FinishPos.X;
                     break;
                 case Direction.three:
                 case Direction.four:
                     EndPos.Y = FinishPos.Y;
                     break;
             }
             PickNewMessage();
             ChangeMessage = false;
         }
         switch ( direction ) {
             case Direction.one:
                 EndPos.X -= 7;
                 break;
             case Direction.two:
                 EndPos.X += 7;
                 break;
             case Direction.three:
                 EndPos.Y -= 7;
                 break;
             case Direction.four:
                 EndPos.Y += 7;
                 break;
         }
         Render( Sentence );
     } catch ( Exception e ) {
         Logger.Log( LogType.Error, e.ToString() );
     }
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:40,代码来源:FeedData.cs

示例5: Interval

        public static void Interval(SchedulerTask task)
        {
            //check to stop Interval
            if (world_ == null)
            {
                task.Stop();
                return;
            }
            if (world_.gameMode != GameMode.TeamDeathMatch)
            {
                task.Stop();
                world_ = null;
                return;
            }

            //remove announcement after 5 seconds
            if ((DateTime.Now - announced).TotalSeconds >= 5)
            {
                foreach (Player p in world_.Players)
                {
                    if (p.ClassiCube && Heartbeat.ClassiCube())
                    {
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f"));//super hacky way to remove announcement, simply send a color code and call it a day
                    }
                }
            }

            if (!started)
            {
                if (world_.Players.Count() < 2) //in case players leave the world or disconnect during the start delay
                {
                    world_.Players.Message("&WTeam DeathMatch&s requires at least 2 people to play.");
                    return;
                }
                if (startTime != null && (DateTime.Now - startTime).TotalSeconds > timeDelay)
                {
                    foreach (Player p in world_.Players)
                    {

                        if (!manualTeams)
                        {
                            assignTeams(p); //assigns teams (who knew?)
                        }
                        if (p.Info.isOnRedTeam) { p.TeleportTo(TeamDeathMatch.redSpawn); } //teleport players to the team spawn
                        if (p.Info.isOnBlueTeam) { p.TeleportTo(TeamDeathMatch.blueSpawn); }

                        if (!p.GunMode)
                        {
                            p.GunMode = true; //turns on gunMode automatically if not already on
                            GunGlassTimer timer = new GunGlassTimer(p);
                            timer.Start();
                        }

                        if (p.Info.IsHidden) //unhides players automatically if hidden (cannot shoot guns while hidden)
                        {
                            p.Info.IsHidden = false;
                            Player.RaisePlayerHideChangedEvent(p);
                        }

                        //send an announcement
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&cLet the Games Begin!"));

                        if (p.ClassiCube && Heartbeat.ClassiCube())
                        {
                            //set player's health
                            p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f[&a--------&f]"));

                            //set game score
                            p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&cRed&f: 0,&1 Blue&f: 0"));
                        }
                    }
                    started = true;   //the game has officially started
                    isOn = true;
                    if (!world_.gunPhysics)
                    {
                        world_.EnableGunPhysics(Player.Console, true); //enables gun physics if they are not already on
                    }
                    lastChecked = DateTime.Now;     //used for intervals
                    announced = DateTime.Now; //set when the announcement was launched
                    return;
                }
            }

            //check if one of the teams have won
            if (redScore >= scoreLimit || blueScore >= scoreLimit)
            {
                Stop(null);
                return;
            }
            if (blueScore == scoreLimit && redScore == scoreLimit) //if they somehow manage to tie which I am pretty sure is impossible
            {
                world_.Players.Message("The teams tied at {0}!", redScore);
                Stop(null);
                return;
            }

            //check if time is up
            if (started && startTime != null && (DateTime.Now - startTime).TotalSeconds >= (totalTime))
            {
                if (redScore != blueScore)
//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:TeamDeathMatch.cs

示例6: Interval

        public static void Interval(SchedulerTask task)
        {
            //check to stop Interval
            if (world_ == null)
            {
                task.Stop();
                return;
            }
            if (world_.gameMode != GameMode.CaptureTheFlag)
            {
                task.Stop();
                world_ = null;
                return;
            }

            //remove announcements after 5 seconds
            if (announced != DateTime.MaxValue && (DateTime.Now - announced).TotalSeconds >= 5)
            {
                foreach (Player p in world_.Players)
                {
                    if (p.ClassiCube && Heartbeat.ClassiCube())
                    {
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f"));//super hacky way to remove announcements, simply send a color code and call it a day
                    }
                }
                announced = DateTime.MaxValue;
            }

            //remove dodge after 1m
            foreach (Player p in world_.Players)
            {
                if (p.Info.canDodge)
                {
                    if (p.Info.dodgeTime != DateTime.MaxValue && (DateTime.Now - p.Info.dodgeTime).TotalSeconds >= 60)
                    {
                        p.Info.canDodge = false;
                        p.Info.dodgeTime = DateTime.MaxValue;

                        world_.Players.Message(p.Name + " is no longer able to dodge.");
                    }
                }
            }

            //remove strengthen after 1m
            foreach (Player p in world_.Players)
            {
                if (p.Info.strengthened)
                {
                    if (p.Info.strengthTime != DateTime.MaxValue && (DateTime.Now - p.Info.strengthTime).TotalSeconds >= 60)
                    {
                        p.Info.strengthened = false;
                        p.Info.strengthTime = DateTime.MaxValue;

                        world_.Players.Message(p.Name + " is no longer dealing 2x damage.");
                    }
                }
            }

            //remove Blades of Fury after 1m
            if ((BlueBOFdebuff != DateTime.MaxValue && (DateTime.Now - BlueBOFdebuff).TotalSeconds >= 60))
            {
                foreach (Player p in world_.Players)
                {
                    if (p.Info.CTFBlueTeam)
                    {
                        p.Info.stabDisarmed = false;
                    }
                    else
                    {
                        p.Info.stabAnywhere = false;
                    }
                }
                BlueBOFdebuff = DateTime.MaxValue;

                world_.Players.Message("Blades of Fury has ended.");
            }

            if ((RedBOFdebuff != DateTime.MaxValue && (DateTime.Now - RedBOFdebuff).TotalSeconds >= 60))
            {
                foreach (Player p in world_.Players)
                {
                    if (p.Info.CTFRedTeam)
                    {
                        p.Info.stabDisarmed = false;
                    }
                    else
                    {
                        p.Info.stabAnywhere = false;
                    }
                }
                RedBOFdebuff = DateTime.MaxValue;

                world_.Players.Message("Blades of Fury has ended.");
            }

            //remove disarm after 30s
            if ((RedDisarmed != DateTime.MaxValue && (DateTime.Now - RedDisarmed).TotalSeconds >= 30))
            {
                foreach (Player p in world_.Players)
                {
//.........这里部分代码省略.........
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:101,代码来源:CTF.cs

示例7: Interval

        public void Interval(SchedulerTask task)
        {
            //check to stop Interval
            if (_world.gameMode != GameMode.ZombieSurvival|| _world == null)
            {
                _world = null;
                task.Stop();
                return;
            }
            if (!isOn)
            {
                if (_world.Players.Count() < 2) //in case players leave the world or disconnect during the start delay
                {
                    if (!ConfigKey.IsNormal.Enabled())
                    {
                        return;
                    }
                    else
                    {
                        _world.Players.Message("&WZombie Survival&s requires at least 4 people to play.");
                        return;
                    }
                }
                if (startTime != null && (DateTime.UtcNow - startTime).TotalSeconds > timeDelay)
                {
                    foreach (Player p in _world.Players)
                    {
                        int x = rand.Next(2, _world.Map.Width);
                        int y = rand.Next(2, _world.Map.Length);
                        int z1 = 0;
                        for (int z = _world.Map.Height - 1; z > 0; z--)
                        {
                            if (_world.Map.GetBlock(x, y, z) != Block.Air)
                            {
                                z1 = z + 3;
                                break;
                            }
                        }
                        p.TeleportTo(new Position(x, y, z1 + 2).ToVector3I().ToPlayerCoords()); //teleport players to a random position
                        beginGame(p);
                        chooseInfected();
                    }
                    isOn = true;
                    lastChecked = DateTime.UtcNow;     //used for intervals
                    return;
                }
            }
            if (isOn && (DateTime.UtcNow - lastChecked).TotalSeconds > 10) //check if players left the world, forfeits if no players of that team left
            {
                if (_world.Players.Count(player => player.Info.isInfected) == _world.Players.Count())
                {
                    ZombiesWin();
                    return;
                }
                if (_world.Players.Count(player => player.Info.isInfected) == 0 && _world.Players.Count() > 0)
                {
                    HumansWin();
                    return;
                }

            }
            timeLeft = Convert.ToInt16(((timeDelay + timeLimit) - (DateTime.Now - startTime).TotalSeconds));

            if (lastChecked != null && (DateTime.UtcNow - lastChecked).TotalSeconds > 29.9 && timeLeft <= timeLimit)
            {
                _world.Players.Message("There are currently {0} human(s) and {1} zombie(s) left on {2}", _world.Players.Count() - _world.Players.Count(player => player.Info.isInfected), _world.Players.Count(player => player.Info.isInfected), _world.ClassyName);
            }
        }
开发者ID:venofox,项目名称:AtomicCraft,代码行数:68,代码来源:ZombieSurvival.cs

示例8: Interval

        public static void Interval(SchedulerTask task)
        {
            //check to stop Interval
            if (TDMworld_.gameMode != GameMode.TeamDeathMatch || TDMworld_ == null)
            {
                TDMworld_ = null;
                task.Stop();
                return;
            }
            if (!started)
            {
                if (TDMworld_.Players.Count() < 2) //in case players leave the world or disconnect during the start delay
                {
                    TDMworld_.Players.Message("&WTeam Death Match&s requires at least 2 people to play.");
                    return;
                }
                if (startTime != null && (DateTime.UtcNow - startTime).TotalSeconds > timeDelay)
                {
                    TDMworld_.Players.Message("&WType &a/Team [red/blue]&w to join a team and begin!");
                    started = true;   //the game has officially started
                    isOn = true;
                    if (!TDMworld_.gunPhysics)
                    {
                        TDMworld_.EnableGunPhysics(Player.Console, true); //enables gun physics if they are not already on
                    }
                    lastChecked = DateTime.UtcNow;     //used for intervals
                    return;
                }

                //check if one of the teams have won
                if (redScore >= scoreLimit)
                {
                    TDMworld_.Players.Message("&fThe &cRed Team&f has won {1} to {0}!", blueScore, redScore);
                    Stop(null);
                    return;
                }
                if (blueScore >= scoreLimit)
                {
                    TDMworld_.Players.Message("&fThe &1Blue Team&f has won {1} to {0}!", redScore, blueScore);
                    Stop(null);
                    return;
                }
                if (blueScore == scoreLimit && redScore == scoreLimit) //if they somehow manage to tie which I am pretty sure is impossible
                {
                    TDMworld_.Players.Message("&fThe teams have tied!");
                    Stop(null);
                    return;
                }

                //check if time is up (delay time + start time)
                if (started && startTime != null && (DateTime.UtcNow - startTime).TotalSeconds >= (timeDelay + timeLimit))
                {
                    if (redScore > blueScore)
                    {
                        TDMworld_.Players.Message("&fThe &cRed Team&f has won {0} to {1}.", redScore, blueScore);
                        Stop(null);
                        return;
                    }
                    if (redScore < blueScore)
                    {
                        TDMworld_.Players.Message("&fThe &1Blue Team&f has won {0} to {1}.", blueScore, redScore);
                        Stop(null);
                        return;
                    }
                    if (redScore == blueScore)
                    {
                        TDMworld_.Players.Message("&fThe teams tied {0} to {1}!", blueScore, redScore);
                        Stop(null);
                        return;
                    }
                    if (TDMworld_.Players.Count() <= 1)
                    {
                        Stop(null);
                        return;
                    }
                }

                if (started && (DateTime.UtcNow - lastChecked).TotalSeconds > 10) //check if players left the world, forfeits if no players of that team left
                {
                    int redCount = TDMworld_.Players.Where(p => p.Info.isOnRedTeam).ToArray().Count();
                    int blueCount = TDMworld_.Players.Where(p => p.Info.isOnBlueTeam).ToArray().Count();
                    if (blueCount < 1 || redCount < 1)
                    {
                        if (blueTeamCount == 0)
                        {
                            if (TDMworld_.Players.Count() >= 1)
                            {
                                TDMworld_.Players.Message("&1Blue Team &fhas forfeited the game. &cRed Team &fwins!");
                            }
                            Stop(null);
                            return;
                        }
                        if (redTeamCount == 0)
                        {
                            if (TDMworld_.Players.Count() >= 1)
                            {
                                TDMworld_.Players.Message("&cRed Team &fhas forfeited the game. &1Blue Team &fwins!");
                            }
                            Stop(null);
                            return;
//.........这里部分代码省略.........
开发者ID:venofox,项目名称:AtomicCraft,代码行数:101,代码来源:TeamDeathMatch.cs


注:本文中的fCraft.SchedulerTask.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。