Inheritance: MonoBehaviour
示例#1
0
 private void Start()
 {
     Data       = new CubeData(10, GetTransform());
     MoveSystem = new CubeMove(Data);
     EventsManager.OnPlancePressed += AddPointToPathWay;
     _moveSpeedSlider.onValueChanged.AddListener(ChangeSpeedOn);
 }
            private LinkedHashMap <string, PuzzleState> GetSuccessorsWithinSlice(int maxSlice, bool includeRedundant)
            {
                var successors = new LinkedHashMap <string, PuzzleState>();

                for (var innerSlice = 0; innerSlice <= maxSlice; innerSlice++)
                {
                    foreach (Face face in Enum.GetValues(typeof(Face)))
                    {
                        var halfOfEvenCube = _puzzle.Size % 2 == 0 && innerSlice == _puzzle.Size / 2 - 1;
                        if (!includeRedundant && (int)face >= 3 && halfOfEvenCube)
                        {
                            continue;
                        }
                        const int outerSlice = 0;
                        for (var dir = 1; dir <= 3; dir++)
                        {
                            var move    = new CubeMove(face, dir, innerSlice, outerSlice, _puzzle);
                            var moveStr = move.ToString();
                            if (moveStr == null)
                            {
                                continue;
                            }

                            var imageCopy = CloneImage(_image);
                            for (var slice = outerSlice; slice <= innerSlice; slice++)
                            {
                                Slice(face, slice, dir, imageCopy);
                            }
                            successors[moveStr] = new CubeState(imageCopy, _puzzle);
                        }
                    }
                }

                return(successors);
            }
示例#3
0
    public System.Action onMoveCount;//이동횟수 알려줌

    void Awake()
    {
        this.cubeMove = GetComponent <CubeMove>();
        this.panelGoal.onGameClear = () =>
        {
            StartCoroutine(this.GameClear());
        };
    }
示例#4
0
 private void ReorganiseLevel()
 {
     Spawner.EmptySpawner();
     CubeMove.DestroyAll();
     Target.EmptyTarget();
     Turnstile.ResetSense();
     player.SetModeNormal();
     targetCounter = 0;
 }
示例#5
0
        virtual protected void OnTriggerEnter(Collider other)
        {
            if (!other.CompareTag(tagCollid))
            {
                return;
            }

            firstTime = true;
            target    = other.GetComponent <CubeMove>();
        }
        void Awake()
        {
            Debug.Log("======CreateCube Awake");
            GameObject cube     = GameObject.CreatePrimitive(PrimitiveType.Cube);
            CubeMove   cubeMove = cube.GetComponent <CubeMove>();

            if (cubeMove == null)
            {
                cubeMove = cube.AddComponent <CubeMove>();
            }
        }
示例#7
0
 private void RubiksCubeMoveMade(object sender, CubeMove move)
 {
     if (rubiksCube.Solved)
     {
         lblStatus.Text      = "Cube Solved";
         lblStatus.ForeColor = Color.Green;
     }
     else
     {
         lblStatus.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
         lblStatus.Text      = "Last Move: " + move;
     }
 }
示例#8
0
    void Update()
    {
        GameObject obj   = GameObject.FindGameObjectWithTag("Player");
        CubeMove   start = obj.GetComponent <CubeMove> ();

        if (start.startFlag == 1)
        {
            isStart = true;
        }

        if (isStart)
        {
            this.m_transform.Translate(new Vector3(move_x, move_y, 0));
        }
    }
示例#9
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Rbk = Instantiate(RBK);
         Rbk.transform.position = Vector3.zero;
         Rbk.AddComponent <CubeMove>();
     }
     if (Input.GetMouseButtonDown(1))
     {
         CubeMove cm = Rbk.GetComponent <CubeMove>();
         Destroy(cm);
         //Destroy(Rbk,2);
     }
 }
示例#10
0
        public VirtualCube(ThreeImageConfiguration configs)
        {
            ResetCenters();
            ResetCorners();
            ResetEdges();

            if (configs.Moves != null)
            {
                CubeMove.ApplAlg(this, configs.Moves);
            }

            if (configs.Case != null)
            {
                CubeMove.ApplAlg(this, configs.Case, true);
            }

            configs.Cube = this;
        }
示例#11
0
    private IEnumerator ReactSphere(GameObject bomb)
    {
        yield return(new WaitUntil(() => CreatingLevel.timer > 1.5f));

        musicSource.clip = sphereClip;
        musicSource.Play();
        RaycastHit[] hits = Physics.SphereCastAll(bomb.transform.position, 1.1f, new Vector3(0, -1f, 0), 10f);
        foreach (RaycastHit q in hits)
        {
            GameObject hitObject = q.transform.gameObject;
            CubeMove   target    = hitObject.GetComponent <CubeMove> ();
            if (target != null)
            {
                if ((int)target.kind == 2)
                {
                    spheres.Add(Instantiate(sphere, new Vector3(Mathf.Round(target.transform.position.x), target.transform.position.y + 1f, Mathf.Round(target.transform.position.z)), Quaternion.identity));
                    target.ReactToHit(true);
                }
                else if ((int)target.kind == 3)
                {
                    Ray        ray = new Ray(new Vector3(target.transform.position.x, 0.99f, target.transform.position.z), new Vector3(0, -1f, 0));
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        hitObject = hit.transform.gameObject;
                        PlatformLength platform = hitObject.GetComponent <PlatformLength> ();
                        if (platform != null)
                        {
                            platform.Decrease();
                        }
                    }
                    target.ReactToHit(false);
                }
                else
                {
                    target.ReactToHit(true);
                }
            }
        }
        spheres.RemoveAt(0);
        Destroy(bomb);
    }
示例#12
0
    private IEnumerator ReactPlane(GameObject plane)
    {
        yield return(new WaitUntil(() => CreatingLevel.timer > 1.5f));

        musicSource.clip = planeCrashClip;
        musicSource.Play();
        Ray        ray = new Ray(plane.transform.position, new Vector3(0, 1f, 0));
        RaycastHit hit;

        Destroy(plane);
        if (Physics.Raycast(ray, out hit))
        {
            GameObject hitObject = hit.transform.gameObject;
            CubeMove   target    = hitObject.GetComponent <CubeMove> ();
            if (target != null)
            {
                if ((int)target.kind == 2)                      //for green blocks
                {
                    spheres.Add(Instantiate(sphere, new Vector3(Mathf.Round(target.transform.position.x), target.transform.position.y + 1f, Mathf.Round(target.transform.position.z)), Quaternion.identity));
                    target.ReactToHit(true);
                }
                else if ((int)target.kind == 3)                      // for black blocks
                {
                    ray = new Ray(new Vector3(target.transform.position.x, 0.99f, target.transform.position.z), new Vector3(0, -1f, 0));
                    if (Physics.Raycast(ray, out hit))
                    {
                        hitObject = hit.transform.gameObject;
                        PlatformLength platform = hitObject.GetComponent <PlatformLength> ();
                        if (platform != null)
                        {
                            platform.Decrease();
                        }
                    }
                    target.ReactToHit(false);
                }
                else
                {
                    target.ReactToHit(true);
                }
            }
        }
    }
示例#13
0
        protected CubeMove[][] GetRandomOrientationMoves(int thickness)
        {
            var randomUFaceMoves = new[]
            {
                null,
                new CubeMove(Face.R, 1, thickness, this),
                new CubeMove(Face.R, 2, thickness, this),
                new CubeMove(Face.R, 3, thickness, this),
                new CubeMove(Face.F, 1, thickness, this),
                new CubeMove(Face.F, 3, thickness, this)
            };
            var randomFFaceMoves = new[]
            {
                null,
                new CubeMove(Face.U, 1, thickness, this),
                new CubeMove(Face.U, 2, thickness, this),
                new CubeMove(Face.U, 3, thickness, this)
            };
            var randomOrientationMoves = new CubeMove[randomUFaceMoves.Length * randomFFaceMoves.Length][];
            var i = 0;

            foreach (var randomUFaceMove in randomUFaceMoves)
            {
                foreach (var randomFFaceMove in randomFFaceMoves)
                {
                    var moves = new List <CubeMove>();
                    if (randomUFaceMove != null)
                    {
                        moves.Add(randomUFaceMove);
                    }
                    if (randomFFaceMove != null)
                    {
                        moves.Add(randomFFaceMove);
                    }
                    var movesArr = new CubeMove[moves.Count];
                    moves.CopyTo(movesArr);
                    randomOrientationMoves[i++] = movesArr;
                }
            }
            return(randomOrientationMoves);
        }
示例#14
0
 private FaceID[,] rotateFace(FaceID[,] face, CubeMove rot)
 {
     // rotate all the colours on a face and adjacent squares
     FaceID[,] newFace = new FaceID[5, 5];
     for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) // for each piece on the face
         switch(rot) {
             case CubeMove.Clockwise:
                 newFace[4 - j, i] = face[i, j]; // if clockwise rotation move all pieces around clockwise
                 break;
             case CubeMove.Double:
                 newFace[4 - i, 4 - j] = face[i, j]; // if double rotation move them around 180 degrees
                 break;
             case CubeMove.AntiClockwise: // if anti-clockwise move them around anti-clockwise
                 newFace[j, 4 - i] = face[i, j];
                 break;
         }
     return newFace;
 }
    void setCubeColor(CubeMove cm, int value)
    {
        Material mMaterial;

        if (value == 2)
        {
            cm.GetComponent <Renderer> ().material.color = Color.cyan;
            mMaterial = Resources.Load("2", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 4)
        {
            mMaterial = Resources.Load("4", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 8)
        {
            mMaterial = Resources.Load("8", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 16)
        {
            mMaterial = Resources.Load("16", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 32)
        {
            mMaterial = Resources.Load("32", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 64)
        {
            mMaterial = Resources.Load("64", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 128)
        {
            mMaterial = Resources.Load("128", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 256)
        {
            mMaterial = Resources.Load("256", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 512)
        {
            mMaterial = Resources.Load("512", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 1024)
        {
            mMaterial = Resources.Load("1024", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
        else if (value == 2048)
        {
            mMaterial = Resources.Load("2048", typeof(Material)) as Material;
            cm.GetComponent <Renderer> ().material = mMaterial;
        }
    }
 public void performMove(FaceID face, CubeMove rot)
 {
     // performing move type methods
     performMove(new Move(face, rot));
 }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        localScene = SceneManager.GetActiveScene();
        if (localScene.buildIndex == 0)
        {
            if (BeginButton == null)
            {
                BeginButton = GameObject.Find("BeginButton");
                BeginButton.GetComponent <Button>().onClick.AddListener(BeginTheGame);
            }

            if (WaitText == null)
            {
                WaitText = GameObject.Find("WaitText").GetComponent <Text>();
            }

            if (localasync == null)
            {
                return;
            }
            float targetValue = localasync.progress;
            if (localasync.progress >= 0.9f)
            {
                //值最大为0.9
                targetValue = 1.0f;
                localasync.allowSceneActivation = true;
            }


            LoadSchedule  = ((int)(targetValue * 100)).ToString() + "%";
            WaitText.text = "Waiting >>>>>" + LoadSchedule;
        }
        else if (localScene.buildIndex == 1)
        {
            if (cubeMoveCS == null)
            {
                cubeMoveCS = GameObject.Find("Cube").GetComponent <CubeMove>();
            }
            if (_leaderBoard == null)
            {
                _leaderBoard  = gameObject.GetComponent <DoLeaderBoard>();
                _rankDataList = _leaderBoard.RankJson();
            }
            if (_gameUi == null)
            {
                _gameUi = GameObject.Find("Manager").GetComponent <GameUI>();
                _gameUi.JumpButton.onClick.AddListener(cubeMoveCS.BoxJump);
                _gameUi.RunButton.onClick.AddListener(cubeMoveCS.BoxRun);
            }
            cubePosition = cubeMoveCS.CubeVector3;
            bool localgameOver = cubeMoveCS.GameOver;
            _gameUi.GameOverSetActive(localgameOver, cubePosition.x);
            _gameUi.ScoreUI(!localgameOver, cubePosition.x, totaltime);
            _gameUi.ChatRoomOver(internetboolen);
            //rank
            if (_gameUi.RankBool == _rankActive)
            {
                _rankActive = !_gameUi.RankBool;
                _gameUi.SetDataToRank(_rankDataList);
            }
        }
    }
示例#18
0
 void Start()
 {
     Egg      = GameObject.Find("Cube");
     cubeMove = Egg.GetComponent <CubeMove>();
 }
示例#19
0
 public Move(FaceID f, CubeMove t)
 {
     face = f; twist = t;
 }
示例#20
0
 private void actualMove(FaceID face, CubeMove rot)
 {
     FaceID[,] transposed = new FaceID[5, 5]; // create a temporary store for face being moved and adjacent piece colours
     for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
         FaceCoord coords = transposeFromFront(face, FaceID.Front, i, j); // pull off the colours of the face and put them into the transpose array
         transposed[i + 1, j + 1] = faceColours[(int) coords.face, coords.i, coords.j];
     }
     for(int i = 0; i < 3; i++) { // pull off the affected colours from the 4 adjacent edges
         FaceCoord coords = transposeFromFront(face, FaceID.Top, i, 2);
         transposed[i + 1, 0] = faceColours[(int) coords.face, coords.i, coords.j];
         coords = transposeFromFront(face, FaceID.Left, 2, i);
         transposed[0, i + 1] = faceColours[(int) coords.face, coords.i, coords.j];
         coords = transposeFromFront(face, FaceID.Right, 0, i);
         transposed[4, i + 1] = faceColours[(int) coords.face, coords.i, coords.j];
         coords = transposeFromFront(face, FaceID.Bottom, i, 0);
         transposed[i + 1, 4] = faceColours[(int) coords.face, coords.i, coords.j];
     }
     transposed = rotateFace(transposed, rot); // perform the actual rotation on the colours
     for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) { // place the newly rotated colours back onto the rotated face
         FaceCoord coords = transposeFromFront(face, FaceID.Front, i, j);
         faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, j + 1];
     }
     for(int i = 0; i < 3; i++) { // place the newly rotated colours back onto the adjacent faces
         FaceCoord coords = transposeFromFront(face, FaceID.Top, i, 2);
         faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, 0];
         coords = transposeFromFront(face, FaceID.Left, 2, i);
         faceColours[(int) coords.face, coords.i, coords.j] = transposed[0, i + 1];
         coords = transposeFromFront(face, FaceID.Right, 0, i);
         faceColours[(int) coords.face, coords.i, coords.j] = transposed[4, i + 1];
         coords = transposeFromFront(face, FaceID.Bottom, i, 0);
         faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, 4];
     }
 }
示例#21
0
 public void performMove(FaceID face, CubeMove rot)
 {
     // perform move stored in FaceID value and CubeMove value
     actualMove(face, rot);
 }