Пример #1
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));
    }
Пример #2
0
        private void Move(bool toRight)
        {
            NormalizePictureScale(true);

            HOTween.Complete();

            foreach (var pic in _pictureArray)
            {
                pic.gameObject.SetActive(true);
            }

            var pic0NewPos = toRight ? _centerPos : _rightPos;
            var pic1NewPos = toRight ? _rightPos : _leftPos;
            var pic2NewPos = toRight ? _leftPos : _centerPos;

            HOTween.To(_pictureArray[0].transform, MoveDurationTime, "localPosition", pic0NewPos);
            HOTween.To(_pictureArray[1].transform, MoveDurationTime, "localPosition", pic1NewPos);
            HOTween.To(_pictureArray[2].transform, MoveDurationTime, "localPosition", pic2NewPos);

            if (Vector3.Distance(pic0NewPos, _rightPos) < 1)
            {
                _pictureArray[0].gameObject.SetActive(false);
            }
            if (Vector3.Distance(pic2NewPos, _leftPos) < 1)
            {
                _pictureArray[2].gameObject.SetActive(false);
            }

            var currentPictureArray = new tk2dSprite[_pictureArray.Length];

            for (var i = 0; i < _pictureArray.Length; i++)
            {
                currentPictureArray[i] = _pictureArray[i];
            }

            _pictureArray[0] = toRight ? currentPictureArray[2] : currentPictureArray[1];
            _pictureArray[1] = toRight ? currentPictureArray[0] : currentPictureArray[2];
            _pictureArray[2] = toRight ? currentPictureArray[1] : currentPictureArray[0];


            _currentPictureIndex = _currentPictureIndex + (toRight ? -1 : 1);
            if (_currentPictureIndex < 0)
            {
                _currentPictureIndex = _pictureList.Count - 1;
            }
            if (_currentPictureIndex == _pictureList.Count)
            {
                _currentPictureIndex = 0;
            }


            var param = new TweenParms();

            param.Prop("scale", _pictureNormalScale * _showScaleFactor);
            param.OnComplete(() => { HOTween.To(_pictureArray[1], MoveDurationTime / 2, "scale", _pictureNormalScale); NormalizePictureScale(false); });

            HOTween.To(_pictureArray[1], MoveDurationTime / 2, param);

            UpdatePictureSprites();
            UpdatePotChars(false);
        }
Пример #3
0
    public bool tryRemoveCompletedCards()
    {
        bool hasComp   = false;
        bool isLinked  = true;
        int  memoryNum = 1;

        if (pokerArr.Count >= 13)
        {
            Poker first = getLastPoker().GetComponent <Poker> ();
            if (first.num == 1)
            {
                string startType = first._type;
                for (int i = pokerArr.Count - 2; i >= 0; i--)
                {
                    GameObject go = pokerArr [i] as GameObject;
                    Poker      p  = go.GetComponent <Poker>();
                    if (p.num == memoryNum + 1 && p._type.Equals(startType))
                    {
                        if (memoryNum == 12)
                        {
                            break;
                        }
                        memoryNum++;
                    }
                    else
                    {
                        isLinked = false;
                        break;
                    }
                }

                if (isLinked)
                {
                    hasComp = true;
                    int d_time = 0;
                    Game.isRemoving = true;
                    for (int i = pokerArr.Count - 1; i > pokerArr.Count - 14; i--)
                    {
                        d_time++;
                        GameObject go = pokerArr [i] as GameObject;
                        // C#
                        TweenParms parms = new TweenParms();

                        Vector3 pos;                        // = new Vector3(Game.baseX+Game.game_wid - Game.card_wid/2.0f-Game.start_x,Game.baseY-Game.card_hei/2.0f-Game.start_y+Game.hei_750-Game.back_next_dis_normal/2.0f*Game.completedCount*Game.card_scale,go.transform.position.z);

                        pos = new Vector3(Game.complete_glow.transform.position.x, Game.complete_glow.transform.position.y - Game.back_next_dis_normal / 2.0f * Game.completedCount * Game.card_scale, Game.complete_glow.transform.position.z);
                        parms.Prop("position", pos);                        // Position tween
                        parms.Ease(EaseType.Linear);                        // Easing type
                        parms.Delay(((float)d_time) * 0.05f);               // Initial delay

                        if (i == pokerArr.Count - 13)
                        {
                            parms.OnComplete(comp, 1, go);
                        }
                        else
                        {
                            parms.OnComplete(comp, 0, go);
                        }

                        HOTween.To(go.transform, 0.15f, parms);
                    }

                    int removeNum = 13;

                    while (removeNum != 0)
                    {
                        removeNum--;

                        pokerArr.RemoveAt(pokerArr.Count - 1);
                    }

                    Game.completedCount++;
                }
            }
        }

        return(hasComp);
    }
        //creates a new HOTween tween with give arguments that moves along the path
        private void CreateTween()
        {
            //prepare HOTween's parameters, you can look them up here
            //http://www.holoville.com/hotween/documentation.html

            //create new plugin for curved paths
            //pass in array of Vector3 waypoint positions, relative = true
            plugPath = new PlugVector3Path(waypoints, true, pathType);

            //orients the tween target along the path
            if (orientToPath)
            {
                plugPath.OrientToPath(lookAhead, lockAxis);
            }

            //lock position axis, if set
            if (lockPosition != Holoville.HOTween.Axis.None)
            {
                plugPath.LockPosition(lockPosition);
            }

            //create a closed loop, if set
            if (loopType == LoopType.loop && closeLoop)
            {
                plugPath.ClosePath(true);
            }

            //create TweenParms for storing HOTween's parameters
            tParms = new TweenParms();
            //sets the path plugin as tween position property
            tParms.Prop("position", plugPath);

            //additional tween parameters
            tParms.AutoKill(false);
            tParms.Loops(1);
            if (!moveToPath)
            {
                tParms.OnComplete(ReachedEnd);
            }

            //differ between TimeValue, use speed with linear easing
            //or time based tweening with an animation easetype
            if (timeValue == TimeValue.speed)
            {
                tParms.SpeedBased();
                tParms.Ease(EaseType.Linear);
            }
            else
            {
                //use time in seconds and the chosen easetype
                if (easeType == Holoville.HOTween.EaseType.AnimationCurve)
                {
                    tParms.Ease(animEaseType);
                }
                else
                {
                    tParms.Ease(easeType);
                }
            }

            //finally create the tween
            tween = HOTween.To(transform, originSpeed, tParms);

            //continue new tween with adjusted speed if it was changed before
            if (originSpeed != speed)
            {
                ChangeSpeed(speed);
            }
        }
Пример #5
0
        private void MoveStart(Vector2Int coordinate)
        {
            VTile startTile = Global.mapSearch.GetTile(this.currentMCharacter.coordinate);
            VTile endTile   = Global.mapSearch.GetTile(coordinate);

            //cBattlefield.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
            Holoville.HOTween.Core.TweenDelegate.TweenCallback moveComplete;
            if (battleMode == Model.BattleMode.move_after_attack)
            {
                moveComplete = () =>
                {
                    this.currentMCharacter.coordinate.y = endTile.coordinate.y;
                    this.currentMCharacter.coordinate.x = endTile.coordinate.x;
                    //cBattle.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
                    App.Util.AppManager.CurrentScene.StartCoroutine(ActionOverNext());
                };
            }
            else
            {
                moveComplete = () =>
                {
                    currentVCharacter.action = Model.ActionType.idle;
                    this.tilesManager.ClearCurrentTiles();
                    battleMode = Model.BattleMode.move_end;
                    this.currentMCharacter.coordinate.y = endTile.coordinate.y;
                    this.currentMCharacter.coordinate.x = endTile.coordinate.x;

                    /*
                     * cBattlefield.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
                     */
                    this.tilesManager.ShowCharacterSkillArea(this.currentMCharacter);
                    Global.battleEvent.DispatchEventOperatingMenu(true);
                };
            }
            List <VTile> tiles = Global.aStar.Search(currentMCharacter, startTile, endTile);

            this.currentMCharacter.roadLength = tiles.Count;
            if (tiles.Count > 0)
            {
                Global.battleEvent.DispatchEventOperatingMenu(false);
                this.tilesManager.ClearCurrentTiles();
                currentVCharacter.action = Model.ActionType.move;
                battleMode = Model.BattleMode.moving;
                Sequence sequence = new Sequence();
                foreach (VTile tile in tiles)
                {
                    TweenParms tweenParms = new TweenParms()
                                            .Prop("X", tile.transform.localPosition.x, false)
                                            .Prop("Y", tile.transform.localPosition.y, false)
                                            .Ease(EaseType.Linear);
                    if (tile.coordinate.Equals(endTile.coordinate))
                    {
                        tweenParms.OnComplete(moveComplete);
                    }
                    sequence.Append(HOTween.To(currentVCharacter, 0.5f, tweenParms));
                }
                sequence.Play();
            }
            else
            {
                moveComplete();
            }
        }