Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //roll up
        if ((Input.GetKey(KeyCode.UpArrow) || MoveHandle.getDirection() == "up") && (GameObject.Find("Door").transform.position.y < DoorScript.max))
        {
            transform.Rotate(Vector3.left * Time.deltaTime * 50, Space.World);
        }

        //roll down
        if ((Input.GetKey(KeyCode.DownArrow) || MoveHandle.getDirection() == "down") && (GameObject.Find("Door").transform.position.y > DoorScript.min))
        {
            transform.Rotate(Vector3.right * Time.deltaTime * 50, Space.World);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (SettingsScript.vr)
        {
            //garage sound
            if ((MoveHandle.getAction() == "onmove" && !isPlaying) && SettingsScript.audioOn)
            {
                audio.Play();
                isPlaying = true;
            }
            if (MoveHandle.getAction() == "halt" && isPlaying)
            {
                audio.Pause();
                isPlaying = false;
            }

            //update door speed realtime
            doorSpeed = float.Parse(SettingsScript.doorSpeedGUI);
        }

        //roll up
//		if((Input.GetKey(KeyCode.UpArrow) || MoveHandle.getDirection ()== "up") &&(transform.position.y < max) )

        if (SettingsScript.training || SettingsScript.online)
        {
            if ((MoveHandle.getAction() == "onmove") && (transform.position.y < max))
            {
                transform.Translate(Vector3.up * Time.deltaTime * doorSpeed, Space.World);
                doorOpen = false;
                //	Debug.Log(Vector3.up.y * Time.deltaTime);
            }
//			else if((MoveHandle.getAction ()== "halt") &&(transform.position.y < max) )
//			{
//			transform.position= new Vector3 (transform.position.x, transform.position.y, transform.position.z);
//				doorOpen = true;
//				audio.Stop();
//			}
            else if ((MoveHandle.getAction() == "onmove") && (transform.position.y >= max))
            {
                transform.position = new Vector3(transform.position.x, max, transform.position.z);
                doorOpen           = true;
                audio.Stop();
            }
//		else if((!SettingsScript.lbtn && !SettingsScript.rbtn) && timeout)
            else if (timeout)
            {
                timeout            = false;
                transform.position = new Vector3(transform.position.x, doorInit, transform.position.z);
                //	animation.Play();
                doorOpen             = false;
                MoveHandle.lefthand  = false;
                MoveHandle.righthand = false;
                MoveHandle.rot0      = 0;
                MoveHandle.rot1      = 0;
            }
            else
            {
                transform.Translate(Vector3.zero, Space.World);
            }
        }

        if (SettingsScript.freemode)
        {
            if ((MoveHandle.getRotation() == "fwd") && (transform.position.y < max))
            {
                transform.Translate(Vector3.up * Time.deltaTime * 3, Space.World);
                doorOpen = false;
                //	Debug.Log(Vector3.up.y * Time.deltaTime);
            }
            else if ((MoveHandle.getRotation() == "bwd") && (transform.position.y >= max))
            {
                transform.position = new Vector3(transform.position.x, max, transform.position.z);
                doorOpen           = true;
                audio.Stop();
            }
            else if (timeout)
            {
                timeout            = false;
                transform.position = new Vector3(transform.position.x, doorInit, transform.position.z);
                //	animation.Play();
                doorOpen             = false;
                MoveHandle.lefthand  = false;
                MoveHandle.righthand = false;
                MoveHandle.rot0      = 0;
                MoveHandle.rot1      = 0;
            }
            else
            {
                transform.Translate(Vector3.zero, Space.World);
            }
        }

        //roll down
//		if((Input.GetKey(KeyCode.DownArrow) || MoveHandle.getDirection ()== "down") && (transform.position.y > min))
//		{
//			transform.Translate(Vector3.down * Time.deltaTime, Space.World);
//		//	Debug.Log(Vector3.down.y * Time.deltaTime);
//		}
//		else if((Input.GetKey(KeyCode.DownArrow) || MoveHandle.getDirection ()== "down") && (transform.position.y <= min) )
//		{
//			transform.position= new Vector3 (transform.position.x, min, transform.position.z);
//		}


        //	Debug.Log ("current: "+ transform.position.y +" , max: "+ max);

        if (transform.position.y >= max)
        {
            //close door after 2 seconds
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                timeout = true;
                timer   = float.Parse(SettingsScript.timerTimeGUI);

                Scoring.score = 1 + Scoring.score;
            }
        }

        //close door
        if (Input.GetKey(KeyCode.X))
        {
            timeout            = true;
            transform.position = new Vector3(transform.position.x, doorInit, transform.position.z);
            //	animation.Play();
            doorOpen             = false;
            MoveHandle.lefthand  = false;
            MoveHandle.righthand = false;
            MoveHandle.rot0      = 0;
            MoveHandle.rot1      = 0;
        }
    }
Exemple #3
0
        protected int MakeTry(int center_col, int changeTimes, BoxShape bshape)
        {
            tempOpr = new List<Key>();
            int i, j, k, t;
            Key tKey;
            int ty = col / 2, tx = 2;
            Box box = BoxFactory.GetBoxFromId((int)bshape, aiFrame);
            for (i = 0; i < 4; i++)
            {
                box.Entity[i].pos.x += tx;
                box.Entity[i].pos.y += ty;
            }
            for (i = 0; i < changeTimes; i++)
            {
                box.Change();
                tempOpr.Add(Key.Up);
            }
            MoveHandle moveWay;
            if (center_col < col / 2)
            {
                k = -1;
                tKey = Key.Left;
                moveWay = new MoveHandle(box.MoveLeft);
            }
            else
            {
                k = 1;
                tKey = Key.Right;
                moveWay = new MoveHandle(box.MoveRight);
            }

            for (; ty != center_col; )
            {
                ty += k;
                bool b = moveWay();
                if (!b) return -1;
                tempOpr.Add(tKey);
            }
            box.FastFall();
            tempOpr.Add(Key.Down);
            //当方块掉落完成后绘制地图
            for (i = 0; i < row; i++)
                for (j = 0; j < col; j++)
                {
                    t = (int)(aiFrame.container.map[i, j].Value);
                    if (t > 0 && t < 9 && !aiFrame.activeBox.UnitInBox(i, j))
                        map[i, j] = 1;
                    else
                        map[i, j] = 0;
                }
            for (i = 0; i < 4; i++)
            {
                tx = box.Entity[i].pos.x;
                ty = box.Entity[i].pos.y;
                map[tx, ty] = 1;
            }

            ProcessMap();
            int rtn = integrator.CalculateScore();

            return rtn;
        }