/**
         * <summary>Updates its own variables from a MoveableData class.</summary>
         * <param name = "saveData">The MoveableData class to load from</param>
         */
        public void LoadData(MoveableData saveData)
        {
            inWorldSpace = saveData.inWorldSpace;

            if (!saveData.doEulerRotation)
            {
                if (inWorldSpace)
                {
                    transform.rotation = new Quaternion(saveData.RotW, saveData.RotX, saveData.RotY, saveData.RotZ);
                }
                else
                {
                    transform.localRotation = new Quaternion(saveData.RotW, saveData.RotX, saveData.RotY, saveData.RotZ);
                }
            }

            StopMoving();
        }
コード例 #2
0
ファイル: Moveable.cs プロジェクト: sirmortimus/team9
        /**
         * <summary>Updates a MoveableData class with its own variables that need saving.</summary>
         * <param name = "saveData">The original MoveableData class</param>
         * <returns>The updated MoveableData class</returns>
         */
        public MoveableData SaveData(MoveableData saveData)
        {
            if (positionChangeTime > 0f)
            {
                saveData.LocX = endPosition.x;
                saveData.LocY = endPosition.y;
                saveData.LocZ = endPosition.z;
            }

            if (rotateChangeTime > 0f)
            {
                saveData.doEulerRotation = doEulerRotation;

                if (doEulerRotation)
                {
                    saveData.LocX = endEulerRotation.x;
                    saveData.LocY = endEulerRotation.y;
                    saveData.LocZ = endEulerRotation.z;
                }
                else
                {
                    saveData.RotW = endRotation.w;
                    saveData.RotX = endRotation.x;
                    saveData.RotY = endRotation.y;
                    saveData.RotZ = endRotation.z;
                }
            }
            else
            {
                saveData.doEulerRotation = true;
            }

            if (scaleChangeTime > 0f)
            {
                saveData.ScaleX = endScale.x;
                saveData.ScaleY = endScale.y;
                saveData.ScaleZ = endScale.z;
            }

            saveData.inWorldSpace = inWorldSpace;

            return(saveData);
        }
コード例 #3
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            MoveableData moveableData = new MoveableData();

            moveableData.objectID      = constantID;
            moveableData.savePrevented = savePrevented;

            if (gameObject.layer == LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer))
            {
                moveableData.isOn = true;
            }
            else
            {
                moveableData.isOn = false;
            }

            if (GetComponent <Moveable_Drag>())
            {
                Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();
                moveableData.trackValue  = moveable_Drag.trackValue;
                moveableData.revolutions = moveable_Drag.revolutions;
            }

            moveableData.LocX = transform.position.x;
            moveableData.LocY = transform.position.y;
            moveableData.LocZ = transform.position.z;

            moveableData.RotX = transform.eulerAngles.x;
            moveableData.RotY = transform.eulerAngles.y;
            moveableData.RotZ = transform.eulerAngles.z;

            moveableData.ScaleX = transform.localScale.x;
            moveableData.ScaleY = transform.localScale.y;
            moveableData.ScaleZ = transform.localScale.z;

            if (GetComponent <Moveable>())
            {
                moveableData = GetComponent <Moveable>().SaveData(moveableData);
            }

            return(Serializer.SaveScriptData <MoveableData> (moveableData));
        }
コード例 #4
0
		public MoveableData SaveData ()
		{
			MoveableData moveableData = new MoveableData ();
			
			moveableData.objectID = constantID;

			if (gameObject.layer == LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.hotspotLayer))
			{
				moveableData.isOn = true;
			}
			else
			{
				moveableData.isOn = false;
			}

			if (GetComponent <Moveable_Drag>())
			{
				Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();
				moveableData.trackValue = moveable_Drag.trackValue;
				moveableData.revolutions = moveable_Drag.revolutions;
			}
			
			moveableData.LocX = transform.position.x;
			moveableData.LocY = transform.position.y;
			moveableData.LocZ = transform.position.z;
			
			moveableData.RotX = transform.eulerAngles.x;
			moveableData.RotY = transform.eulerAngles.y;
			moveableData.RotZ = transform.eulerAngles.z;
			
			moveableData.ScaleX = transform.localScale.x;
			moveableData.ScaleY = transform.localScale.y;
			moveableData.ScaleZ = transform.localScale.z;
			
			return moveableData;
		}
コード例 #5
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            MoveableData moveableData = new MoveableData ();

            moveableData.objectID = constantID;

            if (gameObject.layer == LayerMask.NameToLayer (KickStarter.settingsManager.hotspotLayer))
            {
                moveableData.isOn = true;
            }
            else
            {
                moveableData.isOn = false;
            }

            if (GetComponent <Moveable_Drag>())
            {
                Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();
                moveableData.trackValue = moveable_Drag.trackValue;
                moveableData.revolutions = moveable_Drag.revolutions;
            }

            moveableData.LocX = transform.position.x;
            moveableData.LocY = transform.position.y;
            moveableData.LocZ = transform.position.z;

            moveableData.RotX = transform.eulerAngles.x;
            moveableData.RotY = transform.eulerAngles.y;
            moveableData.RotZ = transform.eulerAngles.z;

            moveableData.ScaleX = transform.localScale.x;
            moveableData.ScaleY = transform.localScale.y;
            moveableData.ScaleZ = transform.localScale.z;

            return Serializer.SaveScriptData <MoveableData> (moveableData);
        }
コード例 #6
0
		public void LoadData (MoveableData data)
		{
			if (GetComponent <DragBase>())
			{
				if (data.isOn)
				{
					GetComponent <DragBase>().TurnOn ();
				}
				else
				{
					GetComponent <DragBase>().TurnOff ();
				}
			}

			if (data.isOn)
			{
				gameObject.layer = LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.hotspotLayer);
			}
			else
			{
				gameObject.layer = LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.deactivatedLayer);
			}

			transform.position = new Vector3 (data.LocX, data.LocY, data.LocZ);
			transform.eulerAngles = new Vector3 (data.RotX, data.RotY, data.RotZ);
			transform.localScale = new Vector3 (data.ScaleX, data.ScaleY, data.ScaleZ);

			if (GetComponent <Moveable_Drag>())
			{
				Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();
				moveable_Drag.isHeld = false;
				if (moveable_Drag.dragMode == DragMode.LockToTrack && moveable_Drag.track != null)
				{
					moveable_Drag.trackValue = data.trackValue;
					moveable_Drag.revolutions = data.revolutions;
					moveable_Drag.StopAutoMove ();
					moveable_Drag.track.SetPositionAlong (data.trackValue, moveable_Drag);
				}
			}
		}
コード例 #7
0
        public override void LoadData(string stringData)
        {
            MoveableData data = Serializer.LoadScriptData <MoveableData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            DragBase dragBase = GetComponent <DragBase>();

            if (dragBase)
            {
                if (data.isOn)
                {
                    dragBase.TurnOn();
                }
                else
                {
                    dragBase.TurnOff();
                }
            }

            if (data.isOn)
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer);
            }
            else
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer);
            }

            transform.position    = new Vector3(data.LocX, data.LocY, data.LocZ);
            transform.eulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ);
            transform.localScale  = new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ);

            Moveable_Drag moveable_Drag = GetComponent <Moveable_Drag>();

            if (moveable_Drag)
            {
                moveable_Drag.LetGo();
                if (moveable_Drag.dragMode == DragMode.LockToTrack)
                {
                    DragTrack dragTrack = ConstantID.GetComponent <DragTrack> (data.trackID);
                    if (dragTrack)
                    {
                        moveable_Drag.SnapToTrack(dragTrack, data.trackValue);
                    }

                    if (moveable_Drag.track)
                    {
                        moveable_Drag.trackValue  = data.trackValue;
                        moveable_Drag.revolutions = data.revolutions;
                        moveable_Drag.StopAutoMove();
                        moveable_Drag.track.SetPositionAlong(data.trackValue, moveable_Drag);
                    }
                }
            }

            Moveable moveable = GetComponent <Moveable>();

            if (moveable)
            {
                moveable.LoadData(data);
            }

            loadedData = true;
        }