Esempio n. 1
0
    public AnimationBeing CreateScaleAnim(GameObject objRef, Vector3 initial, Vector3 target, AnimationType animType, float duration, int direction, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetAnimationVectorStruct(new AnimationVectorStuct(initial, target));

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            Vector3 res = field.GetAnimationVectorStruct().initial *(1 - alpha) + field.GetAnimationVectorStruct().target *alpha;
            //Debug.Log(res);
            obj.transform.localScale = res;
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(objRef, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.GetAnimationVectorStruct());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }
Esempio n. 2
0
    public override void Execute()
    {
        base.Execute();


        InstructionPanel.Instace.SetText("Please scan QR code #3");
        InstructionPanel.Instace.ActivatePanel(true);

        //Enable the appropriate tracker and dont show the object
        VuforiaManager.Instance.EnableTrackerIndex(2);
        VuforiaManager.Instance.GetCurrentTrackerEventHandler().RegisterToTrackerTrackedEvent(DisplayPsigChekPanel);

        //Animate the gauge material
        gaugeBeing = PanelAnimator.Instance.CreateMaterialAnimation(gaugeMaterial.gameObject, gaugeMaterial.sharedMaterial, "_Transparency",
                                                                    AnimationType.Parallel, 1, 1, true);

        //LinkPanels
        psigCheckPanel.LinkPanelToButton(psigCheckPanel.GetNextButton(), boardOperatorPanel);
        boardOperatorPanel.LinkPanelToButton(boardOperatorPanel.GetPreviousButton(), psigCheckPanel);
        boardOperatorPanel.LinkPanelToButton(boardOperatorPanel.GetNextButton(), timerPanel);
        timerPanel.LinkPanelToButton(timerPanel.GetPreviousButton(), boardOperatorPanel);

        //Timer panel activation event
        timerPanel.panelActivatedEvent += TimerPanelActivated;

        //Timer PanelNextClick
        timerPanel.GetNextButton().ButtonPressEvent += GoToNextSequence;
    }
Esempio n. 3
0
    /// <summary>
    /// Animate the specified property value between 0 and 1
    /// </summary>
    /// <param name="objref"></param>
    /// <param name="material"></param>
    /// <param name="property"></param>
    /// <param name="animType"></param>
    /// <param name="duration"></param>
    /// <param name="direction"></param>
    /// <param name="loop"></param>
    /// <returns></returns>
    public AnimationBeing CreateMaterialAnimation(GameObject objRef, Material material, string property, AnimationType animType, float duration, int direction = 1, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetMaterial(material);

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            //Vector3 res = t.GetAnimationVectorStruct().initial * (1 - alpha) + t.GetAnimationVectorStruct().target * alpha;
            material.SetFloat(property, alpha);
            //Debug.Log(res);
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(objRef, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.getMaterial());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }
Esempio n. 4
0
    private void Update()
    {
        //Play Sequence animations
        if (animationBeingsSequence.Count > 0)
        {
            AnimationBeing b = animationBeingsSequence[0];
            b.Update();
            if (b.animationFinished)
            {
                b.targetForDestruction = true;
                animationBeingsSequence.RemoveAt(0);

                DeleteAnimationBeing(b);
            }
        }
        //Debug.Log(animationBeingsParallel.Count);
        //Play Parallel animations
        foreach (AnimationBeing being in animationBeingsParallel)
        {
            Debug.Log("Being:  " + being.obj.name);
            being.Update();
            //This might end up causing some issues. Check this later
            if (being.animationFinished)
            {
                //Debug.Log("Animation done for: " + being.name);
                being.targetForDestruction = true;
                //animationBeingsParallel.Remove(being);

                targetedForDestruction.Add(being);
                //DeleteAnimationBeing(being);
            }
        }
    }
    virtual protected IEnumerator StartDeactivationAnimations(bool animate = true)
    {
        //Hide the buttons first
        HideButtons(null, animate);

        //Wait for a while for button animations to play out
        yield return(new WaitForSeconds(0.75f));

        //while (PanelAnimator.Instance.Contains(HideButtonsAnimated))
        //    yield return null;

        AnimationBeing b = null;

        foreach (AnimationContainer container in animationContainers)
        {
            Debug.Log("Deactivation container playing : " + gameObject.name);
            container.animationBeing.Play();
            b = container.animationBeing;
            yield return(new WaitForSeconds(0.1f));
        }
        //if (b)
        //    Debug.Log("ANimation being:  " + b.name);
        //else
        //    Debug.Log("No B");
        //while (!b.animationFinished)
        if (b != null)
        {
            while (!b.animationFinished)
            {
                yield return(null);
            }
        }

        //yield return new WaitForSeconds(1);

        gameObject.SetActive(false);
        if (manipulatePanelRaycasts)
        {
            GetComponent <Image>().raycastTarget = false;
        }


        isActive = false;
        panelDeactivatedEvent?.Invoke(this);


        //TODO: Need to add an animation to this
        //if(nextButton)
        //    nextButton.gameObject.SetActive(false);
        //if (previousButton)
        //    previousButton.gameObject.SetActive(false);
        yield return(null);
    }
    //Make these functions better
    virtual protected IEnumerator StartActivationAnimations(bool animate = true)
    {
        AnimationBeing b = null;

        foreach (AnimationContainer container in animationContainers)
        {
            container.animationBeing.Play();

            b = container.animationBeing;
            yield return(new WaitForSeconds(0.1f));
        }

        if (b != null)
        {
            while (!b.animationFinished)
            {
                yield return(null);
            }
        }


        ShowButtons(null, animate);

        //Wait for the button animation to play out
        yield return(new WaitForSeconds(0.75f));

        //while (PanelAnimator.Instance.Contains(ShowButtonsAnimated))
        //    yield return null;


        isActive = true;
        panelActivatedEvent?.Invoke(this);


        //If the next and previous buttons are already active, enable them
        if (nextButton)
        {
            if (nextButton.gameObject.activeSelf)
            {
                ActivateNextButton();
            }
        }
        if (previousButton)
        {
            if (previousButton.gameObject.activeSelf)
            {
                ActivatePreviousButton();
            }
        }

        yield return(null);
    }
Esempio n. 7
0
    public AnimationBeing CreateSequenceAnimationBeing <T>(GameObject obj, System.Action <GameObject, AnimationBeingTargetField, float> func,
                                                           T targetComponent, float duration = 1, int direction = 1)
    {
        AnimationBeing being = new AnimationBeing(obj, func, duration, direction);

        //If the target component is specified, always create an animation target being
        if (targetComponent != null)
        {
            being.CreateAnimationBeingTargetAndInitializeDefaultValue(targetComponent);
        }

        animationBeingsSequence.Add(being);

        return(being);
    }
    void TrackerTracked()
    {
        //Unsubscribe
        VuforiaManager.Instance.GetCurrentTrackerEventHandler().UnregisterToTrackerTrackedEvent(TrackerTracked);
        InstructionPanel.Instace.DeactivatePanel(true);


        //Activate the panel
        StartCoroutine(ShowDevice());

        //Show the highlight flange
        VuforiaManager.Instance.GetCurrentTrackerEventHandler().ShowObject();


        flangeBeing = PanelAnimator.Instance.CreateMaterialAnimation(flangeRenderer.gameObject, flangeRenderer.sharedMaterial, "_Transparency",
                                                                     AnimationType.Parallel, 1, 1, true);
    }
Esempio n. 9
0
    IEnumerator BlinkRoutine()
    {
        while (true)
        {
            AnimationBeing b = PanelAnimator.Instance.CreateParallelAnimationBeing(gameObject, ScaleAnim,
                                                                                   new AnimationVectorStuct(new Vector3(0.8f, 0.8f, 0.8f), Vector3.one), 0.5f, 1);

            while (!b.animationFinished)
            {
                yield return(null);
            }

            b = PanelAnimator.Instance.CreateParallelAnimationBeing(gameObject, ScaleAnim,
                                                                    new AnimationVectorStuct(new Vector3(0.8f, 0.8f, 0.8f), Vector3.one), 0.5f, -1);

            while (!b.animationFinished)
            {
                yield return(null);
            }
        }
    }
Esempio n. 10
0
    public AnimationBeing CreateRectTransformLocalPositionAnimation(RectTransform rectTransform,
                                                                    Vector3 initial, Vector3 target, AnimationType animType, float duration, int direction = 1, bool loop = false)
    {
        AnimationBeingTargetField t = new AnimationBeingTargetField();

        t.SetAnimationVectorStruct(new AnimationVectorStuct(initial, target));

        System.Action <GameObject, AnimationBeingTargetField, float> func = null;
        func = (GameObject obj, AnimationBeingTargetField field, float alpha) =>
        {
            //Vector3 res = t.GetAnimationVectorStruct().initial * (1 - alpha) + t.GetAnimationVectorStruct().target * alpha;
            obj.GetComponent <RectTransform>().localPosition = field.GetAnimationVectorStruct().initial *(1 - alpha) +
                                                               field.GetAnimationVectorStruct().target *alpha;

            //material.SetFloat(property, alpha);
        };

        //animation being creation
        AnimationBeing being = new AnimationBeing(rectTransform.gameObject, func, duration, direction);

        being.SetLoop(loop);
        being.CreateAnimationBeingTargetAndInitializeDefaultValue(t.GetAnimationVectorStruct());

        switch (animType)
        {
        case AnimationType.Parallel:
            Debug.Log("Created");
            animationBeingsParallel.Add(being);
            break;

        case AnimationType.Serial:
            animationBeingsSequence.Add(being);
            break;
        }
        return(being);
    }
Esempio n. 11
0
 //TODO: Implement dispose functionality
 void DeleteAnimationBeing(AnimationBeing being)
 {
     //Destroy(being);
 }
Esempio n. 12
0
 public void Blink()
 {
     //blinkRoutine = StartCoroutine(BlinkRoutine());
     being = PanelAnimator.Instance.CreateScaleAnim(gameObject, new Vector3(0.8f, 0.8f, 0.8f), Vector3.one, AnimationType.Parallel, 0.8f, 1, true);
 }
Esempio n. 13
0
 void CreateMaterialAnimationFunction()
 {
     being = PanelAnimator.Instance.CreateMaterialAnimation(gameObject, material, "_Transparency", AnimationType.Parallel, 1, 1, true);
     Invoke("Stop", 10);
 }