Example #1
0
    public void MergeHeads(TileLogic tile)
    {
        pathTiles.Add(tile);
        tile.IsChecked = true;
        coordinates    = tile;

        ROTATION rot = CountRotationHead();
        int      mat = ChooseMaterial();

        //head
        coordinates.gameObject.transform.rotation = Quaternion.Euler(RotationFromROTATION(rot));
        //rest
        if (pathTiles.Count >= 2)
        {
            pathTiles[pathTiles.Count - 2].GetComponent <SpriteRenderer>().sprite = box.sprites[mat];
            if (mat == 2)
            {
                rot = CountRotationSecond();
            }
            pathTiles[pathTiles.Count - 2].gameObject.transform.rotation = Quaternion.Euler(RotationFromROTATION(rot));
        }


        GameManager.Instance.CheckIfAllClicked();
        pathTiles[0].GetComponent <SpriteRenderer>().sprite = box.sprites[0];

        transform.position = pathTiles[0].gameObject.transform.position;
        coordinates        = pathTiles[0];
        pathTiles.RemoveAt(pathTiles.Count - 1);
    }
Example #2
0
    void initVars()
    {
        rotating = ROTATION.NONE;
        view     = VIEW.FRONT;

        platformPos    = new Vector3[platforms.Length];
        oldPlatformPos = new Vector3[platforms.Length];
        newPlatformPos = new Vector3[platforms.Length];
        int i = 0;

        foreach (GameObject platform in platforms)
        {
            platformPos[i] = platform.transform.position;
            platform.GetComponent <PlatformID>().ID = i;
            ++i;
        }

        modPos    = new Vector3[mods.Length];
        oldModPos = new Vector3[mods.Length];
        newModPos = new Vector3[mods.Length];
        i         = 0;
        foreach (GameObject mod in mods)
        {
            modPos[i] = mod.transform.position;
            ++i;
        }
    }
    // private void Start()
    // {
    //     coordinates.IsChecked = true;
    //     coordinates.GetComponent<Renderer>().sharedMaterial = materials[1];
    // }

    // private void Update()
    // {

    // }

    public void Move(TailsTileLogic tile)
    {
        pathTiles.Add(tile);
        tile.IsChecked = true;
        coordinates    = tile;
        gameObject.transform.position = tile.transform.position;
        ROTATION rot = CountRotationHead();
        int      mat = ChooseMaterial();

        //head
        coordinates.GetComponent <Renderer>().sharedMaterial = materials[1];
        coordinates.gameObject.transform.rotation            = Quaternion.Euler(RotationFromROTATION(rot));

        //rest
        if (pathTiles.Count >= 2)
        {
            pathTiles[pathTiles.Count - 2].GetComponent <Renderer>().sharedMaterial = materials[mat];
            if (mat == 2)
            {
                rot = CountRotationSecond();
            }
            pathTiles[pathTiles.Count - 2].gameObject.transform.rotation = Quaternion.Euler(RotationFromROTATION(rot));
        }
        box.SubMoves();

        TailsGameManager.Instance.CheckIfAllClicked();
    }
Example #4
0
 /// <summary>
 /// Rotate the turtle left or right
 /// </summary>
 /// <param name="rotate">choice of left or right</param>
 /// <param name="angle">angle to rotate</param>
 void rotate(ROTATION rotate, double angle)
 {
     if (rotate == ROTATION.RIGHT)
     {
         tess.Right(angle);
     }
     else
     {
         tess.Left(angle);
     }
 }
    /// <summary>
    /// Derived code to be executed in the superclass (GeneralObject) Start() method
    /// </summary>
    override public void DerivedStart()
    {
        //randomise the scale of the asteroid
        gameObject.transform.localScale *= 1f + Random.Range(-0.5f, 1.5f);

        //generate starting rotation of asteroid
        gameObject.transform.rotation = new Quaternion(Random.Range(-180, 180), Random.Range(-180, 180), Random.Range(-180, 180), Random.Range(-180, 180));

        //randomise rotation direction
        OrbitRotation = (ROTATION)(Random.Range(0, 2));

        //randomise whether the asteroid is chasing
        int rand = Random.Range(1, 6);

        switch (rand)
        {
        case 1:
            Chasing = false;
            break;

        case 2:
            Chasing = true;
            break;

        case 3:
            Chasing = false;
            break;

        case 4:
            Chasing = true;
            break;

        case 5:
            Chasing = false;
            break;
        }

        //if applicable, give asteroid a target
        if (Chasing)
        {
            List <GeneralObject> PopulationCentres = new List <GeneralObject>();
            GeneralObject[]      Objects           = (GeneralObject[])FindObjectsOfType(typeof(GeneralObject));

            for (int i = 0; i < Objects.Length; i++)
            {
                if (System.Convert.ToInt64(Objects[i].Population) > 0)
                {
                    PopulationCentres.Add(Objects[i]);
                }
            }

            Target = PopulationCentres[Random.Range(0, PopulationCentres.Count)];
        }
    }
    public void GoBack()
    {
        pathTiles[pathTiles.Count - 1].IsChecked = false;
        pathTiles[pathTiles.Count - 1].GetComponent <Renderer>().sharedMaterial = materials[3];
        pathTiles.RemoveAt(pathTiles.Count - 1);
        coordinates = pathTiles[pathTiles.Count - 1];
        gameObject.transform.position = pathTiles[pathTiles.Count - 1].transform.position;
        ROTATION rot = CountRotationHead();

        coordinates.GetComponent <Renderer>().sharedMaterial = materials[1];
        coordinates.gameObject.transform.rotation            = Quaternion.Euler(RotationFromROTATION(rot));
        box.AddMoves();
    }
Example #7
0
        public void InitGizmo(int id, ROTATION rotation)
        {
            _rotation = rotation;
            _id       = id;

            _forwardGizmo.gameObject.SetActive(true);
            _upGizmo.gameObject.SetActive(true);
            _forwardLine.gameObject.SetActive(true);

            _forwardGizmo.onGizmoMoved.AddListener(x => GizmoMoved());
            _upGizmo.onGizmoMoved.AddListener(x => GizmoMoved());

            UpdateGizmo(id);
        }
Example #8
0
        public static ModelInput RecreateRealModel(ModelInput origin)
        {
            if (origin.type == ModelData.DURATION.TYPE)
            {
                return(DURATION.CopyValues(origin));
            }
            if (origin.type == ModelData.APPEAR.TYPE)
            {
                return(APPEAR.CopyValues(origin));
            }
            if (origin.type == ModelData.SIZE.TYPE)
            {
                return(SIZE.CopyValues(origin));
            }
            if (origin.type == ModelData.SPEED.TYPE)
            {
                return(SPEED.CopyValues(origin));
            }
            if (origin.type == ModelData.POSITION.TYPE)
            {
                return(POSITION.CopyValues(origin));
            }
            if (origin.type == ModelData.ROTATION.TYPE)
            {
                return(ROTATION.CopyValues(origin));
            }
            if (origin.type == ModelData.EVENT.TYPE)
            {
                return(EVENT.CopyValues(origin));
            }
            if (origin.type == ModelData.COUNT.TYPE)
            {
                return(COUNT.CopyValues(origin));
            }
            if (origin.type == ModelData.SHAPE.TYPE)
            {
                return(SHAPE.CopyValues(origin));
            }
            if (origin.type == ModelData.PROJECTILE.TYPE)
            {
                return(PROJECTILE.CopyValues(origin));
            }

            return(null);
        }
Example #9
0
        public void Rotate(ROTATION r)
        {
            PuzzleNode[, ,] newArr = new PuzzleNode[size, size, size];
            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    for (int z = 0; z < size; z++)
                    {
                        switch (r)
                        {
                        case (ROTATION.POSZ):
                            newArr[x, y, z] = arr[y, size - 1 - x, z];
                            break;

                        case (ROTATION.NEGZ):
                            newArr[x, y, z] = arr[size - 1 - y, x, z];
                            break;

                        case (ROTATION.POSY):
                            newArr[x, y, z] = arr[size - 1 - z, y, x];
                            break;

                        case (ROTATION.NEGY):
                            newArr[x, y, z] = arr[z, y, size - 1 - x];
                            break;

                        case (ROTATION.NEGX):
                            newArr[x, y, z] = arr[x, size - 1 - z, y];
                            break;

                        case (ROTATION.POSX):
                            newArr[x, y, z] = arr[x, z, size - 1 - y];
                            break;

                        default:
                            newArr[x, y, z] = arr[x, y, z];
                            break;
                        }
                    }
                }
            }
            arr = newArr;
        }
Example #10
0
        public static Quaternion GetRotation(ROTATION _rot)
        {
            switch (_rot)
            {
            case TileManager.ROTATION.DEFAULT:
                return(Quaternion.Euler(new Vector3(0f, 0f, 0f)));

            case TileManager.ROTATION.ROT90:
                return(Quaternion.Euler(new Vector3(0f, 0f, -90f)));

            case TileManager.ROTATION.ROT180:
                return(Quaternion.Euler(new Vector3(0f, 0f, -180f)));

            case TileManager.ROTATION.ROT270:
                return(Quaternion.Euler(new Vector3(0f, 0f, -270f)));
            }

            return(Quaternion.Euler(new Vector3(0f, 0f, 0f)));
        }
    private Vector3 RotationFromROTATION(ROTATION rott)
    {
        switch (rott)
        {
        case ROTATION.DEEGREES_0:
            return(new Vector3(0, 0, 0));

        case ROTATION.DEEGREES_90:
            return(new Vector3(0, 0, 90));

        case ROTATION.DEEGREES_180:
            return(new Vector3(0, 0, 180));

        case ROTATION.DEEGREES_270:
            return(new Vector3(0, 0, 270));

        default:
            return(new Vector3(0, 0, 0));
        }
    }
Example #12
0
        public static Quaternion GetTransform(ROTATION r, out Vector3 scale)
        {
            var b = (byte)r;
            var m = Matrix4x4.zero;
            var x = b & 3;
            var y = (b >> 2) & 3;

            scale.x = ((b >> 4) & 1) != 0 ? -1 : 1;
            scale.y = ((b >> 5) & 1) != 0 ? -1 : 1;
            scale.z = ((b >> 6) & 1) != 0 ? -1 : 1;
            m[x, 0] = scale.x;
            m[y, 1] = scale.y;
            m[Mathf.Clamp(3 - x - y, 0, 2), 2] = scale.z;
            m[3, 3] = 1;
            //Debug.Log($"{r} ({b})↓\r\n{m}");
            //Debug.Log($"lossyScale={m.lossyScale}");
            //Debug.Log($"scale={scale}");
            scale = m.lossyScale;
            return(m.rotation);
        }
        public void Rotate(String[] fileEntries, UpdateGUI update, ROTATION rotate)
        {
            for (int n = 0; n < fileEntries.Length; n++)
                {
                    try
                    {

                        Process myProcess = new Process();
                        myProcess.StartInfo.FileName = "\"" + appPath + "\\convert\"";
                        myProcess.StartInfo.Arguments = (" -rotate 90 \"" + fileEntries[n] + "\" \"" + fileEntries[n]+ "\"  ");
                        myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        myProcess.StartInfo.UseShellExecute = false;
                        myProcess.StartInfo.CreateNoWindow = true;
                        myProcess.Start();
                        myProcess.WaitForExit();
                        update(n, "");
                        Application.DoEvents();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error Rotation " + ex.Message);
                    }
                }
        }
Example #14
0
 public void performRotateLeft()
 {
     rotating = ROTATION.LEFT;
     rState   = ROTATION_STATE.TRANSFORM;
     subState = SUB_STATE.SETUP;
 }
Example #15
0
 public void performRotateRight()
 {
     rotating = ROTATION.RIGHT;
     rState   = ROTATION_STATE.TRANSFORM;
     subState = SUB_STATE.SETUP;
 }
Example #16
0
    // State machine to handle rotation sequence
    //     This sequence has 4 steps:
    //         Transform: pauses the player and moves the platforms and modifiers back to their real position in 3D
    //         Rotate: rotates the camera to the next view
    //         Project: moves the platforms and modifiers back to a 2D position relative to the new view
    //         Done: resumes the player and resets the rotating variable
    //     Each step has 3 parts (excluding Done):
    //         Setup: initialize variables, calculate new positions/rotation, etc.
    //         Perform: perform the actual animation (translation, rotation, etc)
    //         Complete: finish up step, set enum value to next step, etc.
    void rotationController()
    {
        switch (rState)
        {
        case ROTATION_STATE.TRANSFORM:
            switch (subState)
            {
            case SUB_STATE.SETUP:
                pausePlayer();
                transformPlatformsAndModifiersBackTo3D();
                t        = 0.0f;
                subState = SUB_STATE.PERFORM;
                break;

            case SUB_STATE.PERFORM:
                if (interpolatePlatformsAndModifiers())
                {
                    subState = SUB_STATE.COMPLETE;
                }
                break;

            case SUB_STATE.COMPLETE:
                rState   = ROTATION_STATE.ROTATE;
                subState = SUB_STATE.SETUP;
                break;
            }
            break;

        case ROTATION_STATE.ROTATE:
            switch (subState)
            {
            case SUB_STATE.SETUP:
                t           = 0.0f;
                oldRotation = this.transform.eulerAngles.y;
                setNewRotation();
                subState = SUB_STATE.PERFORM;
                break;

            case SUB_STATE.PERFORM:
                if (interpolateCamera())
                {
                    subState = SUB_STATE.COMPLETE;
                }
                break;

            case SUB_STATE.COMPLETE:
                setNewView();
                rState   = ROTATION_STATE.PROJECT;
                subState = SUB_STATE.SETUP;
                break;
            }
            break;

        case ROTATION_STATE.PROJECT:
            switch (subState)
            {
            case SUB_STATE.SETUP:
                t = 0.0f;
                projectPlatformsAndModifiersOnto2D();
                subState = SUB_STATE.PERFORM;
                break;

            case SUB_STATE.PERFORM:
                if (interpolatePlatformsAndModifiers())
                {
                    subState = SUB_STATE.COMPLETE;
                }
                break;

            case SUB_STATE.COMPLETE:
                rState = ROTATION_STATE.DONE;
                break;
            }
            break;

        case ROTATION_STATE.DONE:
            resumePlayer();
            rotating = ROTATION.NONE;
            break;
        }
    }
Example #17
0
    void initVars()
    {
        rotating = ROTATION.NONE;
        view = VIEW.FRONT;

        platformPos = new Vector3[platforms.Length];
        oldPlatformPos = new Vector3[platforms.Length];
        newPlatformPos = new Vector3[platforms.Length];
        int i = 0;
        foreach(GameObject platform in platforms) {
            platformPos[i] = platform.transform.position;
            platform.GetComponent<PlatformID>().ID = i;
            ++i;
        }

        modPos = new Vector3[mods.Length];
        oldModPos = new Vector3[mods.Length];
        newModPos = new Vector3[mods.Length];
        i = 0;
        foreach(GameObject mod in mods) {
            modPos[i] = mod.transform.position;
            ++i;
        }
    }
Example #18
0
 public static String[,,] Rotate(String[,,] arr, ROTATION r)
 {
     String[, ,] newArr = new String[3, 3, 3];
     for (int x = 0; x < 3; x++)
     {
         for (int y = 0; y < 3; y++)
         {
             for (int z = 0; z < 3; z++)
             {
                 switch (r)
                 {
                     case (ROTATION.POSZ):
                         newArr[x, y, z] = arr[y, 2 - x, z];
                         break;
                     case (ROTATION.NEGZ):
                         newArr[x, y, z] = arr[2 - y, x, z];
                         break;
                     case (ROTATION.POSY):
                         newArr[x, y, z] = arr[2-z,y,x];
                         break;
                     case (ROTATION.NEGY):
                         newArr[x, y, z] = arr[z,y,2-x];
                         break;
                     case (ROTATION.NEGX):
                         newArr[x, y, z] = arr[x,2-z,y];
                         break;
                     case (ROTATION.POSX):
                         newArr[x, y, z] = arr[x,z,2-y];
                         break;
                     default:
                         newArr[x, y, z] = arr[x,y,z];
                         break;
                 }
             }
         }
     }
     return newArr;
 }
Example #19
0
 // State machine to handle rotation sequence
 //     This sequence has 4 steps:
 //         Transform: pauses the player and moves the platforms and modifiers back to their real position in 3D
 //         Rotate: rotates the camera to the next view
 //         Project: moves the platforms and modifiers back to a 2D position relative to the new view
 //         Done: resumes the player and resets the rotating variable
 //     Each step has 3 parts (excluding Done):
 //         Setup: initialize variables, calculate new positions/rotation, etc.
 //         Perform: perform the actual animation (translation, rotation, etc)
 //         Complete: finish up step, set enum value to next step, etc.
 void rotationController()
 {
     switch(rState) {
         case ROTATION_STATE.TRANSFORM:
             switch(subState) {
                 case SUB_STATE.SETUP:
                     pausePlayer();
                     transformPlatformsAndModifiersBackTo3D();
                     t = 0.0f;
                     subState = SUB_STATE.PERFORM;
                     break;
                 case SUB_STATE.PERFORM:
                     if( interpolatePlatformsAndModifiers() ) {
                         subState = SUB_STATE.COMPLETE;
                     }
                     break;
                 case SUB_STATE.COMPLETE:
                     rState = ROTATION_STATE.ROTATE;
                     subState = SUB_STATE.SETUP;
                     break;
             }
             break;
         case ROTATION_STATE.ROTATE:
             switch(subState) {
                 case SUB_STATE.SETUP:
                     t = 0.0f;
                     oldRotation = this.transform.eulerAngles.y;
                     setNewRotation();
                     subState = SUB_STATE.PERFORM;
                     break;
                 case SUB_STATE.PERFORM:
                     if( interpolateCamera() ) {
                         subState = SUB_STATE.COMPLETE;
                     }
                     break;
                 case SUB_STATE.COMPLETE:
                     setNewView();
                     rState = ROTATION_STATE.PROJECT;
                     subState = SUB_STATE.SETUP;
                     break;
             }
             break;
         case ROTATION_STATE.PROJECT:
             switch(subState) {
                 case SUB_STATE.SETUP:
                     t = 0.0f;
                     projectPlatformsAndModifiersOnto2D();
                     subState = SUB_STATE.PERFORM;
                     break;
                 case SUB_STATE.PERFORM:
                     if( interpolatePlatformsAndModifiers() ) {
                         subState = SUB_STATE.COMPLETE;
                     }
                     break;
                 case SUB_STATE.COMPLETE:
                     rState = ROTATION_STATE.DONE;
                     break;
             }
             break;
         case ROTATION_STATE.DONE:
             resumePlayer();
             rotating = ROTATION.NONE;
             break;
     }
 }
Example #20
0
 public void performRotateRight()
 {
     rotating = ROTATION.RIGHT;
     rState = ROTATION_STATE.TRANSFORM;
     subState = SUB_STATE.SETUP;
 }
Example #21
0
 public void performRotateLeft()
 {
     rotating = ROTATION.LEFT;
     rState = ROTATION_STATE.TRANSFORM;
     subState = SUB_STATE.SETUP;
 }