示例#1
0
        public static Hockeyist NearestOpponent(this Hockeyist me)
        {
            var world = Get <World> .Current();

            Hockeyist nearestOpponent      = null;
            double    nearestOpponentRange = 0.0D;

            foreach (Hockeyist hockeyist in world.Hockeyists)
            {
                if (hockeyist.IsTeammate ||
                    hockeyist.Type == HockeyistType.Goalie ||
                    hockeyist.State == HockeyistState.KnockedDown ||
                    hockeyist.State == HockeyistState.Resting)
                {
                    continue;
                }

                double opponentRange = MathUtil.Hypot(me.X - hockeyist.X, me.Y - hockeyist.Y);

                if (nearestOpponent == null || opponentRange < nearestOpponentRange)
                {
                    nearestOpponent      = hockeyist;
                    nearestOpponentRange = opponentRange;
                }
            }

            return(nearestOpponent);
        }
示例#2
0
        public static bool IsHunter(this Hockeyist me)
        {
            var world = Get <World> .Current();

            var teammate = world.MyTeam().First(x => x.Id != me.Id);

            return(world.Puck.OwnerHockeyistId == me.Id || me.GetDistanceTo(world.Puck) < teammate.GetDistanceTo(world.Puck));
        }
示例#3
0
        public static Point MyNetDefensePoint(this World _world)
        {
            Player player = _world.GetMyPlayer();

            Hockeyist goalie =
                _world.Hockeyists.FirstOrDefault(
                    x => x.Type == HockeyistType.Goalie && x.PlayerId == player.Id);

            double netX = 0.5D * (player.NetBack + player.NetFront);
            double netY = 0.5D * (player.NetBottom + player.NetTop);

            if (goalie != null)
            {
                var game = Get <Game> .Current();

                netY += (goalie.Y > netY ? 0.5D : -0.5D) * game.GoalNetHeight / 2;
            }

            return(new Point(netX, netY));
        }
示例#4
0
        public static bool InNetFrame(this Hockeyist me)
        {
            Player p = Get <World> .Current().GetMyPlayer();

            return(me.Y < p.NetBottom && me.Y > p.NetTop);
        }
示例#5
0
        public static bool OwnsThePuck(this Hockeyist me)
        {
            var w = Get <World> .Current();

            return(w.Puck.OwnerHockeyistId == me.Id);
        }