예제 #1
0
        private static void CreateStateInstances(IApplicationController applicationController,
                                                 IItemFormatter itemFormatter,
                                                 IMargin labelMargin,
                                                 out IBackgroundState backgroundState,
                                                 out IGridState gridState,
                                                 out IScaleState scaleState,
                                                 out IDataDrawState graphState,
                                                 out IScalingState scalingState,
                                                 out IGraphControlFormState graphControlFormState)
        {
            backgroundState = new BackgroundState();
            applicationController.RegisterInstance <IBackgroundState>(backgroundState);

            gridState = new GridState();
            gridState.LabelPadding  = labelMargin;
            gridState.ItemFormatter = itemFormatter;
            applicationController.RegisterInstance <IGridState>(gridState);

            scaleState = new ScaleState();
            applicationController.RegisterInstance <IScaleState>(scaleState);

            graphState = new DataDrawState();
            applicationController.RegisterInstance <IDataDrawState>(graphState);

            scalingState = new ScalingState();
            applicationController.RegisterInstance <IScalingState>(scalingState);

            graphControlFormState = new GraphControlFormState();
            applicationController.RegisterInstance <IGraphControlFormState>(graphControlFormState);
        }
예제 #2
0
    private void Update()
    {
        if (m_State == ScaleState.Idle)
        {
            return;
        }

        if (m_State == ScaleState.In)
        {
            m_Transform.localScale = Lerp(Vector2.zero, m_OriginalScale, m_ElapsedTime / m_EnableTime, out m_Completed);
            if (m_Completed)
            {
                m_State = ScaleState.Idle;
            }
        }

        if (m_State == ScaleState.Out && !m_Transform.localScale.Equals(Vector2.zero))
        {
            m_Transform.localScale = Lerp(m_OriginalScale, Vector2.zero, m_ElapsedTime / m_DisableTime, out m_Completed);
            if (m_Completed)
            {
                m_State = ScaleState.Idle;
            }
        }

        m_ElapsedTime += Time.deltaTime;
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (curScaleState == ScaleState.INCR)
        {
            currentScale += curSpeed * Time.deltaTime;
            if (currentScale >= curMaxScale)
            {
                currentScale   = curMaxScale;
                curScaleState  = ScaleState.DECR;
                secondaryBeat ^= true;
                curMaxScale    = secondaryBeat ? secondaryMaxScale : primaryMaxScale;
            }
        }
        else if (curScaleState == ScaleState.DECR)
        {
            currentScale -= curSpeed * Time.deltaTime;
            if (currentScale <= curMinScale)
            {
                currentScale  = curMinScale;
                curScaleState = ScaleState.INCR;
            }
        }

        heartImage.GetComponent <RectTransform>().localScale = new Vector3(currentScale, currentScale);
    }
예제 #4
0
    public void ChangeScaleMode()
    {
        TextMeshPro[] texts = GameObject.Find("ScaleButton").GetComponentsInChildren <TextMeshPro>();
        Vector3       scale = originalTransform[0].scale;

        //Vector3 pos = bones[0].transform.localPosition;
        //Vector3 scaledPosition = new Vector3(pos.x / scale.x, pos.y / scale.y, pos.z / scale.z);
        //bones[0].transform.localPosition = scaledPosition;
        switch (gScaleState)
        {
        case ScaleState.Half:
        {
            gScaleState = ScaleState.Original;
            for (int i = 1; i < 100; i++)
            {
                Invoke("ScaleUpStep", 0.5f * i / 100);
            }
            //bones[0].transform.localScale = scale;

            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 2x";
            }
            break;
        }

        case ScaleState.Original:
        {
            gScaleState = ScaleState.Double;
            for (int i = 1; i < 200; i++)
            {
                Invoke("ScaleUpStep", 0.5f * i / 200);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 0.5x";
            }
            break;
        }

        case ScaleState.Double:
        {
            gScaleState = ScaleState.Half;
            for (int i = 1; i < 100; i++)
            {
                Invoke("ScaleDownStep", 0.5f * i / 100);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 1x";
            }
            break;
        }

        default:
            break;
        }
    }
예제 #5
0
    public void ChangeScaleMode()
    {
        TextMeshPro[] texts = GameObject.Find("ScaleButton").GetComponentsInChildren <TextMeshPro>();

        Debug.Log("Change Scale Button Pressed");

        Vector3 scale = originalTransform[0].scale;

        switch (gScaleState)
        {
        case ScaleState.Half:
        {
            gScaleState = ScaleState.Original;
            for (int i = 1; i < 100; i++)
            {
                Invoke("ScaleUpStep", 0.5f * i / 100);
            }

            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 2x";
            }
            break;
        }

        case ScaleState.Original:
        {
            gScaleState = ScaleState.Double;
            for (int i = 1; i < 200; i++)
            {
                Invoke("ScaleUpStep", 0.5f * i / 200);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 0.5x";
            }
            break;
        }

        case ScaleState.Double:
        {
            gScaleState = ScaleState.Half;
            for (int i = 1; i < 100; i++)
            {
                Invoke("ScaleDownStep", 0.5f * i / 100);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 1x";
            }
            break;
        }

        default:
            break;
        }
    }
예제 #6
0
    // Start is called before the first frame update
    void Start()
    {
        numberOfBones = 6;

        // init bone references
        for (int i = 1; i <= numberOfBones; i++)
        {
            GameObject t = GameObject.Find("Bone_" + i);
            bones.Add(t);
            Transform     tr = t.GetComponent <Transform>();
            TransformInfo ti = new TransformInfo
            {
                pos    = tr.localPosition,
                rotate = tr.localRotation,
                scale  = tr.localScale
            };
            originalTransform.Add(ti);
        }

        gBoneState = BoneState.ShowAll;

        // slider enable/disable
        slider  = GameObject.Find("PinchSlider");
        slider2 = GameObject.Find("PinchSliderHor");

        // scale functions
        gScaleState = ScaleState.Original;

        // menus
        nearMenu = GameObject.Find("NearMenu");
        handMenu = GameObject.Find("HandMenu");

        //document slate
        docSlate = GameObject.Find("Slate");
        Material firstPage = docSlate.transform.Find("ContentQuad").gameObject.GetComponent <Pages>().getMat();

        docSlate.transform.Find("ContentQuad").gameObject.GetComponent <Renderer>().material = firstPage;
        docSlate.SetActive(false);

        GameObject bone_1_ref = GameObject.Find("Bone_1");

        // bone manipulation components
        boneBoundingBox         = bone_1_ref.transform.Find("BoneGroup").gameObject.GetComponent <BoundingBox>();
        boneManipulationHandler = bone_1_ref.transform.Find("BoneGroup").gameObject.GetComponent <ManipulationHandler>();

        // CT manipulation components
        ctBoundingBox         = bone_1_ref.transform.Find("CTGroup").gameObject.GetComponent <BoundingBox>();
        ctManipulationHandler = bone_1_ref.transform.Find("CTGroup").gameObject.GetComponent <ManipulationHandler>();

        // group manipulation components
        allBoundingBox         = bone_1_ref.GetComponent <BoundingBox>();
        allManipulationHandler = bone_1_ref.GetComponent <ManipulationHandler>();

        handMenu.SetActive(false);
    }
    public void ChangeScaleMode()
    {
        TextMeshPro[] texts = GameObject.Find("ScaleButton").GetComponentsInChildren <TextMeshPro>();
        Vector3       scale = originalTransform[0].scale;

        // the scale of bones changes from 0.5 -> 1.0 -> 2.0 -> 0.5 repeatedly
        switch (gScaleState)
        {
        case ScaleState.Half:
        {
            gScaleState = ScaleState.Original;
            bones[0].transform.localScale = scale;

            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 2x";
            }
            break;
        }

        case ScaleState.Original:
        {
            gScaleState = ScaleState.Double;
            for (int i = 1; i < 200; i++)
            {
                Invoke("ScaleUpStep", 0.5f * i / 200);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 0.5x";
            }
            break;
        }

        case ScaleState.Double:
        {
            gScaleState = ScaleState.Half;
            for (int i = 1; i < 100; i++)
            {
                Invoke("ScaleDownStep", 0.5f * i / 100);
            }
            foreach (TextMeshPro tmp in texts)
            {
                tmp.text = "Zoom: 1x";
            }
            break;
        }

        default:
            break;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        numberOfBones         = 6;
        numberOfAdjustedBones = 7;

        Debug.Log("Number of bones loaded: " + numberOfBones);
        Debug.Log("Number of adjusted bones loaded: " + numberOfAdjustedBones);

        // store the initial trasformations of bone fragements
        for (int i = 1; i <= numberOfBones; i++)
        {
            GameObject t = GameObject.Find("Bone_" + i);
            bones.Add(t);
            Transform     tr = t.GetComponent <Transform>();
            TransformInfo ti = new TransformInfo
            {
                pos    = tr.localPosition,
                rotate = tr.localRotation,
                scale  = tr.localScale
            };
            originalTransform.Add(ti);
        }

        // store the initial trasformations of adjusted bone fragments
        for (int i = 1; i <= numberOfAdjustedBones; i++)
        {
            GameObject t = GameObject.Find("Bone_" + i + "_aligned");
            adjustedBones.Add(t);
            Transform     tr = t.GetComponent <Transform>();
            TransformInfo ti = new TransformInfo
            {
                pos    = tr.localPosition,
                rotate = tr.localRotation,
                scale  = tr.localScale
            };
            originalTransformAdjusted.Add(ti);
        }

        gBoneState = BoneState.ShowAll;

        // color mode init
        gColorState = ColorState.Select;

        // slider enable/disable
        slider  = GameObject.Find("PinchSlider");
        slider2 = GameObject.Find("PinchSliderHor");

        // scale functions
        gScaleState = ScaleState.Original;
    }
예제 #9
0
        private static void CreateStateInstancees(IApplicationController applicationController,
                                                  out IBackgroundState backgroundState, out IGridState gridState, out IScaleState scaleState, out IDataDrawState graphState, out IGraphControlFormState graphControlFormState)
        {
            backgroundState = new BackgroundState();
            applicationController.RegisterInstance <IBackgroundState>(backgroundState);

            gridState = new GridState();
            applicationController.RegisterInstance <IGridState>(gridState);

            scaleState = new ScaleState();
            applicationController.RegisterInstance <IScaleState>(scaleState);

            graphState = new DataDrawState();
            applicationController.RegisterInstance <IDataDrawState>(graphState);

            graphControlFormState = new GraphControlFormState();
            applicationController.RegisterInstance <IGraphControlFormState>(graphControlFormState);
        }
예제 #10
0
    void UpdateScale()
    {
        fLerp += Time.deltaTime * (int)state * fScaleSpeed;

        trBox.transform.localScale = Vector3.Lerp(Vector3.zero, new Vector3(1.1f, 1.1f, 1.1f), curve.Evaluate(fLerp));

        if (state == ScaleState.scale && fLerp >= 1)
        {
            state  = ScaleState.idle;
            fTimer = fShowLength;
        }

        if (state == ScaleState.unscale && fLerp <= 0)
        {
            state    = ScaleState.idle;
            fTimer   = Random.Range(fDelayMin, fDelayMax);
            bIsShown = false;
        }
    }
예제 #11
0
    /// <summary>
    /// Creates the state of the base.创建一个基本的状态管理器
    /// </summary>
    /// <returns>The base state.</returns>
    /// <param name="tra">Tra.管理的tansform对象</param>
    StateManager CreateBaseState(Transform tra)
    {
        StateManager stateMgr = new StateManager(tra);

        IdleState   idle        = new IdleState();
        ScaleState  scale       = new ScaleState();
        RotateState rotate      = new RotateState();
        DragState   drag        = new DragState();
        StaticState staticState = new StaticState();


        stateMgr.Add(idle);
        stateMgr.Add(scale);
        stateMgr.Add(rotate);
        stateMgr.Add(drag);
        stateMgr.Add(staticState);

        return(stateMgr);
    }
예제 #12
0
 void Update()
 {
     if (curScaleState == ScaleState.scaling)
     {
         targetScaleFactor   += Time.deltaTime * scaleSpeed;
         transform.localScale = Vector3.Slerp(Vector3.zero, targetScale, targetScaleFactor);
         if (targetScaleFactor > 1f)
         {
             curScaleState     = ScaleState.stopScale;
             targetScaleFactor = 0f;
         }
     }
     else if (curScaleState == ScaleState.stopScale)
     {
         targetScaleFactor += Time.deltaTime;
         if (targetScaleFactor > timeLengthAfterScaleUp)
         {
             Factory.Recycle(transform);
         }
     }
 }
예제 #13
0
        public void ZoomAndUnzoomTest()
        {
            var controller = TestFactory.CreateApplicationController();

            TestFactory.CreateBaseServices(controller, null,
                                           out IGridState gridState, out IDataDrawState graphState,
                                           out IItemFormatter itemFormatter, out IMargin margin,
                                           out IDataService dataService, out IScaleService scaleService);

            int iterations = 100000;
            var state      = new ScaleState(scaleService.State);

            for (int i = 0; i < iterations; i++)
            {
                scaleService.Zoom(-120);
            }
            for (int i = 0; i < iterations && !state.Equals(scaleService.State); i++)
            {
                scaleService.Zoom(-120);
            }
            Assert.IsTrue(state.Equals(scaleService.State), $"State before zooming/unzooming not the same as before");
        }
예제 #14
0
    void UpdatePos()
    {
        if (weight1 > weight2 + 0.1f && currentState != ScaleState.Plate1Down)
        {
            print("Plate 1 down");
            m_anim.SetTrigger("Plate 1 down");
            currentState = ScaleState.Plate1Down;
        }

        if (weight2 > weight1 + 0.1f && currentState != ScaleState.Plate2Down)
        {
            print("Plate 2 down");
            m_anim.SetTrigger("Plate 2 down");
            currentState = ScaleState.Plate2Down;
        }

        if (weight1 >= weight2 - 0.1f && weight2 >= weight1 - 0.1f && currentState != ScaleState.Level)
        {
            print("Plates level");
            m_anim.SetTrigger("Level");
            currentState = ScaleState.Level;
        }
    }
예제 #15
0
    void Update()
    {
        if (state == ScaleState.Off)
        {
            return;
        }

        if (state == ScaleState.Decrease)
        {
            if (CheckPoint(transform.localScale.x, startScale.x) &&
                CheckPoint(transform.localScale.z, startScale.z))
            {
                transform.localScale = startScale;
                state = ScaleState.Off;
            }
            else
            {
                transform.localScale = Vector3.Lerp(transform.localScale, startScale, Time.deltaTime * scaleSpeed);
                //SetScale(-scaleVectSpeed);
            }
        }
        else
        {
            if (transform.localScale.x >= newScale.x &&
                transform.localScale.z >= newScale.z)
            {
                transform.localScale = newScale;
                state = ScaleState.Off;
            }
            else
            {
                transform.localScale = Vector3.Lerp(transform.localScale, newScale, Time.deltaTime * scaleSpeed);
                //SetScale(scaleVectSpeed);
            }
        }
    }
예제 #16
0
 public void StartDecrease()
 {
     state = ScaleState.Decrease;
 }
예제 #17
0
 public void StartIncrease()
 {
     state = ScaleState.Increase;
 }
예제 #18
0
 public void Enable()
 {
     m_ElapsedTime = 0.0f;
     m_State       = ScaleState.In;
 }
예제 #19
0
 public void Disable()
 {
     m_ElapsedTime = 0.0f;
     m_State       = ScaleState.Out;
 }
 public void InvokeOnScalingUpYEndedEvent(ScaleState scaleState)
 {
     onScalingUpYEndedEvent.Invoke(scaleState);
 }
    public void LaunchRelativeToTimeY(ScaleState scaleState)
    {
        var time = scaleState.timeScalingUpY;

        LaunchRelativeToFactor(time);
    }
    public void LaunchRelativeToDeltaScaleY(ScaleState scaleState)
    {
        var delta = scaleState.currentScale.y - scaleState.prevScale.y;

        LaunchRelativeToFactor(delta);
    }
예제 #23
0
 public void TriggerUnscale()
 {
     fLerp = 1;
     state = ScaleState.unscale;
 }
예제 #24
0
 // Update is called once per frame
 void Update()
 {
     switch(_scaleState)
     {
         case ScaleState._increase:
             if (_currentFontSize >= _scaleFontTo)
             {
                 _scaleState = ScaleState._static;
                 break;
             }
             _currentFontSize += _step;
             _labelText.fontSize = _currentFontSize;
             if (Shadow != null)
             {
                 Shadow._currentFontSize += _step;
                 Shadow._labelText.fontSize = Shadow._currentFontSize;
             }
             return;
         case ScaleState._static:
             _pauseTimeout--;
             if (_pauseTimeout <= 0)
                 _scaleState = ScaleState._decrease;
             return;
         case ScaleState._decrease:
             if (_destroyAfterAnimation)
             {
                 if (_currentFontSize > _animateFromSize)
                 {
                     _currentFontSize -= _step;
                     _labelText.fontSize = _currentFontSize;
                     if (Shadow != null)
                     {
                         Shadow._currentFontSize -= _step;
                         Shadow._labelText.fontSize = Shadow._currentFontSize;
                     }
                 }
                 else
                 {
                     if (_type.HasValue)
                     {
                         _scaleState = ScaleState._none;
                         transform.localScale = Vector3.zero;
                         if (Shadow != null)
                             Shadow.transform.localScale = Vector3.zero;
                     }
                     else
                     {
                         if (Shadow != null)
                             Destroy(Shadow.gameObject);
                         Destroy(gameObject);
                     }
                     //_destroyAfterAnimation = false;
                     if (_animationFinished == null) return;
                     var callback = _animationFinished;
                     _animationFinished = null;
                     callback();
                 }
             }
             else
             {
                 if (_animationFinished == null) return;
                 var callback = _animationFinished;
                 _animationFinished = null;
                 callback();
                 _scaleState = ScaleState._none;
             }
             return;
     }
 }
예제 #25
0
    // Start is called before the first frame update
    void Start()
    {
        //DirectoryInfo di = new DirectoryInfo(Application.dataPath + "/MyDemo/Assets/Meshes");
        //FileInfo[] fis = di.GetFiles();

        //foreach (FileInfo fi in fis)
        //{
        //    // File Name Convensions :
        //    // Bone_1.obj for base bones,
        //    // Bone_#.obj for fragments,
        //    // Bone_#_aligned.obj for adjusted fragments,
        //    // Bone_{#+1}_aligned.obj for addition artifitial structures.

        //    //Debug.Log(fi.Name);
        //    if (fi.Extension.Contains("obj"))
        //    {
        //        if (fi.Name.Contains("aligned"))
        //            numberOfAdjustedBones++;
        //        else
        //            numberOfBones++;
        //    }
        //}

        numberOfBones         = 6;
        numberOfAdjustedBones = 7;

        Debug.Log("Number of bones loaded: " + numberOfBones);
        Debug.Log("Number of adjusted bones loaded: " + numberOfAdjustedBones);

        // init bone references
        for (int i = 1; i <= numberOfBones; i++)
        {
            GameObject t = GameObject.Find("Bone_" + i);
            bones.Add(t);
            Transform     tr = t.GetComponent <Transform>();
            TransformInfo ti = new TransformInfo
            {
                pos    = tr.localPosition,
                rotate = tr.localRotation,
                scale  = tr.localScale
            };
            originalTransform.Add(ti);
        }

        for (int i = 1; i <= numberOfAdjustedBones; i++)
        {
            GameObject t = GameObject.Find("Bone_" + i + "_aligned");
            adjustedBones.Add(t);
            Transform     tr = t.GetComponent <Transform>();
            TransformInfo ti = new TransformInfo
            {
                pos    = tr.localPosition,
                rotate = tr.localRotation,
                scale  = tr.localScale
            };
            originalTransformAdjusted.Add(ti);
        }

        gBoneState = BoneState.ShowAll;

        // color mode init
        gColorState = ColorState.Select;

        // slider enable/disable
        slider  = GameObject.Find("PinchSlider");
        slider2 = GameObject.Find("PinchSliderHor");

        // scale functions
        gScaleState = ScaleState.Original;
    }
예제 #26
0
 public void TriggerScale()
 {
     fLerp    = 0;
     bIsShown = true;
     state    = ScaleState.scale;
 }
예제 #27
0
 public void ResolveSizeUp(ScaleState scaleState)
 {
     ResolveSizeUp(scaleState.prevScale, scaleState.currentScale);
 }
예제 #28
0
 void OnEnable()
 {
     targetScaleFactor    = 0f;
     transform.localScale = Vector3.zero;
     curScaleState        = ScaleState.scaling;
 }