Esempio n. 1
0
        public IBike ClosestBike(long curTime, IBike thisBike)
        {
            BikeDynState thisBikeState = thisBike.DynamicState(curTime);

            return(Bikes.Count <= 1 ? null : Bikes.Values.Where(b => b != thisBike)
                   .OrderBy(b => Vector2.Distance(b.DynamicState(curTime).position, thisBikeState.position)).First());
        }
Esempio n. 2
0
        public List <Vector2> CloseBikePositions(long curTime, IBike thisBike, int maxCnt)
        {
            // Todo: this is actually "current enemy pos"
            BikeDynState thisBikeState = thisBike.DynamicState(curTime);

            return(Bikes.Values.Where(b => b != thisBike)
                   .OrderBy(b => Vector2.Distance(b.DynamicState(curTime).position, thisBikeState.position)).Take(maxCnt) // IBikes
                   .Select(ob => ob.DynamicState(curTime).position).ToList());                                            // TODO: extract dynamic states rather than recalc? Maybe not?
        }
Esempio n. 3
0
        public void PostBikeTurn(IBike bike, TurnDir dir)
        {
            // This only comes from local AI and player - and "too close" is probably already caught by the bike controller
            BikeDynState bs     = bike.DynamicState(CurrentRunningGameTime); // TODO: Really?
            Vector2      nextPt = (bike as BaseBike).UpcomingGridPoint(bs.position);

            float dx = Vector2.Distance(bs.position, nextPt);

            if (dx < BaseBike.length * .5f)
            {
                logger.Warn($"PostBikeTurn(): Bike too close to turn: {dx} < {BaseBike.length * .5f}");
            }
            else
            {
                apian.SendBikeTurnReq(FrameApianTime, bike, dir, nextPt);
            }
        }