Example #1
0
    private void setTargetRotation(float rotation, GameInputController.ROTATION_AXIS axis)
    {
        if (activeForm)
        {
            Vector3    currentRotation = new Vector3();
            Quaternion r;
            switch (axis)
            {
            case GameInputController.ROTATION_AXIS.X:
                activeForm.RotateAround(activeForm.position, activeForm.right, rotation);
                r = activeForm.rotation;
                currentRotation = new Vector3(r.eulerAngles.x, r.eulerAngles.y, r.eulerAngles.z);
                //activeForm.RotateAround(activeForm.position, activeForm.right, -rotation);
                break;

            case GameInputController.ROTATION_AXIS.Y:
                activeForm.RotateAround(activeForm.position, activeForm.up, rotation);
                r = activeForm.rotation;
                currentRotation = new Vector3(r.eulerAngles.x, r.eulerAngles.y, r.eulerAngles.z);
                //activeForm.RotateAround(activeForm.position, activeForm.up, -rotation);
                break;

            case GameInputController.ROTATION_AXIS.Z:
                activeForm.RotateAround(activeForm.position, activeForm.forward, rotation);
                r = activeForm.rotation;
                currentRotation = new Vector3(r.eulerAngles.x, r.eulerAngles.y, r.eulerAngles.z);
                //activeForm.RotateAround(activeForm.position, activeForm.forward, -rotation);
                break;
            }
            //activeForm.DORotate(currentRotation, interpolationDuration, RotateMode.FastBeyond360).SetEase(interpolationEase);
            // TODO: make the animarion great again
        }
    }
Example #2
0
        private List <Level.Rotation> getListOfRotations(string stateJSON)
        {
            var state     = Json.Deserialize(stateJSON) as Dictionary <string, object>;
            var rotations = state[ROTATION] as List <object>;

            /*var rotationsJson = Json.Serialize(state[ROTATION]);
             * Debug.Log("Rotations: " + state[ROTATION]);
             * var rotations = Json.Deserialize(rotationsJson) as Dictionary<string, object>;*/
            // TODO: check if this works
            //rotations.OrderBy(r => r.Key);

            List <Level.Rotation> rotationsList = new List <Level.Rotation>();

            foreach (object rs in rotations)
            {
                Debug.Log("Rot: " + rs);
                var rotationJson = Json.Serialize(rs);
                Debug.Log("Rot: " + rotationJson);
                var rotation = Json.Deserialize(rotationJson) as Dictionary <string, object>;
                foreach (KeyValuePair <string, object> r in rotation)
                {
                    GameInputController.ROTATION_AXIS axis = GameInputController.ROTATION_AXIS.X;
                    if (r.Key == "x")
                    {
                        axis = GameInputController.ROTATION_AXIS.X;
                    }
                    else if (r.Key == "y")
                    {
                        axis = GameInputController.ROTATION_AXIS.Y;
                    }
                    else if (r.Key == "z")
                    {
                        axis = GameInputController.ROTATION_AXIS.Z;
                    }
                    Debug.Log("Axis: " + axis + " Value: " + r.Value);
                    rotationsList.Add(new Level.Rotation
                    {
                        Axis  = axis,
                        Value = ((float)(Int64)r.Value)
                    });
                }
            }
            return(rotationsList);
        }