예제 #1
0
        public void OnRemoveBikeCmd(RemoveBikeMsg msg)
        {
            logger.Info($"OnRemoveBikeCmd({msg.bikeId}) Now: {FrameApianTime} Ts: {msg.TimeStamp}");
            IBike ib = CoreData.GetBaseBike(msg.bikeId);

            _RemoveBike(ib, true);
        }
예제 #2
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());
        }
예제 #3
0
        static void Main(string[] args)
        {
            PullExample.Run();

            PushExample1.Run();

            PushExample2.Run();

            PushExample3.Run();

            Rx.Run();

            Async.MyAsync().ContinueWith((t) => Console.WriteLine($"Ende")).Wait();

            var items = new IBike[]
            {
                new Rahmen("KTM", "Ultra Sport 2016", 403.99m, Waehrung.EUR),
                new Bremsen("Shimano", "Brake XS", 38500.60m, Waehrung.JPY),
                new Schaltwerk("Shimano", "Deore XTR", 56749.95m, Waehrung.JPY),
                new Reifen("Schwalbe", "Pro 751", 35.24m, Waehrung.EUR),
                new Rahmen("Santa Cruz", "SC1524", 2505.00m, Waehrung.USD),
                new Bremsen("Shimano", "Brake STS", 60500.60m, Waehrung.JPY),
                new Schaltwerk("Shimano", "Deore XTR", 56749.95m, Waehrung.JPY),
                new Reifen("Michelin", "MB 2020", 42.50m, Waehrung.EUR),
            };

            var waehrung = Waehrung.EUR;

            foreach (var x in items)
            {
                Console.WriteLine($"{x.Description} {x.Mod} {x.Preis.ConvertTo(waehrung).Amount,8:0.00} {waehrung} ");
            }

            JSon.Run(items);
        }
예제 #4
0
        public static void Main()
        {
            BikeFactory factory  = new BikeFactory();
            IBike       roadBike = factory.GetBike("RoadBike");

            Console.WriteLine(roadBike.Description);
        }
예제 #5
0
 protected void _RemoveBike(IBike ib, bool shouldBlowUp = true)
 {
     logger.Info($"_RemoveBike(): {ib.bikeId}");
     CoreData.RemovePlacesForBike(ib);
     BikeRemovedEvt?.Invoke(this, new BikeRemovedData(ib.bikeId, shouldBlowUp));
     CoreData.PostBikeRemoval(ib.bikeId); // we're almost certainly iterating over the list of bikes so don;t remove it yet.
 }
예제 #6
0
        // Bikes
        public void OnNewBikeEvt(object sender, IBike ib)
        {
            logger.Info($"OnNewBikeEvt(). Id: {SID(ib.bikeId)}, Local: {ib.peerId == appCore.LocalPeerId}, AI: {ib.ctrlType == BikeFactory.AiCtrl}");
            FrontendBike b = FeBikeFactory.Create(ib, ib.peerId == appCore.LocalPeerId);

            b.Setup(ib, beamAppl, appCore);
            feBikes[ib.bikeId] = b;
        }
예제 #7
0
 public void RemovePlacesForBike(IBike bike)
 {
     Logger.Info($"RemovePlacesForBike({bike.bikeId})");
     foreach (BeamPlace p in PlacesForBike(bike))
     {
         PostPlaceRemoval(p);
     }
 }
예제 #8
0
 public BikeState(IBike ib)
 {
     score   = ib.score;
     xPos    = ib.basePosition.x;
     yPos    = ib.basePosition.y;
     heading = ib.baseHeading;
     speed   = ib.speed;
 }
예제 #9
0
 public virtual void Setup(IBike beBike, IBeamApplication appl, IBeamAppCore core)
 {
     Logger  = UniLogger.GetLogger("Frontend"); // use the FE logger
     appCore = core;
     bb      = beBike;
     CreateControl();
     control.Setup(appl, core, beBike);
 }
        public void Should_create_a_Bike_of_the_specified_type(IVehicleFactory vehicleFactory, Type expectedBikeType)
        {
            // Act
            IBike result = vehicleFactory.CreateBike();

            // Assert
            Assert.IsType(expectedBikeType, result);
        }
예제 #11
0
 public PlaceReportArgs(IBike _bike, int _xIdx, int _zIdx, Heading _entryH, Heading _exitH)
 {
     bike      = _bike;
     xIdx      = _xIdx;
     zIdx      = _zIdx;
     entryHead = _entryH;
     exitHead  = _exitH;
 }
예제 #12
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?
        }
예제 #13
0
        public void OnNewBikeEvt(object sender, IBike ib)
        {
            bool isLocal = ib.peerId == game.LocalPeerId;

            logger.Info($"{(ModeName())} - OnNewBikeEvt() - New {(isLocal?"Local":"Remote")} bike: {ib.bikeId}");
            if (_curState == kCreatingBikes && isLocal)
            {
                _SetState(kReadyToPlay, null);
            }
        }
예제 #14
0
    //
    // API
    //


    //
    // Utility
    //

    // Bike Factory stuff

    static public GameObject CreateBike(IBike ib, FeGround feGround)
    {
        GameObject newBike = GameObject.Instantiate(FrontendBikeFactory.GetInstance().bikePrefab, utils.Vec3(ib.basePosition), Quaternion.identity) as GameObject;

        newBike.AddComponent(bikeClassTypes[ib.ctrlType]);
        newBike.transform.parent = feGround.transform;
        FrontendBike bk = (FrontendBike)newBike.transform.GetComponent("FrontendBike");

        bk.Setup(ib, BeamMain.GetInstance().beamApp.mainGameInst);
        return(newBike);
    }
예제 #15
0
        public void OnNewBikeEvt(object sender, IBike newBike)
        {
            // If it's local we need to tell it to Go!
            bool isLocal = newBike.peerId == appl.LocalPeer.PeerId;

            logger.Info($"{(ModeName())} - OnNewBikeEvt() - {(isLocal?"Local":"Remote")} Bike created, ID: {newBike.bikeId} Sending GO! command");
            if (isLocal)
            {
                game.PostBikeCommand(newBike, BikeCommand.kGo);
            }
        }
예제 #16
0
        // Places stuff

        // Set up a place instance for use or re-use
        protected BeamPlace SetupPlace(IBike bike, int xIdx, int zIdx, long expireTimeMs)
        {
            BeamPlace p = freePlaces.Count > 0 ? freePlaces.Pop() : new BeamPlace();

            // Maybe populating a new one, maybe re-populating a used one.
            p.expirationTimeMs = expireTimeMs;
            p.xIdx             = xIdx;
            p.zIdx             = zIdx;
            p.bike             = bike;
            return(SetupPlace(p));
        }
예제 #17
0
        public void RoadBikeShop_OrderBike_ReturnsInstanceOfRoadBike()
        {
            // Arrange
            IBikeShop shop = new RoadBikeShop();

            // Act
            IBike bike = shop.OrderBike("test");

            // Assert
            Assert.IsInstanceOfType(bike, typeof(RoadBike));
        }
예제 #18
0
        public void MountainBikeShop_OrderBike_ReturnsInstanceOfHybridBike()
        {
            // Arrange
            IBikeShop shop = new HybridBikeShop();

            // Act
            IBike bike = shop.OrderBike("test");

            // Assert
            Assert.IsInstanceOfType(bike, typeof(HybridBike));
        }
예제 #19
0
        public void OnCreateBikeCmd(BikeCreateDataMsg msg)
        {
            logger.Verbose($"OnCreateBikeCmd(): {msg.bikeId}.");
            IBike ib = msg.ToBike(CoreData);

            logger.Verbose($"** OnCreateBike() created {ib.bikeId} at ({ib.basePosition.x}, {ib.basePosition.y})");
            if (_AddBike(ib))
            {
                // *** Bikes are created stationary now - so there's no need to correct for creation time delay
                logger.Verbose($"OnCreateBike() created {ib.bikeId} at ({ib.basePosition.x}, {ib.basePosition.y})");
            }
        }
예제 #20
0
        public async Task AddBike(IBike bike)
        {
            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(bike), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync($"{apiUrl}", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();
                }
            }
        }
예제 #21
0
파일: BikeTask.cs 프로젝트: fite474/3IPRGVD
 public void UseSimulator()
 {
     if (threadRunning)
     {
         bike.Close();
     }
     bike = new BikeSimulator();
     if (!threadRunning)
     {
         thread = new Thread(StartBikeSession);
         thread.Start();
     }
 }
예제 #22
0
 protected void ApplyScoreUpdate(Dictionary <string, int> update)
 {
     foreach (string id in update.Keys)
     {
         IBike bike = CoreData.GetBaseBike(id);
         bike?.AddScore(update[id]);
         if (bike.score <= 0)
         {
             logger.Info($"ApplyScoreUpdate(). Bike: {bike.bikeId} has no score anymore!");
             apian.SendRemoveBikeObs(FrameApianTime, bike.bikeId);
         }
     }
 }
예제 #23
0
        public static void Run()
        {
            CVehicle Car  = new CVehicle();
            CVehicle Bike = new CVehicle();

            ICar  ICar  = Car as ICar;
            IBike IBike = Bike as IBike;

            ICar.CarM1();
            ICar.CarM2();
            IBike.BikeM1();
            IBike.BikeM2();
        }
예제 #24
0
파일: BikeTask.cs 프로젝트: fite474/3IPRGVD
 public void ChangeBike(string comPort)
 {
     if (threadRunning)
     {
         bike.Close();
     }
     bike = new BikeKettler(comPort);
     if (!threadRunning)
     {
         thread = new Thread(StartBikeSession);
         thread.Start();
     }
 }
예제 #25
0
        public bool _AddBike(IBike ib)
        {
            logger.Verbose($"_AddBike(): {ib.bikeId} at ({ib.basePosition.x}, {ib.basePosition.y})");

            if (CoreData.GetBaseBike(ib.bikeId) != null)
            {
                return(false);
            }

            CoreData.Bikes[ib.bikeId] = ib;

            NewBikeEvt?.Invoke(this, ib);

            return(true);
        }
예제 #26
0
        public static void Main()
        {
            BikeFactory factory = new BikeFactory();

            IBike roadBike = factory.GetBike("RoadBike");

            roadBike.FrameSize = 54;

            Console.WriteLine(roadBike.Description + " with " + roadBike.FrameSize);

            IBike anotherBike = factory.GetBike("RoadBike");

            Console.WriteLine(anotherBike.Description + " with " + anotherBike.FrameSize);

            Console.ReadLine();
        }
예제 #27
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);
            }
        }
예제 #28
0
 public void AddBikeToGarage(IBike bike)
 {
     try
     {
         Bikes.Add(bike);
     }
     catch (ArgumentNullException nullException)
     {
         ConsoleColor prevColour = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Null bikes Exceptopm.");
         Console.WriteLine($"{nullException.Message}");
         Console.WriteLine($"{nullException.TargetSite}");
         Console.WriteLine($"{nullException.StackTrace}");
         Console.ForegroundColor = prevColour;
     }
 }
예제 #29
0
    // Bikes

    public void OnNewBikeEvt(object sender, IBike ib)
    {
        logger.Info($"OnNewBikeEvt(). Id: {ib.bikeId}, LocalPlayer: {ib.ctrlType == BikeFactory.LocalPlayerCtrl}");
        GameObject bikeGo = FrontendBikeFactory.CreateBike(ib, feGround);

        feBikes[ib.bikeId] = bikeGo;
        if (ib.ctrlType == BikeFactory.LocalPlayerCtrl)
        {
            mainObj.inputDispatch.SetLocalPlayerBike(bikeGo);
            mainObj.uiController.CurrentStage().transform.Find("RestartBtn")?.SendMessage("moveOffScreen", null);
            mainObj.uiController.CurrentStage().transform.Find("Scoreboard")?.SendMessage("SetLocalPlayerBike", bikeGo);
            mainObj.gameCamera.StartBikeMode(bikeGo);
        }
        else
        {
            mainObj.uiController.CurrentStage().transform.Find("Scoreboard")?.SendMessage("AddBike", bikeGo);
        }

        mainObj.uiController.ShowToast($"New Bike: {ib.name}", Toast.ToastColor.kBlue);
    }
예제 #30
0
        public void DoWork(IBike bike)
        {
            // adjust the pressure in the tires
            switch (bike.Type)
            {
            case Common.BikeType.Hybrid:
                bike.TirePressure += new Random().Next(-20, 20);
                break;

            case Common.BikeType.Mountain:
                bike.TirePressure += new Random().Next(-5, 5);
                break;

            case Common.BikeType.Road:
                bike.TirePressure += new Random().Next(-40, 40);
                break;

            default:
                throw new ArgumentOutOfRangeException($"{bike.Type} isn't a supported bike type");
            }
        }