Example #1
0
        private static object BothOrEither(DynamicDelegate f, DynamicDelegate g, Func <Func <bool>, Func <bool>, bool> operand, dynamic liftBy)
        {
            if (f.IsNotNull())
            {
                return(Delegate((object[] arguments) => operand(() => f.DynamicInvoke <bool>(arguments), () => g.DynamicInvoke <bool>(arguments))));
            }

            return(Lift(liftBy)(f, g));
        }
    public Vector3 AddForces()
    {
        Vector3 resultant = new Vector3();

        resultant = Gravity.CalculateGravity(weight) + Lift.CalculateLift(mesh);
        return(resultant);
    }
Example #3
0
        public void LiftHasCurrentLocationOfGroundWhenInitialized()
        {
            Lift lift = LiftFactory.CreateLift();

            Assert.Equal(0, lift.CurrentFloor);
            Assert.Equal(LiftStatus.Awaiting, lift.CurrentStatus);
        }
Example #4
0
    // Use this for initialization
    //	void Start () {}

    // Update is called once per frame
    void Update()
    {
        // 左右移動入力
        walkStandbyVec = GetWalkInput();

        // ジャンプ入力
        jumpStandbyFlg |= GetJumpInput();

        // ジャンプ滞空時間
        remainJumpTime = (!Land.IsLanding ? remainJumpTime + Time.deltaTime : 0.0f);

        // 持ち上げ/下げ
        if ((Land.IsLanding || WaterStt.IsWaterSurface) && !IsRotation)
        {
            if (GetLiftInput())
            {
                if (!liftTrg)
                {
                    Lift.Lift();
                }
                liftTrg = true;
            }
            else
            {
                liftTrg = false;
            }
        }
    }
Example #5
0
    public static int[] TheLift(int[][] queues, int capacity)
    {
        var building = RidersDict(queues);
        var lift     = new Lift(queues.Length - 1, capacity);

        int peopleOnFloor = building[0].Count;

        if (peopleOnFloor != 0)
        {
            for (int i = 0; i < peopleOnFloor; i++)
            {
                if (lift.IsLiftFull())
                {
                    break;
                }
                lift.PassengerOn(building[0][i]);
                building[lift.CurrentFloor].Remove(building[lift.CurrentFloor][i]);
                peopleOnFloor--;
                i--;
            }
        }

        lift.AddCurrentToStopList();
        int nextStop = 0;

        while (nextStop != -1)
        {
            nextStop = lift.NextStop(building);
            if (nextStop == -1)
            {
                break;
            }
            lift.CurrentFloor = nextStop;
            lift.AddCurrentToStopList();
            lift.PassengerOff();
            peopleOnFloor = building[lift.CurrentFloor].Count;
            for (int j = 0; j < peopleOnFloor; j++)
            {
                if (lift.IsLiftFull())
                {
                    break;
                }
                if (building[lift.CurrentFloor][j].UpOrDown == lift.CurrentDirection)
                {
                    lift.PassengerOn(building[lift.CurrentFloor][j]);
                    building[lift.CurrentFloor].Remove(building[lift.CurrentFloor][j]);
                    peopleOnFloor--;
                    j--;
                }
            }
        }

        if (lift.CurrentFloor == 0)
        {
            return(lift.GetStopsList().ToArray());
        }
        lift.CurrentFloor = 0;
        lift.AddCurrentToStopList();
        return(lift.GetStopsList().ToArray());
    }
Example #6
0
    // ------------------------------------------------------------------------

    public bool nextFieldAvailable(Vector3 direction)
    {
        RaycastHit hit;

        // check if something is standing on the field
        if (Debug.isDebugBuild)
        {
            Debug.DrawRay(endPosition + Vector3.up * 0.25f, direction, Color.blue, 0.5f);
        }

        if (Physics.Raycast(endPosition + Vector3.up * 0.25f, direction, out hit, 1f))
        {
            return(false);
        }

        Floor floor = getFloor(endPosition + direction);

        if (!floor || (floor && !floor.isFree(gameObject)))
        {
            return(false);
        }

        Lift lift = floor.gameObject.GetComponent <Lift>();

        if (lift && lift.isPlaying())
        {
            return(false);
        }
        return(true);
    }
        public void ExecutionPlan_HasSummonAndDesitnationDescOrder_WhenSummonedFrom2FloorsToGoDownAndParkedHigherThanBothAndRequestImmediatlyFollowSummonAndFirstRequestIsFromLowerFloor()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(8, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Down);
            SummonInformation         request1 = new SummonInformation(1, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon2,
                request2,
                summon1,
                request1
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(2));
        }
        public void ExecutionPlan_HasSummonAndDesitnationAscOrder_WhenSummonedFrom2DifferentFloorsHigherThanParkedToUpAndDifferentRequestedFloorsAndUser2RequestLowerFloorThanUser1SummoningAndParkedFloorInBetween()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(5, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(9, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request2 = new SummonInformation(3, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(3));
        }
        public void ExecutionPlan_HasSummonAndDesitnationAscOrder_WhenSummonedFrom2DifferentFloorsAndFirstSummonRequestUpAndSecondSummonRequestDown()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(6, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(6, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(13, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(5, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(3));
        }
Example #10
0
 private static void Prefix(Lift __instance)
 {
     if (SameThings.Instance.Config.LiftMoveDuration > -1)
     {
         __instance.movingSpeed = SameThings.Instance.Config.LiftMoveDuration;
     }
 }
Example #11
0
    void HandleClickOnGuest(GameObject guestGO)
    {
        Lift lift = HotelController.Instance.GetCurrentLift();

        Guest guest = gameObjectToGuestMap[guestGO];

        if (guest.guestReadyForLift && lift.currentFloor == guest.currentFloor && lift.doorsClosed == false && guest.lift == null)
        {
            Debug.Log("CLICKED ON GUEST: " + guest.currentFloor + " " + guest.patience);

            if (clickTextDone == false)
            {
                clickTextDone     = true;
                tutorialText.text = "SELECT GUEST'S REQUESTED FLOOR";
            }

            for (int i = 0; i < 6; i++)
            {
                if (lift.slots[i] == null)
                {
                    lift.slots[i] = guest;
                    SendGuestToLift(guest, lift, i);
                    return;
                }
            }
        }
    }
Example #12
0
    public void ArrivedOnFloor(Lift lift)
    {
        GameObject liftGo = GetLiftGameObject(lift);

        Transform liftTransform = GetLiftGameObject(lift).transform;

        liftTransform.localPosition = new Vector3(liftTransform.localPosition.x,
                                                  (float)lift.targetFloor, liftTransform.localPosition.z);

        Debug.Log("OPEN DOORS ON LIFT " + lift.id);

        lift.arrivedOnFloorTimer = 3f;

        Display display = liftGo.GetComponent <Display> ();

        display.currentSpeed          = 0f;
        display.distanceToTargetFloor = 0f;

        lift.doorsOpening  = true;
        lift.doorsClosing  = false;
        lift.doorsClosed   = false;
        lift.doorsOpen     = true;
        lift.liftOpenTimer = 0f;

        lift.liftButtonsPressed[lift.currentFloor] = false;
        UpdateLiftButtonLight(lift, lift.currentFloor);

        CheckWhetherGuestsGetOut(lift);

        SoundController.Instance.Ding();
    }
Example #13
0
    public void SetLiftPositionFromFloor(Lift lift, int floor)
    {
        Transform liftTransform = GetLiftGameObject(lift).transform;

        liftTransform.localPosition = new Vector3(liftTransform.localPosition.x,
                                                  (float)floor, liftTransform.localPosition.z);
    }
Example #14
0
    void HandleClickOnLift(GameObject go, bool leftButton)
    {
        Lift lift = gameObjectToLiftMap[go];

        if (leftButton)
        {
            HotelController.Instance.liftBeingControlled = lift.id;
            HotelController.Instance.selectionCylinder.SetCylinder(lift.id);
            LiftController.Instance.liftSelectedText.text = "Lift " + (HotelController.Instance.liftBeingControlled + 1).ToString();
            LiftController.Instance.UpdateLiftButtonLights();
        }
        else
        {
            Debug.Log("Right click on lift " + lift.id);


            if (lift.doorsOpening || lift.doorsOpen)
            {
                lift.doorsClosing = true;
                lift.doorsOpening = false;
                lift.doorsOpen    = false;
                SoundController.Instance.Doors();
            }

            else
            {
                lift.doorsOpening = true;
                lift.doorsClosing = false;
                lift.doorsClosed  = false;
                SoundController.Instance.Doors();
            }
        }
    }
Example #15
0
        public async Task <IActionResult> Edit(int id, [Bind("LiftID,UserID,DateTimePerformed,ExercisePerfromed,Weight,Reps")] Lift lift)
        {
            if (id != lift.LiftID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lift);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LiftExists(lift.LiftID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lift));
        }
Example #16
0
            public void WhenOpenDoorsAndNoDirection_ThenLiftDoorsOpenAndSetDireciton()
            {
                var lift = new Lift()
                {
                    Level     = 5,
                    State     = LiftState.Stopped,
                    Direction = null
                };

                var passengerGettingOn = new Passenger(0);
                var summons            = new List <Summon>()
                {
                    new Summon(5, Direction.Down, new List <Passenger>()
                    {
                        passengerGettingOn
                    })
                };

                LiftService.ExecuteInstruction(Instruction.OpenDoors, lift, summons);

                Assert.True(lift.State == LiftState.DoorsOpen);
                // passengers get on
                Assert.Contains(passengerGettingOn, lift.Passengers);
                // answered summons are removed
                Assert.Empty(summons);
                // direction set
                Assert.True(lift.Direction == Direction.Down);
            }
Example #17
0
        /// <SUMMARY>
        /// Start Service
        /// </SUMMARY>
        public override void StartService()
        {
            var procs = Environment.ProcessorCount;

            ThreadPool.SetMaxThreads(procs, Math.Max(1, procs / 4));
            ThreadPool.SetMaxThreads(procs * 2, Math.Max(1, procs / 2));

            LoggingProvider.Use(LoggingProvider.FileLoggingProvider);

            var config = ConfigManager.Load <ServerConfig>();

            server = new HttpBackend(IPAddress.Any, config.ListenPort);

            var staticWebContentFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web");

            var routeTable = new RouteTable(
                Route.Get("/*").With(new DirectoryInfo(staticWebContentFolder)),
                Route.Get("/month").With(Lift.ToJsonHandler(getShiolMonthFiles))
                .ApplyResponseFilter(Filters.GZip)
                .LimitRate(100),
                Route.Get("/date").With((req) => processRequest(req)),
                Route.Get("/trama").With((req) => processRequest(req))
                );

            server.Start(routeTable);
        }
        public void ExecutionPlan_HasExpectedAscUpToMaxFloorThenDesc_WhenSummonedFrom3FloorsTo2DifferentsFloors()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(2, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(5, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         summon3  = new SummonInformation(10, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(0, TravelDirection.None, summon2);
            SummonInformation         request3 = new SummonInformation(0, TravelDirection.None, summon3);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                summon3,
                request2,
                request3
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(summon3.SummonFloor, planResult.ElementAt(2));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(3));
            Assert.Equal(request2.SummonFloor, planResult.ElementAt(4));
        }
Example #19
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag("Lift"))
     {
         currentLift = null;
     }
 }
Example #20
0
        public static void Main(string[] args)
        {
            var procs = Environment.ProcessorCount;

            ThreadPool.SetMaxThreads(procs, Math.Max(1, procs / 4));
            ThreadPool.SetMaxThreads(procs * 2, Math.Max(1, procs / 2));

            LoggingProvider.Use(LoggingProvider.ConsoleLoggingProvider);

            var config = ConfigManager.Load <ServerConfig>();

            var server = new HttpBackend(IPAddress.Any, config.ListenPort);

            var wsService = new WebSocketService();
            var staticWebContentFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web");

            var routeTable = new RouteTable(
                Route.Get("/*").With(new DirectoryInfo(staticWebContentFolder)),
                Route.Get("/").With(wsService.Redirect),
                Route.Get("/plaintext").With(() => greeting),
                Route.Get("/plaintext/delayed").WithAsync(DelayedGreeter),
                Route.GetWebSocketUpgrade("/ws").With(wsService.HandleUpgradeRequest),
                Route.Get("/metrics").With(Lift.ToJsonHandler(server.GetMetricsReport))
                .ApplyResponseFilter(Filters.GZip)
                .LimitRate(100)
                );

            server.Start(routeTable);
        }
Example #21
0
        public async Task <ActionResult <Lift> > PostLift(Lift lift)
        {
            _db.Lifts.Add(lift);
            await _db.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetLiftById), new { id = lift.Id }, lift));
        }
Example #22
0
        public static LiftModel Lift(Lift lift)
        {
            IEnumerable <Coordinate> getCoordinates()
            {
                yield return(new Coordinate(lift.Point1Latitude, lift.Point1Longitude));

                yield return(new Coordinate(lift.Point2Latitude, lift.Point2Longitude));

                if (lift.Point3Latitude.HasValue)
                {
                    yield return(new Coordinate(lift.Point3Latitude.Value, lift.Point3Longitude.Value));
                }
                if (lift.Point4Latitude.HasValue)
                {
                    yield return(new Coordinate(lift.Point4Latitude.Value, lift.Point4Longitude.Value));
                }
                if (lift.Point5Latitude.HasValue)
                {
                    yield return(new Coordinate(lift.Point5Latitude.Value, lift.Point5Longitude.Value));
                }
            }

            return(new LiftModel
            {
                LiftId = lift.LiftID,
                Name = lift.Name,
                LiftType = ((LiftTypeEnum)lift.TypeId).GetDescription(),
                Occupancy = lift.Occupancy,
                Resort = null,
                Coordinates = getCoordinates().ToList(),
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingElevatorEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="elevator"><inheritdoc cref="Elevator"/></param>
 /// <param name="lift"><inheritdoc cref="Type"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public InteractingElevatorEventArgs(Player player, global::Lift.Elevator elevator, global::Lift lift, bool isAllowed = true)
 {
     Lift      = Lift.Get(lift);
     Player    = player;
     Elevator  = Lift.Elevators.FirstOrDefault(elev => elev.Base == elevator);
     IsAllowed = isAllowed;
 }
Example #24
0
        public async Task<IHttpActionResult> PutLift(int id, Lift lift)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != lift.LiftID)
            {
                return BadRequest();
            }

            db.Entry(lift).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiftExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Example #25
0
        public IHttpActionResult PutLift(int id, Lift lift)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lift.Id)
            {
                return(BadRequest());
            }

            db.Entry(lift).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiftExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void Lift_CreateExecutionPlanWith6Values_WhenSummonedFrom3FloorsTo3DifferentsFloors()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(0, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(0, TravelDirection.Up);
            SummonInformation         request1 = new SummonInformation(5, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         summon3  = new SummonInformation(10, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            SummonInformation         request3 = new SummonInformation(8, TravelDirection.None, summon3);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                summon3,
                request2,
                request3
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(6, planResult.Count());
        }
Example #27
0
        private void AddLiftId(Trail trail)
        {
            bool isIdValid = false;

            ListAllLifts();
            while (isIdValid == false)
            {
                Console.WriteLine("\nEnter lift id to access the trail: ");
                int value;

                if (!int.TryParse(Console.ReadLine(), out value))
                {
                    Console.WriteLine("Input must be a number!", Color.Pink);
                }
                else
                {
                    int  id   = value;
                    Lift lift = liftController.Get(id);
                    if (lift.Name != null)
                    {
                        isIdValid    = true;
                        trail.LiftId = id;
                    }
                }
            }
        }
Example #28
0
        protected override void ComputeVelocity()
        {
            jumpFrame = false;

            Vector2 move = Vector2.zero;

            move.x = input.Direction.x;

            if (input.GetButtonDown("Jump") && Grounded)
            {
                velocity.y = jumpTakeOffSpeed;
                isJumping  = true;
                jumpFrame  = true;

                jumpLift = currentLift;
            }
            else if (input.GetButtonUp("Jump"))
            {
                if (velocity.y > 0)
                {
                    velocity.y *= 0.5f;
                }
            }

            TargetVelocity = move * maxSpeed;
        }
Example #29
0
        public static LiftViewModel MapLiftToViewModel(Lift lift, string uid)
        {
            var vm = new LiftViewModel()
            {
                MaxLift    = lift.MaxLift,
                IsMainLift = lift.IsMainLift,
                LiftName   = lift.LiftName.Name,
                LiftType   = lift.LiftType.Name,
                Date       = lift.Date,
                Day        = lift.Days.Day,
                Lift       = new Lift()
                {
                    Id         = lift.Id,
                    MaxLift    = lift.MaxLift,
                    IsMainLift = lift.IsMainLift,
                    Date       = lift.Date,
                    UserId     = uid,
                    LiftName   = new LiftName()
                    {
                        Id = lift.LiftName.Id
                    },
                    LiftType = new LiftType()
                    {
                        Id = lift.LiftType.Id
                    }
                }
            };

            return(vm);
        }
Example #30
0
    // ------------------------------------------------------------------------

    public override bool grabbed(GameObject by)
    {
        if (ForceLift.liftsActive)
        {
            return(false);
        }

        ForceLift.liftsActive = true;

        foreach (GameObject g in GameObject.FindGameObjectsWithTag("Lift"))
        {
            Lift lift = g.GetComponent <Lift>();
            if (lift.getCarriedElement())            // skip if something stands on the lift
            {
                continue;
            }
            if (triggerUp)
            {
                lift.up();
            }
            else
            {
                lift.down();
            }
        }
        return(true);
    }
Example #31
0
            private void NetworkUpdate()
            {
                if (Lift.net.group.subscribers.Count == 0)
                {
                    return;
                }

                if (Net.sv.write.Start())
                {
                    Net.sv.write.PacketID(Message.Type.GroupChange);
                    Net.sv.write.EntityID(Lift.net.ID);
                    Net.sv.write.GroupID(Lift.net.group.ID);
                    Net.sv.write.Send(new SendInfo(Lift.net.group.subscribers));
                }

                if (Net.sv.write.Start())
                {
                    Net.sv.write.PacketID(Message.Type.EntityPosition);
                    Net.sv.write.EntityID(Lift.net.ID);
                    Net.sv.write.Vector3(Lift.GetNetworkPosition());
                    Net.sv.write.Vector3(Lift.GetNetworkRotation().eulerAngles);
                    Net.sv.write.Float(Lift.GetNetworkTime());

                    SendInfo info = new SendInfo(Lift.net.group.subscribers);
                    info.method   = SendMethod.ReliableUnordered;
                    info.priority = Priority.Immediate;
                    Net.sv.write.Send(info);
                }
            }
Example #32
0
 static void Main(string[] args)
 {
     Lift lift = new Lift();
     while(true)
     {
         Console.WriteLine("The elevator is now in {0} floor ", lift.Floor);
         Console.Write("Give a new floor number (1-5) > ");
         lift.Floor = int.Parse(Console.ReadLine());
     }
 }
Example #33
0
        public async Task<IHttpActionResult> PostLift(Lift lift)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Lifts.Add(lift);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = lift.LiftID }, lift);
        }
Example #34
0
 public void Test1()
 {
     var groundFloor = new Floor(0);
     var lift = new Lift(groundFloor);
     var events = new List<LiftArrivedEvent>();
     lift.ArriveAtFloor += events.Add;
     var firstFloor = new Floor(1);
     lift.Summon(firstFloor, Direction.Down);
     Assert.That(events.Count, Is.EqualTo(1));
     Assert.That(events[0].Direction, Is.EqualTo(Direction.Down));
     Assert.That(events[0].Floor, Is.EqualTo(firstFloor));
 }
Example #35
0
 public void Test3()
 {
     var secondFloor = new Floor(2);
     var lift = new Lift(secondFloor);
     var events = new List<LiftArrivedEvent>();
     lift.ArriveAtFloor += events.Add;
     var groundFloor = new Floor(0);
     lift.Summon(groundFloor, Direction.Up);
     Assert.That(events.Count, Is.EqualTo(2));
     Assert.That(events[0].Direction, Is.EqualTo(Direction.Down));
     Assert.That(events[0].Floor, Is.EqualTo(new Floor(1)));
     Assert.That(events[1].Direction, Is.EqualTo(Direction.Up));
     Assert.That(events[1].Floor, Is.EqualTo(new Floor(0)));
 }
Example #36
0
 public void Test4()
 {
     var groundFloor = new Floor(0);
     var lift = new Lift(groundFloor);
     var events = new List<LiftArrivedEvent>();
     lift.ArriveAtFloor += events.Add;
     var thirdFloor = new Floor(3);
     lift.GoTo(thirdFloor);
     Assert.That(events.Count, Is.EqualTo(3));
     Assert.That(events[0].Direction, Is.EqualTo(Direction.Up));
     Assert.That(events[0].Floor, Is.EqualTo(new Floor(1)));
     Assert.That(events[1].Direction, Is.EqualTo(Direction.Up));
     Assert.That(events[1].Floor, Is.EqualTo(new Floor(2)));
     Assert.That(events[2].Direction, Is.EqualTo(Direction.Stationary));
     Assert.That(events[2].Floor, Is.EqualTo(new Floor(3)));
 }
Example #37
0
File: Map.cs Project: saltire/droid
    public void ShowMap(Lift lift)
    {
        // Pause game.
        Time.timeScale = 0;

        string levelName = lift.transform.parent.name;
        currentLiftIndex = lift.liftIndex;

        SetLiftPosition(Array.IndexOf(lifts[currentLiftIndex], levelName));

        // Light up current lift.
        if (currentLiftObject) {
            currentLiftObject.GetComponent<Renderer>().material.SetColor("_EmissionColor", Color.black);
        }
        currentLiftObject = transform.Find("Lift " + (char)(65 + currentLiftIndex));
        currentLiftObject.GetComponent<Renderer>().material.SetColor("_EmissionColor", Color.white);

        // Switch cameras.
        mapCamera.enabled = true;

        fireReleased = false;
    }
Example #38
0
    public void Update()
    {
        if (selecting) {

            if ((Input.GetButtonDown("Up") || Input.GetButtonDown("Left")) && selIndex > 0) {
                selIndex--;
            }
            if ((Input.GetButtonDown("Down") || Input.GetButtonDown("Right")) && selIndex < options.Length - 1) {
                selIndex++;
            }
            if (Input.GetButtonDown("Select")) {
                string result = options[selIndex];

                if (result != "Skill") {

                    CharAction caction = null;

                    if (result == "Move") { caction = new Move(dchar) as CharAction; }
                    if (result == "Lift") { caction = new Lift(dchar) as CharAction; }
                    if (result == "Attack") { caction = new Attack(dchar) as CharAction; }
                    if (result == "Lob") { caction = new Lob(dchar) as CharAction; }
                    if (result == "Whirlwind") { caction = new Whirlwind(dchar) as CharAction; }
                    if (result == "Inferno") { caction = new Inferno(dchar) as CharAction; }
                    if (result == "Exit") { Application.Quit(); }
                    selecting = false;

                    Camera.mainCamera.audio.PlayOneShot(Resources.Load("audio/se/select") as AudioClip);
                    StartCoroutine(YieldReturn(caction));

                }

            }
            if (Input.GetButtonDown("Cancel")) {
                selecting = false;
                Camera.mainCamera.audio.PlayOneShot(Resources.Load("audio/se/cancel") as AudioClip);
                cfunc();
            }
        }
    }