Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
    public Vector3 AddForces()
    {
        Vector3 resultant = new Vector3();

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

            Assert.Equal(0, lift.CurrentFloor);
            Assert.Equal(LiftStatus.Awaiting, lift.CurrentStatus);
        }
Ejemplo n.º 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;
            }
        }
    }
Ejemplo n.º 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());
    }
Ejemplo n.º 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));
        }
Ejemplo n.º 10
0
 private static void Prefix(Lift __instance)
 {
     if (SameThings.Instance.Config.LiftMoveDuration > -1)
     {
         __instance.movingSpeed = SameThings.Instance.Config.LiftMoveDuration;
     }
 }
Ejemplo n.º 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;
                }
            }
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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();
            }
        }
    }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
            }
Ejemplo n.º 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));
        }
Ejemplo n.º 19
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag("Lift"))
     {
         currentLift = null;
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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(),
            });
        }
Ejemplo n.º 23
0
 /// <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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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;
                    }
                }
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
                }
            }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 37
0
Archivo: Map.cs Proyecto: 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;
    }
Ejemplo n.º 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();
            }
        }
    }