Beispiel #1
0
        static void Main(string[] args)
        {
            StoriedBuilding building = new StoriedBuilding("B1", 10, 1, 1);
            LiftController  lc       = new LiftController(building);

            lc.Start();

            Random rnd = new Random();

            for (int i = 0; i < 10; i++)
            {
                byte currentFloor = (byte)rnd.Next(building.MinFloor, building.MaxFloor);
                byte targetFloor  = (byte)currentFloor;
                while (targetFloor == currentFloor)
                {
                    targetFloor = (byte)rnd.Next(building.MinFloor, building.MaxFloor);
                }
                byte weight = (byte)rnd.Next(0, 0);

                Passenger p = new Passenger(i, currentFloor, targetFloor, weight);

                lc.AddPassenger(p);
                Console.WriteLine("Add passenger [{0}]", i);
                Thread.Sleep(20000);
            }

            Console.Read();
        }
        public void GetLiftFromDatabaseById()
        {
            var data = new List <Lift>
            {
                new Lift {
                    Id = 1, Name = "First"
                },
                new Lift {
                    Id = 2, Name = "Second"
                },
                new Lift {
                    Id = 3, Name = "Third"
                },
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Lift> >();

            mockSet.As <IQueryable <Lift> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <SkiResortContext>();

            mockContext.Setup(c => c.Lifts).Returns(mockSet.Object);

            var controller = new LiftController(mockContext.Object);
            var lift       = controller.Get(1);

            Assert.AreEqual("First", lift.Name);
        }
 public void Setup()
 {
     _permissionService = new PermissionServiceMock();
     _projServ          = new ProjectServiceMock();
     _wordrepo          = new WordRepositoryMock();
     _liftController    = new LiftController(_wordrepo, _projServ, _permissionService);
     _wordService       = new WordService(_wordrepo);
 }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        movementState = 0;
        inv           = new PlayerInventory();
        inv.coffeePot = new CoffeePot(6);

        animator       = GetComponentInChildren <Animator>();
        liftController = lift.GetComponent <LiftController> ();        // could be null!
        SetPlayerCoffeeTextures();
    }
Beispiel #5
0
 public Lift(int liftNumber, int numberOfFloorButtons)
 {
     Number = liftNumber;
     EmergencyCallButton = new LiftButton(this);
     EmergencyExitButton = new LiftButton(this);
     OpenDoorButton = new OpenDoorButton(this);
     CloseDoorButton = new CloseDoorButton(this);
     FloorButtonList = CreateFloorButtons(numberOfFloorButtons);
     Controller = new LiftController(this);
 }
    private void StartGame()
    {
        _liftHolder.SetActive(true);
        _floorsHolder.SetActive(true);
        _setupsObjects.SetActive(false);

        _liftController   = FindObjectOfType <LiftController>();
        _floorsController = FindObjectOfType <FloorsController>();

        InitializeFloors();
        InitializeLiftButtons();
    }
Beispiel #7
0
    private void Awake()
    {
        Instance = this;

        _liftDirection = Direction.Stopped;
        DoorsText.text = "Двери\nоткрыты!";

        _currentFloor      = 1;
        LiftIndicator.text = "1";
        PlayerOnFloor.text = "1";

        PlayerOnFloor.onValueChanged.AddListener(delegate { LimitInputValue(); });
    }
Beispiel #8
0
        public void Setup()
        {
            _projRepo          = new ProjectRepositoryMock();
            _wordRepo          = new WordRepositoryMock();
            _liftService       = new LiftService();
            _notifyService     = new HubContextMock();
            _permissionService = new PermissionServiceMock();
            _wordService       = new WordService(_wordRepo);
            _liftController    = new LiftController(
                _wordRepo, _projRepo, _permissionService, _liftService, _notifyService, _logger);

            _logger = new MockLogger();
            _projId = _projRepo.Create(new Project {
                Name = ProjName
            }).Result !.Id;
        }
Beispiel #9
0
    private void get_aim(LiftController lift1, GameObject stair, HashSet <LiftController> eqlist)
    {
        LiftController goto_left = null, goto_right = null;

        foreach (Transform child in stair.transform)
        {
            switch (child.name)
            {
            case "LeftLift":
            case "Lift (1)":
                goto_left = child.gameObject.GetComponent <LiftController> ();
                break;

            case "RightLift":
            case "Lift":
                goto_right = child.gameObject.GetComponent <LiftController> ();
                break;

            default:
                break;
            }
        }
        lift1.up_or_down = up_or_down;
        if (up_or_down == false)
        {
            lift1.to     = goto_left.gameObject;
            goto_left.to = lift1.gameObject;
            eqlist.Add(goto_left.gameObject.GetComponent <LiftController> ());
        }
        else
        {
//			Debug.Log ("Attach right lift.");
            lift1.to      = goto_right.gameObject;
            goto_right.to = lift1.gameObject;
            eqlist.Add(goto_right.gameObject.GetComponent <LiftController> ());
        }

        return;
    }
Beispiel #10
0
        public void AddTrailToDatabase()
        {
            var data = new List <Lift>()
            {
                new Lift("a", 125, 75, "9am-5pm", true),
                new Lift("a", 155, 55, "9am-5pm", true)
            }.AsQueryable();


            var mockSet = new Mock <DbSet <Lift> >();

            mockSet.As <IQueryable <Lift> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Lift> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <SkiResortContext>();

            mockContext.Setup(c => c.Lifts).Returns(mockSet.Object);

            var service = new LiftController(mockContext.Object);

            data.ToList().ForEach(t => service.Add(t));
        }
Beispiel #11
0
 public DisplayLift()
 {
     liftController = new LiftController();
     InputLifts();
 }
Beispiel #12
0
 public DisplayTrail()
 {
     trailController = new TrailController();
     liftController  = new LiftController();
     InputLifts();
 }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        if (foot.OnLift == true)
        {
            isLifted   = true;
            isGrounded = true;
        }
        else
        {
            isLifted = false;
        }


        if (player == playerType.Dola)
        {
            anim.SetBool("Dola", true);
            WalkSpeed = 6f;
        }
        else
        {
            anim.SetBool("Dola", false);
            WalkSpeed = 4f;
        }

        //デバッグ用ブレークポイント
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("break");
        }

        //save
        if (Input.GetKeyDown(KeyCode.S))
        {
            SaveData.SetFloat("Y", this.transform.position.y);
            Debug.Log("Yに" + this.transform.position.y + "をセーブしました");
        }

        //メニュー用
        if (Input.GetKeyDown(KeyCode.Q))
        {
            if (player_Active)
            {
                menu_Active   = true;
                player_Active = false;

                anim.SetBool("Walk", false);

                //if (instanceMenuUI == null) {

                //instanceMenuUI = GameObject.Instantiate (MenuUI) as GameObject;
                MenuUI.gameObject.SetActive(true);

                //}
                Debug.Log("MENUOPEN");
            }
            else
            {
                player_Active                 = true;
                menu_Active                   = false;
                MapFlag                       = false;
                ArrowFlag                     = true;
                currentMENUpointa             = 1;
                firstMenuPointa.localPosition = new Vector3(0.92f, 80, 0);
                //MENUPointa.transform.position = RectTransformUtility.WorldToScreenPoint (Camera.main, new Vector3 (0, 0, 0));
                for (int i = 0; i < 20; i++)
                {
                    if (Map1flag[i] == true)
                    {
                        Destroy(MAP1[i]);

                        //MAPDELETE
                    }
                }
                MenuUI.gameObject.SetActive(false);
                //Destroy (instanceMenuUI);
                Debug.Log("MENUCLOSE");
            }
        }

        //playerがアクティブであれば操作可能(MENUの際off)
        if (player_Active)
        {
            //着地判定
            if (isGrounded == false)
            {
                isGrounded = Physics2D.Linecast(
                    transform.position + transform.up * 0.02f,
                    transform.position - transform.up * 0.02f,
                    groundLayer);
            }

            //jumpflag:一定時間経過&&地面と接地

            if (now >= 0.5f)
            {
                now      = 0;
                jumpflag = true;
                Debug.Log("jumpflag_ON");
            }

            if (jumpflag == false)
            {
                now += Time.deltaTime;
            }

            if (Input.GetKeyDown("space") && player == playerType.Dola)
            {
                if (jumpflag)
                {
                    if (isGrounded)
                    {
                        if (player == playerType.Ed)
                        {
                            jumpPower = 250;
                        }
                        else
                        {
                            jumpPower = 350;
                        }
                        jumpflag   = false;
                        isGrounded = false;
                        rigidbody2D.AddForce(Vector2.up * jumpPower);
                        Debug.Log("jumpflag_OFF");
                    }
                }
            }

            //左キー: -1、右キー: 1
            float x = Input.GetAxisRaw("Horizontal");
            float y = Input.GetAxisRaw("Vertical");

            //左か右を入力したら
            if (x != 0)
            {
                Ray2D        rayToFoot = new Ray2D(new Vector2(transform.position.x, transform.position.y + 0.5f), new Vector2(x * 2, -1.5f));
                RaycastHit2D hitToFoot = Physics2D.Raycast((Vector2)rayToFoot.origin, (Vector2)rayToFoot.direction, RayRangeToFoot, mask);

                Debug.DrawRay(rayToFoot.origin, rayToFoot.direction * RayRangeToFoot, Color.blue, 0.1f, false);

                if (hitToFoot.collider != null || player == playerType.Dola)
                {
                    //入力方向へ移動
                    if (Input.GetKey(KeyCode.LeftShift))                       //ダッシュ
                    {
                        if (isLifted)
                        {
                            LiftController LC = GObj.GetComponent <LiftController> ();
                            TotalSpeed           = x * DashSpeed + LC.rigidbody2D.velocity.x;
                            rigidbody2D.velocity = new Vector2(TotalSpeed, rigidbody2D.velocity.y);
                        }
                        else if (isHashigo)
                        {
                            if (y != 0)
                            {
                                rigidbody2D.velocity = new Vector2(x * WalkSpeed, y * HashigoSpeed);
                            }
                        }
                        else
                        {
                            rigidbody2D.velocity = new Vector2(x * DashSpeed, rigidbody2D.velocity.y);
                        }
                        Vector2 temp = transform.localScale;
                        temp.x = x * (-5);
                        transform.localScale = temp;
                        anim.SetBool("Walk", true);
                    }
                    else
                    {
                        if (isLifted)
                        {
                            LiftController LC = foot.Lift.GetComponent <LiftController> ();
                            rigidbody2D.velocity = new Vector2(x * WalkSpeed + LC.rigidbody2D.velocity.x, LC.rigidbody2D.velocity.y);
                        }
                        else if (isHashigo)
                        {
                            rigidbody2D.velocity = new Vector2(x * WalkSpeed, y * HashigoSpeed);
                        }
                        else
                        {
                            rigidbody2D.velocity = new Vector2(x * WalkSpeed, rigidbody2D.velocity.y);
                        }

                        Vector2 temp = transform.localScale;
                        temp.x = x * (-5);
                        transform.localScale = temp;
                        anim.SetBool("Walk", true);
                    }
                }
            }
            else
            {
                if (isLifted)
                {
                    LiftController LC = foot.Lift.GetComponent <LiftController> ();
                    rigidbody2D.velocity = new Vector2(0 + LC.rigidbody2D.velocity.x, LC.rigidbody2D.velocity.y);
                }
                else if (isHashigo)
                {
                    rigidbody2D.velocity = new Vector2(x * WalkSpeed, y * HashigoSpeed);
                }
                else
                {
                    rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
                }
                anim.SetBool("Walk", false);
            }
        }
        else
        {
            //MENU画面操作
            if (menu_Active)
            {
                if (moveflag == false)
                {
                    waittime += Time.deltaTime;
                }

                if (waittime > 1.5)
                {
                    moveflag = true;
                    waittime = 0;
                }

                if (ArrowFlag)
                {
                    if (Input.GetKeyDown(KeyCode.DownArrow))
                    {
                        if (currentMENUpointa != 4)
                        {
                            if (moveflag)
                            {
                                currentMENUpointa += 1;
                                Debug.Log(currentMENUpointa);
                                iTween.MoveBy(MENUPointa.gameObject, iTween.Hash("y", -50));
                                moveflag = false;
                            }
                        }
                    }

                    if (Input.GetKeyDown(KeyCode.UpArrow))
                    {
                        if (currentMENUpointa != 1)
                        {
                            if (moveflag)
                            {
                                currentMENUpointa -= 1;
                                Debug.Log(currentMENUpointa);
                                iTween.MoveBy(MENUPointa.gameObject, iTween.Hash("y", 50f));
                                moveflag = false;
                            }
                        }
                    }
                }

                if (MapFlag)
                {
                    float x = Input.GetAxisRaw("Horizontal");
                    if (x != 0)
                    {
                        for (int i = 0; i < 20; i++)
                        {
                            if (Map1flag [i])
                            {
                                iTween.MoveBy(MAP1 [i], iTween.Hash("x", x * (-65f), "Time", 0.2f));
                            }
                        }
                    }
                }

                if (currentMENUpointa == 1)
                {
                    if (Input.GetKeyDown(KeyCode.Z))
                    {
                        if (MapFlag == false)
                        {
                            ArrowFlag = false;
                            Debug.Log("MAP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                            MapFlag = true;

                            //MAPShow

                            for (int i = 0; i < 20; i++)
                            {
                                if (Map1flag[i] == true)
                                {
                                    var rote = Quaternion.AngleAxis(0, new Vector3(0, 0, 0));
                                    MAP1[i] = Instantiate(MAP1Pictures[i], Map1_position [i], rote) as GameObject;
                                    //MAP1[i].transform.position = RectTransformUtility.WorldToScreenPoint (Camera.main, new Vector3 (0, 0, 0));
                                    MAP1[i].transform.SetParent(canvas.transform, false);
                                    MAP1 [i].transform.SetSiblingIndex(CanvasFrontObject.transform.GetSiblingIndex() + 1);
                                }
                            }
                        }
                        else
                        {
                            ArrowFlag = true;



                            Debug.Log("MAPBREAK!!!!!!!!!!!!!!!!!!!!!!!!!!");
                            MapFlag = false;

                            for (int i = 0; i < 20; i++)
                            {
                                if (Map1flag[i] == true)
                                {
                                    Destroy(MAP1[i]);

                                    //MAPDELETE
                                }
                            }
                        }
                    }
                }
                else if (currentMENUpointa == 2)
                {
                }
                else if (currentMENUpointa == 3)
                {
                }
                else if (currentMENUpointa == 4)
                {
                }
            }
        }
    }
Beispiel #14
0
 private void Awake()
 {
     _liftController = FindObjectOfType <LiftController>();
 }
 void Start()
 {
     parentLift = transform.parent.gameObject.GetComponent <LiftController>();
 }
Beispiel #16
0
    /*
     * 在Awake的时候会帮助子对象设置脚本
     * 子对象有三个,
     */
    void Awake()
    {
        var script = get_parent_script();

        HashSet <LiftController> equal_lists          = new HashSet <LiftController> ();
        HashSet <LiftController> reversed_equal_lists = new HashSet <LiftController> ();        // 反向的eqlist

//		Debug.Log ("Create cross channel in " + script.gameObject);
        foreach (Transform myTrans in transform)
        {
            switch (myTrans.name)
            {
            case "MidLift":
            case "Lift":
                mid = myTrans.GetComponent <LiftController> ();
                mid.initCrossChannel();
                mid.initStair();
                reversed_equal_lists.Add(mid);
                break;

            case "UpLift":
                up = myTrans.GetComponent <LiftController> ();
                up.initCrossChannel();
                up.initElescator(true);
                reversed_equal_lists.Add(up);
                break;

            case "Lift (2)":
                up = myTrans.GetComponent <LiftController> ();
                up.initCrossChannel();
                up.initElescator(false);
                reversed_equal_lists.Add(up);
                break;

            case "DownLift":
                down = myTrans.GetComponent <LiftController> ();
                down.initCrossChannel();
                down.initElescator(false);
                reversed_equal_lists.Add(down);
                break;

            case "Lift (1)":
                down = myTrans.GetComponent <LiftController> ();
                down.initCrossChannel();
                down.initElescator(true);
                reversed_equal_lists.Add(down);
                break;

            default:
                break;
            }
        }



//		Debug.Log ("My mid is " + mid + " up is " + up);
        foreach (Transform childTrans in to)
        {
            switch (childTrans.name)
            {
            case "SquareStairMid":
                get_aim(mid, childTrans.gameObject, equal_lists);
                break;

            case "SquareStairUp":
                get_aim(up, childTrans.gameObject, equal_lists);
                break;

            case "SquareStairDown":
                get_aim(down, childTrans.gameObject, equal_lists);
                break;

            default:
                break;
            }
        }

        /*
         *  正向反向填充eqlist.
         */
        foreach (LiftController lc in reversed_equal_lists)
        {
            lc.un_allowed_lifts = equal_lists;
        }
        foreach (LiftController lc in equal_lists)
        {
            lc.un_allowed_lifts = reversed_equal_lists;
        }
        return;
    }
Beispiel #17
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "switch" && PC.player == PlayerControler.playerType.Ed)
     {
         CollisionFlag = true;
         SwitchFlag    = true;
         obj           = other.gameObject;
     }
     //Gareki
     if (other.tag == "switch_Gareki" && PC.player == PlayerControler.playerType.Dola)
     {
         CollisionFlag     = true;
         Switch_GarekiFlag = true;
         obj = other.gameObject;
     }
     if (other.tag == "Bridge" && PC.player == PlayerControler.playerType.Dola)
     {
         BridgeController Bridge = other.gameObject.GetComponent <BridgeController>();
         if (Bridge.BridgeActionFlag == false)
         {
             CollisionFlag = true;
             BridgeFlag    = true;
             obj           = other.gameObject;
         }
     }
     if (other.tag == "rock" && PC.player == PlayerControler.playerType.Dola)
     {
         CollisionFlag = true;
         RockFlag      = true;
         obj           = other.gameObject;
     }
     if (other.gameObject.name == "PlayerChange")
     {
         CollisionFlag = true;
         PCFlag        = true;
     }
     if (other.gameObject.name == "Lift")
     {
         LiftController LC = other.GetComponent <LiftController>();
         if (LC.lifttype == LiftController.LiftType.Pressure)
         {
             plessureFlag = true;
             Debug.Log("plessureON");
         }
     }
     if (other.gameObject.name == "waterController" && PC.player == PlayerControler.playerType.Ed)
     {
         CollisionFlag = true;
         waterFlag     = true;
     }
     if (other.gameObject.name == "key" && PC.player == PlayerControler.playerType.Ed)
     {
         CollisionFlag = true;
         KC            = other.GetComponent <KeyContoller>();
         keyFlag       = true;
     }
     if (other.gameObject.tag == "door")
     {
         CollisionFlag = true;
         doorFlag      = true;
         obj           = other.gameObject;
     }
 }