Пример #1
0
    void SetPosition(bool isMotion)
    {
        //print ("SetPosition");
        //print ("isMotion="+isMotion);

        Vector3 pos = mLocalPosition;

        //print ("pos1="+pos);

        //print ("seq="+seq);


        pos += new Vector3(0f, seq * cellHeight, 0f);
        //print ("pos2="+pos);

        //pos -= new Vector3(0f, 300f, 0f);
        if (isMotion)
        {
            //print ("if isMotion");

            TweenParms parms = new TweenParms();
            parms.Prop("localPosition", pos);
            parms.Ease(EaseType.EaseOutCirc);
            HOTween.To(mTrans, 0.1f, parms);
            HOTween.Play();
        }
        else
        {
            //print ("else isMotion");

            mTrans.localPosition = pos;
        }
        //titleLabel.text = heros[seq].spriteName;
    }
Пример #2
0
 //resumes the current tween and tries to play the walk animation
 public void Resume()
 {
     //unblock further tween execution in NextWaypoint()
     waiting = false;
     //resume tweener
     HOTween.Play(transform);
     //play walk animation
     PlayWalk();
 }
Пример #3
0
        public override void OnEnter()
        {
            if (playType == PlayType.playForward)
            {
                HOTween.PlayForward(tweenID.Value);
            }
            else if (playType == PlayType.playBackward)
            {
                HOTween.PlayBackwards(tweenID.Value);
            }
            else
            {
                HOTween.Play(tweenID.Value);
            }

            Finish();
        }
Пример #4
0
    IEnumerator HideMenu()
    {
        Time.timeScale = 1; HOTween.Play();

        TweenParms parms = new TweenParms().Prop("position", new Vector3(_PausedBackground.transform.position.x, 16, -5)).Ease(EaseType.EaseOutQuart);

        HOTween.To(_PausedBackground.transform, 0.6f, parms).WaitForCompletion();

        parms = new TweenParms().Prop("position", new Vector3(_PlayButton.transform.position.x, 16, -6)).Ease(EaseType.EaseOutQuart);
        HOTween.To(_PlayButton.transform, 0.4f, parms).WaitForCompletion();
        audio.Play();

        parms = new TweenParms().Prop("position", new Vector3(_ReloadButton.transform.position.x, 16, -6)).Ease(EaseType.EaseOutQuart);
        HOTween.To(_ReloadButton.transform, 0.5f, parms).WaitForCompletion();


        parms = new TweenParms().Prop("position", new Vector3(_MenuButton.transform.position.x, 16, -6)).Ease(EaseType.EaseOutQuart);
        yield return(StartCoroutine(HOTween.To(_MenuButton.transform, 0.2f, parms).WaitForCompletion()));

        isPaused = false;
    }
Пример #5
0
    void OnGUI()
    {
        DGUtils.BeginGUI();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Play"))
        {
            HOTween.Play();
        }
        if (GUILayout.Button("Pause"))
        {
            HOTween.Pause();
        }
        if (GUILayout.Button("Kill"))
        {
            HOTween.Kill();
        }
        GUILayout.EndHorizontal();

        DGUtils.EndGUI();
    }
Пример #6
0
    // Set current table position;
    void SetPosition(bool isMotion)
    {
        Vector3 pos = mLocalPosition;

        pos -= new Vector3(seq * cellWidth, 0f, 0f);
        if (isMotion)
        {
            TweenParms parms = new TweenParms();
            parms.Prop("localPosition", pos);
            parms.Ease(EaseType.Linear);
            HOTween.To(mTrans, 0.1f, parms);
            HOTween.Play();
        }
        else
        {
            mTrans.localPosition = pos;
        }
        if (titleLabel != null)
        {
            titleLabel.text = heros[seq].spriteName;
        }
    }
Пример #7
0
        // ===================================================================================
        // UNITY METHODS ---------------------------------------------------------------------

        override public void OnInspectorGUI()
        {
            HOGUIStyle.InitGUI();

            EditorGUIUtility.LookLikeControls(_labelsWidth, _fieldsWidth);

            GUILayout.Space(4);
#if MICRO
            GUILayout.Label("HOTweenMicro v" + HOTween.VERSION);
#else
            GUILayout.Label("HOTween v" + HOTween.VERSION);
#endif
            GUILayout.Space(4);

            TweenInfo[] twInfos = HOTween.GetTweenInfos();
            if (twInfos == null)
            {
                GUILayout.Label("No tweens");
                return;
            }

            // Store and display tot running/paused/disabled tweens.
            int totTweens = twInfos.Length;
            List <TweenInfo> runningTweens   = new List <TweenInfo>();
            List <TweenInfo> pausedTweens    = new List <TweenInfo>();
            List <TweenInfo> completedTweens = new List <TweenInfo>();
            List <TweenInfo> disabledTweens  = new List <TweenInfo>();
            foreach (TweenInfo twInfo in twInfos)
            {
                if (!twInfo.isEnabled)
                {
                    disabledTweens.Add(twInfo);
                }
                else if (twInfo.isComplete)
                {
                    completedTweens.Add(twInfo);
                }
                else if (twInfo.isPaused)
                {
                    pausedTweens.Add(twInfo);
                }
                else
                {
                    runningTweens.Add(twInfo);
                }
            }
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Tweens (tot - running/paused/completed/disabled):\n" + totTweens + " - " + runningTweens.Count + "/" + "/" + pausedTweens.Count + "/" + completedTweens.Count + "/" + disabledTweens.Count);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Draw play/pause/kill all buttons
            GUILayout.Space(4);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Play All", HOGUIStyle.BtTinyStyle, GUILayout.Width(76)))
            {
                HOTween.Play();
            }
            if (GUILayout.Button("Pause All", HOGUIStyle.BtTinyStyle, GUILayout.Width(76)))
            {
                HOTween.Pause();
            }
            if (GUILayout.Button("Complete All", HOGUIStyle.BtTinyStyle, GUILayout.Width(86)))
            {
                HOTween.Complete();
            }
            if (GUILayout.Button("Kill All", HOGUIStyle.BtTinyStyle, GUILayout.Width(76)))
            {
                HOTween.Kill();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Display data for each tween (divided by running/paused/completed/disabled)
            for (int i = 0; i < 4; ++i)
            {
                TweenGroup       twGroup;
                List <TweenInfo> targetInfos;
                string           groupLabel;
                switch (i)
                {
                case 0:
                    twGroup     = TweenGroup.Running;
                    targetInfos = runningTweens;
                    groupLabel  = "Running";
                    break;

                case 1:
                    twGroup     = TweenGroup.Paused;
                    targetInfos = pausedTweens;
                    groupLabel  = "Paused";
                    break;

                case 2:
                    twGroup     = TweenGroup.Completed;
                    targetInfos = completedTweens;
                    groupLabel  = "Completed but not killed";
                    break;

                default:
                    twGroup     = TweenGroup.Disabled;
                    targetInfos = disabledTweens;
                    groupLabel  = "Disabled";
                    break;
                }

                if (targetInfos.Count == 0)
                {
                    continue;
                }
                GUILayout.Space(8);
                GUILayout.BeginVertical(HOGUIStyle.BoxStyleRegular);
                GUILayout.BeginHorizontal();
                GUILayout.Label(groupLabel + " Tweens (" + targetInfos.Count + ")", HOGUIStyle.TitleStyle, GUILayout.ExpandWidth(false));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Click a target to select it");
                GUILayout.EndHorizontal();
                GUILayout.Space(6);
                foreach (TweenInfo twInfo in targetInfos)
                {
                    GUILayout.BeginVertical(GUI.skin.box);
                    if (twInfo.isSequence)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("[Sequence]", HOGUIStyle.LabelSmallStyle);
                        if (twGroup != TweenGroup.Disabled)
                        {
                            DrawTargetButtons(twInfo, twGroup);
                        }
                        GUILayout.EndHorizontal();
                        DrawInfo(twInfo);
                        foreach (object twTarget in twInfo.targets)
                        {
                            DrawTarget(twInfo, twTarget, twGroup, true);
                        }
                    }
                    else
                    {
                        DrawTarget(twInfo, twInfo.targets[0], twGroup, false);
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndVertical();
            }
        }
Пример #8
0
    /// <summary>
    /// Creates a tween based on the given tweenData and returns it,
    /// or returns <code>null</code> if the tween was empty.
    /// </summary>
    /// <param name="p_twData">
    /// A <see cref="HOTweenData"/>
    /// </param>
    public static Holoville.HOTween.Tweener CreateTween(HOTweenData p_twData, float p_globalDelay, float p_globalTimeScale)
    {
        if (p_twData.propDatas.Count == 0 || !p_twData.isActive)
        {
            return(null);
        }

        TweenParms parms = new TweenParms()
                           .Delay(p_twData.delay + p_globalDelay)
                           .Id(p_twData.id)
                           .Loops(p_twData.loops, p_twData.loopType)
                           .UpdateType(p_twData.updateType)
                           .Ease(p_twData.easeType)
                           .TimeScale(p_twData.timeScale * p_globalTimeScale)
                           .AutoKill(p_twData.autoKill)
                           .Pause(p_twData.paused);

        if (p_twData.easeType == EaseType.AnimationCurve)
        {
            parms.Ease(p_twData.animationCurve);
        }
        else
        {
            parms.Ease(p_twData.easeType);
        }

        // Eventual onComplete
        if (p_twData.onCompleteActionType != HOTweenData.OnCompleteActionType.None)
        {
            switch (p_twData.onCompleteActionType)
            {
            case HOTweenData.OnCompleteActionType.PlayAll:
                parms.OnComplete(() => HOTween.Play());
                break;

            case HOTweenData.OnCompleteActionType.PlayTweensById:
                parms.OnComplete(() => HOTween.Play(p_twData.onCompletePlayId));
                break;

            case HOTweenData.OnCompleteActionType.RestartTweensById:
                parms.OnComplete(() => HOTween.Restart(p_twData.onCompletePlayId));
                break;

            case HOTweenData.OnCompleteActionType.SendMessage:
                if (p_twData.onCompleteTarget == null || p_twData.onCompleteMethodName == "")
                {
                    break;
                }
                object onCompleteParm = null;
                switch (p_twData.onCompleteParmType)
                {
                case HOTweenData.ParameterType.Color:
                    onCompleteParm = p_twData.onCompleteParmColor;
                    break;

                case HOTweenData.ParameterType.Number:
                    onCompleteParm = p_twData.onCompleteParmNumber;
                    break;

                case HOTweenData.ParameterType.Object:
                    onCompleteParm = p_twData.onCompleteParmObject;
                    break;

                case HOTweenData.ParameterType.Quaternion:
                    onCompleteParm = p_twData.onCompleteParmQuaternion;
                    break;

                case HOTweenData.ParameterType.Rect:
                    onCompleteParm = p_twData.onCompleteParmRect;
                    break;

                case HOTweenData.ParameterType.String:
                    onCompleteParm = p_twData.onCompleteParmString;
                    break;

                case HOTweenData.ParameterType.Vector2:
                    onCompleteParm = p_twData.onCompleteParmVector2;
                    break;

                case HOTweenData.ParameterType.Vector3:
                    onCompleteParm = p_twData.onCompleteParmVector3;
                    break;

                case HOTweenData.ParameterType.Vector4:
                    onCompleteParm = p_twData.onCompleteParmVector4;
                    break;
                }
                parms.OnComplete(p_twData.onCompleteTarget, p_twData.onCompleteMethodName, onCompleteParm);
                break;
            }
        }

        foreach (HOPropData propData in p_twData.propDatas)
        {
            if (propData.isActive)
            {
                parms.Prop(propData.propName, Activator.CreateInstance(propData.pluginType, propData.endVal, propData.isRelative));
            }
        }
        if (!parms.hasProps)
        {
            return(null);
        }

        if (p_twData.tweenFrom)
        {
            return(HOTween.From(p_twData.target, p_twData.duration, parms));
        }
        return(HOTween.To(p_twData.target, p_twData.duration, parms));
    }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }



        //Detecting if the player clicked on the left mouse button and also if there is no animation playing
        if (Input.GetButtonDown("Fire1"))
        {
            //The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            if (hit.transform != null)
            {
                if (hit.transform.gameObject.name == _MenuButton.name)
                {
                    GetComponent <AudioSource>().PlayOneShot(MenuSound);
                    hit.transform.localScale = new Vector3(1.1f, 1.1f, 0);
                    Application.LoadLevel("MainMenu");
                }

                if (hit.transform.gameObject.name == _ReloadButton.name)
                {
                    GetComponent <AudioSource>().PlayOneShot(MenuSound);
                    Time.timeScale = 1;
                    isPaused       = false;
                    HOTween.Play();
                    hit.transform.localScale = new Vector3(1.1f, 1.1f, 0);
                    Application.LoadLevel(Application.loadedLevelName);
                }
                if (hit.transform.gameObject.name == _PauseButton.name && !isPaused && !isCountingDown && !isEnded && HOTween.GetTweenersByTarget(_PlayButton.transform, false).Count == 0 && HOTween.GetTweenersByTarget(_MenuButton.transform, false).Count == 0)
                {
                    GetComponent <AudioSource>().PlayOneShot(MenuSound);
                    StartCoroutine(ShowMenu());
                    hit.transform.localScale = new Vector3(1.1f, 1.1f, 0);
                }
                else if ((hit.transform.gameObject.name == _PauseButton.name || hit.transform.gameObject.name == _PlayButton.name) && !isEnded && !isCountingDown && isPaused && HOTween.GetTweenersByTarget(_PlayButton.transform, false).Count == 0 && HOTween.GetTweenersByTarget(_MenuButton.transform, false).Count == 0)
                {
                    GetComponent <AudioSource>().PlayOneShot(MenuSound);
                    StartCoroutine(HideMenu());
                    hit.transform.localScale = new Vector3(1f, 1f, 0);
                }
                else if ((hit.transform.gameObject.name == _TestScore.name) && !isEnded && !isCountingDown && !isPaused)
                {
                    GetComponent <AudioSource>().PlayOneShot(MenuSound);
                    _scoreTotal += _scoreIncrement;
                    UpdateLevel(20 * _scoreIncrement);
                    Util.ButtonPressAnimation(hit.transform.gameObject);
                }
                else if ((hit.transform.gameObject.name == _TestLevelEnd.name) && !isEnded && !isCountingDown && !isPaused)
                {
                    isEnded  = true;
                    isPaused = true;
                    StartCoroutine(ShowBoardScore());
                    Util.ButtonPressAnimation(hit.transform.gameObject);
                    //Update the Level
                    UpdateReachedLevel();
                }
            }
        }
        if (isPaused)
        {
            return;
        }

        if (!isPaused)
        {
            timing  += 0.001f;
            progress = (float)(timing * _timerCoef);
            _Time.transform.localScale = new Vector3(Mathf.Clamp01(progress), _Time.transform.localScale.y, 0);
        }
        if (Mathf.Clamp01(progress) >= 1)
        {
            isEnded  = true;
            isPaused = true;
            TweenParms parms = new TweenParms().Prop("position", new Vector3(_TimeIsUp.transform.position.x, -0.85f, -6)).Ease(EaseType.EaseOutQuart);
            HOTween.To(_TimeIsUp.transform, 0.5f, parms).WaitForCompletion();
            StartCoroutine(ShowBoardScore());
        }
        //Update the score
        (GetComponent(typeof(TextMesh)) as TextMesh).text = _scoreTotal.ToString();
        if (PlayerPrefs.GetInt("HighScore") < _scoreTotal && !_BestScoreReached)
        {
            _BestScoreReached = true;
        }
        if (PlayerPrefs.GetInt("HighLevel") < level && !_BestLevelReached)
        {
            _BestLevelReached = true;
        }
    }