示例#1
0
    //called to synchronize gameObjectClone of Object2PropertiesMapping back to this saved state
    public void synchronizeProperties(GameObject go, Object2PropertiesMapping o2m)
    {
        //HINT: lerping is still highly experimental
        //EZReplayManager.singleton.StartCoroutine_Auto(EZReplayManager.singleton.MoveTo (go.transform,serVec3ToVec3(this.localPosition),0.08f));

        if (o2m.isParentObj && o2m.getGameObject() != null && o2m.getGameObject().transform.parent != null)
        {
            go.transform.position = this.position;
            go.transform.rotation = this.rotation;
        }
        else
        {
            go.transform.localPosition = this.localPosition;
            go.transform.localRotation = this.localRotation;
        }

        go.SetActive(this.isActive);

        if (emittingParticles)
        {
            go.GetComponent <ParticleEmitter> ().emit = true;
        }
        else if (go.GetComponent <ParticleEmitter> ())
        {
            go.GetComponent <ParticleEmitter> ().emit = false;
        }
    }
示例#2
0
    //	public Vector3 serVec3ToVec3 (SerVector3 serVec3)
    //	{
    //		return new Vector3 (serVec3.x, serVec3.y, serVec3.z);
    //	}
    //
    //	public Quaternion serQuatToQuat (SerQuaternion serQuat)
    //	{
    //		return new Quaternion (serQuat.x, serQuat.y, serQuat.z, serQuat.w);
    //	}

    public bool isDifferentTo(SavedState otherState, Object2PropertiesMapping o2m)
    {
        bool changed = false;

        if (!changed && isActive != otherState.isActive)
        {
            changed = true;
        }

        if (o2m.isParentObj && o2m.getGameObject().transform.parent != null)
        {
            if (!changed && position.isDifferentTo(otherState.position))
            {
                changed = true;
            }

            if (!changed && rotation.isDifferentTo(otherState.rotation))
            {
                changed = true;
            }
        }

        if (!changed && localPosition.isDifferentTo(otherState.localPosition))
        {
            changed = true;
        }

        if (!changed && localRotation.isDifferentTo(otherState.localRotation))
        {
            changed = true;
        }

        if (!changed && emittingParticles != otherState.emittingParticles)
        {
            changed = true;
        }

        return(changed);
    }
示例#3
0
    //called to synchronize gameObjectClone of Object2PropertiesMapping back to this saved state
    public void synchronizeProperties(GameObject go, Object2PropertiesMapping o2m)
    {
        //HINT: lerping is still highly experimental
        //EZReplayManager.singleton.StartCoroutine_Auto(EZReplayManager.singleton.MoveTo (go.transform,serVec3ToVec3(this.localPosition),0.08f));

        if (o2m.isParentObj && o2m.getGameObject() != null && o2m.getGameObject().transform.parent != null) {

            go.transform.position = serVec3ToVec3(this.position);
            go.transform.rotation = serQuatToQuat(this.rotation);

        } else {
            go.transform.localPosition = serVec3ToVec3(this.localPosition);
            go.transform.localRotation = serQuatToQuat(this.localRotation);

        }

        go.SetActive( this.isActive );

        if (emittingParticles)
            go.GetComponent<ParticleEmitter>().emit = true;
        else if ( go.GetComponent<ParticleEmitter>() )
            go.GetComponent<ParticleEmitter>().emit = false;
    }
示例#4
0
    public bool isDifferentTo(SavedState otherState, Object2PropertiesMapping o2m)
    {
        bool changed = false;

        if (!changed && isActive != otherState.isActive)
            changed = true;

        if (o2m.isParentObj && o2m.getGameObject().transform.parent != null) {
            if (!changed && position.isDifferentTo(otherState.position) )
                changed = true;

            if (!changed && rotation.isDifferentTo(otherState.rotation) )
                changed = true;
        }

        if (!changed && localPosition.isDifferentTo( otherState.localPosition) )
            changed = true;

        if (!changed && localRotation.isDifferentTo( otherState.localRotation) )
            changed = true;

        if (!changed && emittingParticles != otherState.emittingParticles)
            changed = true;

        return changed;
    }
示例#5
0
    //switch to different mode.. so far there are MODE_LIVE for viewing a normal game action and MODE_REPLAY for viewing a replay of a recording
    public void switchModeTo(ViewMode newMode)
    {
        if (newMode == ViewMode.LIVE)
        {
            sendCallback2All("__EZR_live_prepare", null);

            //reset game object (i.e. rigidbody state)
            foreach (KeyValuePair <GameObject, Object2PropertiesMapping> entry in gOs2propMappings)
            {
                //GameObject go = entry.Key;
                Object2PropertiesMapping propMapping = entry.Value;
                if (propMapping.getGameObject() != null)
                {
                    propMapping.resetObject();
                }
            }

            bool tmpWasLoading = false;
            if (isLoadingSlotInUse())
            {
                tmpWasLoading = true;
            }

            useRecordingSlot();

            if (tmpWasLoading)             //repeat to avoid a bug
            {
                switchModeTo(ViewMode.LIVE);
            }

            //COUNTFRAMES
            maxPositions = getMaxFrames(gOs2propMappings);


            sendCallback2All("__EZR_live_ready", null);
        }
        else
        {
            sendCallback2All("__EZR_replay_prepare", null);

            if (maxPositions > 0)
            {
                //prepare parents first
                foreach (KeyValuePair <GameObject, Object2PropertiesMapping> entry in gOs2propMappings)
                {
                    //GameObject go = entry.Key;
                    Object2PropertiesMapping propMapping = entry.Value;
                    if (propMapping.isParent())
                    {
                        //if (propMapping.getGameObject() != null)
                        propMapping.prepareObjectForReplay();
                    }
                }
                //..then childs
                foreach (KeyValuePair <GameObject, Object2PropertiesMapping> entry in gOs2propMappings)
                {
                    //GameObject go = entry.Key;
                    Object2PropertiesMapping propMapping = entry.Value;
                    if (!propMapping.isParent())
                    {
                        //if (propMapping.getGameObject() != null)
                        propMapping.prepareObjectForReplay();
                    }
                }

                sendCallback2All("__EZR_replay_ready", null);
            }
            else
            {
                newMode = ViewMode.LIVE;
                if (showWarnings)
                {
                    print("EZReplayManager WARNING: You have not recorded anything yet. Will not replay.");
                }
            }
        }

        currentMode = newMode;
        stop();
    }