Exemple #1
0
    //deprecated
    public void FlipFinal(float delay = 0f, bool withAnimation = true)
    {
        /*
         #region NEW_ADD
         * int sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().buildIndex;
         * if (sceneIndex != (int)EScene.SCENE_Demo) {
         *      return;
         * }
         #endregion
         */
        Vector3 oldPos = transform.position;

        if (withAnimation)
        {
            _flipActionList.Clear();

            FiniteTimeAction delayTime = null;
            if (delay > 0f)
            {
                delayTime = DelayTime.Create(delay);
            }

            //上移
            FiniteTimeAction mby = MoveBy.Create(0.2f, Vector3.up * 10f);
            //翻过来
            FiniteTimeAction mbt1 = RotateBy.Create(0.2f, Vector3.forward, 180f, Space.Self);
            //下移到原来的地方
            FiniteTimeAction mbt2 = MoveTo.Create(0.2f, oldPos);

            FiniteTimeAction mbt3 = MoveTo.Create(0.2f, Vector3.up * 5f);
            FiniteTimeAction mbt4 = RotateTo.Create(0.2f, Vector3.zero);

            FiniteTimeAction mbt5 = InvokeAction.Create(delegate(GameObject target, object userdata) {
                //TableController.Instance.SetCurrentPlayedTile (this);
            });
            if (delayTime != null)
            {
                _flipActionList.Add(delayTime);
            }
            _flipActionList.Add(mby);
            _flipActionList.Add(mbt1);
            _flipActionList.Add(mbt2);
            _flipActionList.Add(mbt3);
            _flipActionList.Add(mbt4);
            _flipActionList.Add(mbt5);
            ActionManager.Instance.RunAction(gameObject, _flipActionList);
        }
        else
        {
            //transform.Rotate (Vector3.forward, 180f, Space.Self);
            transform.rotation = Quaternion.identity;
            transform.position = Vector3.up * 5f;
            //TableController.Instance.SetCurrentPlayedTile (this);
        }
    }
Exemple #2
0
    public void Insert(Vector3 dstPosition, bool isLocal = false)
    {
        _insertActionList.Clear();
        FiniteTimeAction mby  = MoveBy.Create(0.1f, Vector3.up * MahjongTile.Thickness, isLocal);
        FiniteTimeAction mbt1 = MoveTo.Create(0.2f, dstPosition + Vector3.up * MahjongTile.Thickness, isLocal);
        FiniteTimeAction mbt2 = MoveTo.Create(0.1f, dstPosition, isLocal);

        _insertActionList.Add(mby);
        _insertActionList.Add(mbt1);
        _insertActionList.Add(mbt2);
        ActionManager.Instance.RunAction(gameObject, _insertActionList);
    }
Exemple #3
0
    //deprecated
    public void Flip(float delay = 0f, bool withAnimation = true)
    {
        /*
         #region NEW_ADD
         * int sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().buildIndex;
         * if (sceneIndex != (int)EScene.SCENE_Demo) {
         *      return;
         * }
         #endregion
         */
        Vector3 oldPos = transform.position;

        if (withAnimation)
        {
            _flipActionList.Clear();

            FiniteTimeAction delayTime = null;
            if (delay > 0f)
            {
                delayTime = DelayTime.Create(delay);
            }

            //上移
            FiniteTimeAction mby = MoveBy.Create(0.2f, Vector3.up * 10f);
            //翻过来
            FiniteTimeAction mbt1 = RotateBy.Create(0.2f, Vector3.forward, 180f, Space.Self);
            //下移到原来的地方
            FiniteTimeAction mbt2 = MoveTo.Create(0.2f, oldPos);
            if (delayTime != null)
            {
                _flipActionList.Add(delayTime);
            }
            _flipActionList.Add(mby);
            _flipActionList.Add(mbt1);
            _flipActionList.Add(mbt2);
            ActionManager.Instance.RunAction(gameObject, _flipActionList);
        }
        else
        {
            transform.Rotate(Vector3.forward, 180f, Space.Self);
        }
    }
Exemple #4
0
    void CallFuncTest()
    {
        btn_text.text = "点击停止";
        var action = Sequence.Create(
            CallFunc.Create(CallBackO, "延时0.5秒"),
            DelayTime.Create(0.5f),
            CallFunc.Create(CallBackO, "图片移动"),
            MoveTo.Create(1f, 200, 100).InitSubjectTransform(image.transform),
            MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "颜色渐变"),
            ColorTo.Create(0.5f, 1, 0, 0, 1f).InitSubjectComponent(image),
            ColorTo.Create(0.5f, 0, 1, 0, 1f).InitSubjectComponent(image),
            ColorTo.Create(0.5f, 0, 0, 1, 1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "颜色reset"),
            ColorTo.Create(0.5f, 1, 1, 1, 1).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "渐隐"),
            FadeOut.Create(1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "渐出"),
            FadeIn.Create(1f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "1秒闪烁5次"),
            Blink.Create(1f, 5),
            CallFunc.Create(CallBackO, "二阶贝塞尔曲线"),
            BezierTo.Create(2.0f, new Vector3(200, 100, 0), new Vector3(-100, 50, 0), new Vector3(100, 80, 0)).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "移动回原点"),
            MoveTo.Create(1f, 0, 0).InitSubjectTransform(image.transform),
            CallFunc.Create(CallBackO, "边移动边放大"),
            Spawn.Create(MoveTo.Create(1.0f, 200, 100f), ScaleTo.Create(1.0f, 3.0f, 3.0f, 3.0f)),
            CallFunc.Create(CallBackO, "缩放位置回原位"),
            Spawn.Create(MoveTo.Create(1.0f, 0, 0), ScaleTo.Create(1.0f, 1f, 1f, 1f)),
            NumberBy.Create(2.0f, "数字跳跃,从100到200:{0:f2}", 100, 100).InitSubjectComponent(text),
            DelayTime.Create(0.5f),
            NumberTo.Create(2.0f, "数字跳跃,从200到0:{0:f2}", 200, 0).InitSubjectComponent(text),
            DelayTime.Create(0.5f),
            CallFunc.Create(CallBackO, "Image Filled"),
            FillAmountTo.Create(1.5f, 0f).InitSubjectComponent(image),
            FillAmountTo.Create(1.5f, 1.0f).InitSubjectComponent(image),
            CallFunc.Create(CallBackO, "reset"),
            CallFunc.Create(CallBackO, "旋转 放大2倍,复原。重复3次"),
            Repeat.Create(Spawn.Create(
                              RotationBy.Create(1.0f, 0, 0, 360f),
                              Sequence.Create(
                                  ScaleTo.Create(0.5f, 2.0f, 2.0f, 2.0f),
                                  ScaleTo.Create(0.5f, 1.0f, 1.0f, 1.0f))).InitSubjectTransform(image.transform), 3),
            ExtraAction.Create()
            );

        float toX        = 300f;
        var   easeAction = Sequence.Create(
            CallFunc.Create(CallBackO, "变速运动演示,图一正常,图二是变速运动"),
            DelayTime.Create(1f),
            CallFunc.Create(CallBackO, "当前变速是EaseIn"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseIn.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseIn.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),

            CallFunc.Create(CallBackO, "当前变速是EaseOut"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),

            CallFunc.Create(CallBackO, "当前变速是EaseInOut"),
            DelayTime.Create(0.5f),
            Spawn.Create(
                MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseInOut.Create(MoveBy.Create(1.0f, toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "复位"),
            Spawn.Create(
                MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image.transform),
                EaseInOut.Create(MoveBy.Create(1.0f, -toX, 0f, 0f).InitSubjectTransform(image2.transform), 3f)),
            CallFunc.Create(CallBackO, "变速运动未完待续"),
            DelayTime.Create(1f),
            ExtraAction.Create()
            );

        CCActionManager.Instance.AddAction(Sequence.Create(action, easeAction, CallFunc.Create(CallBackEnd)), transform);
    }
Exemple #5
0
    //deprecated later for lua
    IEnumerator shuffleAndInitPocket(/*GameInitPush? gip*/)
    {
        Debug.Log("!!!!!!!!!!!!!!!!!!!!!shuffleAndInitPocket");
        int a = 3;        //gip.Value.Dice (0);
        int b = 5;        //gip.Value.Dice (1);

        _shuffle_initpocket_state = 0;

        //UIControllerGame.Instance.SetPaiRestInfo (_wall.Count);
        //UIControllerGame.Instance.RefreshPaiRestInfo ();

        Transform dice = poolMahjongRes.Spawn("DiceGroup");

        ActionBase act = MoveBy.Create(1f, Vector3.down * MahjongTile.Height * 2);

        ActionManager.Instance.RunAction(_slot.gameObject, act);
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < _playPlayers.Length; ++i)
        {
            _players [i] = _playPlayers [i];
        }

        //hard code
        if (_playPlayers [_dealerIndex] == _self)
        {
            for (int i = 0; i < _playPlayers.Length; ++i)
            {
                if (_playPlayers [i] != _self)
                {
                    for (int j = 0; j < 13; ++j)
                    {
                        _playPlayers [i].Proxy.PocketList.Add(TileDef.Create());
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < _playPlayers.Length; ++i)
            {
                if (_playPlayers [i] != _self)
                {
                    if (i == _dealerIndex)
                    {
                        for (int j = 0; j < 14; ++j)
                        {
                            _playPlayers [j].Proxy.PocketList.Add(TileDef.Create());
                        }
                    }
                    else
                    {
                        for (int j = 0; j < 13; ++j)
                        {
                            _playPlayers [j].Proxy.PocketList.Add(TileDef.Create());
                        }
                    }
                }
            }
        }
        if (_playPlayers.Length == 3)
        {
            if (_players [0] == _self)
            {
                _players [3] = _players [2];
                _players [2] = _front;
            }
            else if (_players [1] == _self)
            {
                _players [3] = _front;
            }
            else if (_players [2] == _self)
            {
                _players [0] = _right;
                _players [1] = _front;
                _players [2] = _left;
                _players [3] = _self;
            }
        }

        //dealer and opposite dealer are 14 tons, others are 13tons
        _pile.RebuildStack(a, b, 108, 0, 0);
        int offset = _self.SetupStack(_pile, 0, 14 * 2);

        offset += _right.SetupStack(_pile, offset, 13 * 2);
        offset += _front.SetupStack(_pile, offset, 14 * 2);
        _left.SetupStack(_pile, offset, 13 * 2);

        act = MoveTo.Create(1f, _slotOriginal);
        ActionManager.Instance.RunAction(_slot.gameObject, act);

        yield return(new WaitForSeconds(1f));

        // dice sound
        //AudioManager.Instance.PlaySound (AudioManager.Instance.Tou_Zi);
        DiceController.Instance.ThrowDice(a, b);

        Debug.Log("******" + DiceController.Instance.DiceDone);

        yield return(new WaitUntil(() => DiceController.Instance.DiceDone == true));

        Debug.Log("Dice -> " + a + "," + b);

        for (int i = 0; i < 4; ++i)
        {
            _playPlayers [i].InitDraw(i == _dealerIndex);
        }

        //TableController.Instance.SetCurrentPlayer (GetPlayerDisplayIndex (_playPlayers [0]));

        // despawn dice
        poolMahjongRes.Despawn(dice, poolMahjongRes.transform);

        for (int i = 0; i < 4; ++i)
        {
            yield return(new WaitUntil(() => _playPlayers [i].InitDrawFinished == true));
        }

        _shuffle_initpocket_state = 1;

        //UIControllerGame.Instance.OpenRefreshButton ();

        Debug.Log("@shuffleAndInitPocket");
    }
Exemple #6
0
    // param id is a combo list
    public void Combo(TileDef def, int num, int flipNum = 0, bool withAnimation = true)
    {
        MahjongTile tile     = null;
        Vector3     localPos = Vector3.zero;

        if (ComboLocator.childCount > 0)
        {
            localPos = Vector3.zero - MahjongTile.Width * _direction * ComboLocator.childCount - MahjongTile.Width * _direction * 0.2f;
        }
        else
        {
            localPos = Vector3.zero;
        }

        for (int i = 0; i < num; ++i)
        {
            tile = MahjongTile.Create(def);
            tile.Reset();

            if (i < flipNum)
            {
                tile.Direction = MahjongTile.Face.PLANE_NEGTIVE;

                _angle = Vector3.Angle(Vector3.right, _direction);
                //Debug.Log (_angle + "    " + Vector3.right + "," + _direction);
                // unity3d bug from vector3.right to vector3.forward == 90 ?
                if (_direction == Vector3.forward)
                {
                    _angle = 270f;
                }
                tile.transform.Rotate(Vector3.up, _angle, Space.Self);
            }
            else
            {
                _angle = Vector3.Angle(Vector3.right, _direction);
                //Debug.Log (_angle + "    " + Vector3.right + "," + _direction);
                // unity3d bug from vector3.right to vector3.forward == 90 ?
                if (_direction == Vector3.forward)
                {
                    _angle = 270f;
                }
                tile.transform.Rotate(Vector3.up, _angle, Space.Self);
            }

            //往左偏移的起始位置
            tile.transform.parent        = ComboLocator;
            tile.transform.localPosition = localPos - i * MahjongTile.Width * _direction;

            if (withAnimation)
            {
                //再往左偏移一段位置从起始位置起 然后播放动画
                Vector3 localDstPosition = tile.transform.localPosition;
                tile.transform.localPosition = tile.transform.localPosition - _direction * MahjongTile.Width * 3f;

                ActionBase act = MoveTo.Create(0.2f, localDstPosition, true);
                ActionManager.Instance.RunAction(tile.gameObject, act);
            }
        }

        //Debug.Log (_comboLocator.transform.childCount);
    }
Exemple #7
0
    public void updatePocketPosition()
    {
        if (_direction != Vector3.right)
        {
            return;
        }

        float      duration = 0.2f;
        Vector3    to;
        ActionBase act   = null;
        int        count = PocketLocator.childCount;

        switch (count)
        {
        case 1:
        case 2:
        {
            to  = _originPocketPos + _direction * 7 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 3:
        case 4:
        {
            to  = _originPocketPos + _direction * 5 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 5:
        case 6:
        {
            to  = _originPocketPos + _direction * 4 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 7:
        case 8:
        {
            to  = _originPocketPos + _direction * 3 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 9:
        case 10:
        {
            to  = _originPocketPos + _direction * 2 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 11:
        case 12:
        {
            to  = _originPocketPos + _direction * 1 * MahjongTile.Width;
            act = MoveTo.Create(duration, to);
        }
        break;

        case 13:
        case 14:
            break;
        }

        if (act != null)
        {
            ActionManager.Instance.RunAction(PocketLocator.gameObject, act);
        }
    }
Exemple #8
0
    public void Moveto(Vector3 dstPosition, bool isLocal = false)
    {
        ActionBase mbt = MoveTo.Create(0.2f, dstPosition, isLocal);

        ActionManager.Instance.RunAction(gameObject, mbt);
    }