Exemplo n.º 1
0
    /// <summary>
    /// 开始走 转过去的回调
    /// </summary>
    /// <param name="args"></param>
    private void OnRotate1Complete(object args)
    {
        var   temp     = (object[])args;
        var   to       = (Vector2)temp[1];
        var   from     = (Vector2)temp[0];
        Tween move_pos = m_TweenPlayer.AddClip("move", Config.RotateTime);

        move_pos.SetTweenType(TweenType.LocalPosition);
        move_pos.SetTo(new Vector3((to.x - 1) * Config.PieceWidth, 0, (to.y - 1) * Config.PieceWidth));
        var steps = CalMoveSteps(from, to);

        move_pos.SetDuration(steps * Config.MoveStepTime);
        move_pos.SetOnComplete(OnRotate2, temp);
        m_TweenPlayer.StartPlay();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 自己走棋
    /// </summary>
    /// <param name="to"></param>
    private void ShowMove(object[] args)
    {
        var eatPiece = ((Vector2)args[2]).y;
        var to       = (Vector2)args[1];
        var from     = (Vector2)args[0];

        var dx         = to.x - from.x;
        var dy         = to.y - from.y;
        var angle      = GetAngleByDeltaXY(dx, dy);
        var localAngle = (angle) % 360;

        if (m_TweenPlayer == null)
        {
            m_TweenPlayer = gameObject.AddComponent <TweenPlayer>();
        }

        if (m_ModelTween == null)
        {
            m_ModelTween = pieceModel.AddComponent <TweenPlayer>();
        }

        //有棋子播放攻击表现
        if (eatPiece >= 0)
        {
            Tween rotate_start = m_ModelTween.AddClip("rotate_start", Config.RotateTime);
            rotate_start.SetTweenType(TweenType.LocalRotation);
            rotate_start.SetTo(new Vector3(0, localAngle, 0));
            rotate_start.SetOnComplete(ShowAttack, args);
            m_ModelTween.StartPlay();
        }

        //没有棋子直接走
        else
        {
            Debug.Log("localAngel==============" + localAngle);
            Tween rotate_start = m_ModelTween.AddClip("rotate_start", Config.RotateTime);
            rotate_start.SetTweenType(TweenType.LocalRotation);
            rotate_start.SetTo(new Vector3(0, localAngle, 0));
            rotate_start.SetOnComplete(OnRotate1Complete, args);
            m_ModelTween.StartPlay();
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 远程攻击
    /// </summary>
    /// <param name="effectName"></param>
    /// <param name="to"></param>
    private void OnRemoteAttack(string effectName, object[] args)
    {
        var to   = (Vector2)args[1];
        var from = (Vector2)args[0];

        if (m_pieceAnimator == null)
        {
            m_pieceAnimator = pieceModel.GetComponent <Animator>();
        }
        m_pieceAnimator.Play("Attack");

        EffectPlayer effectPlayer = App.EffectManager.LoadEffect(m_Attack, effectName);

        effectPlayer.IsOnce = true;

        TweenPlayer m_AttackPlayer = m_Attack.AddComponent <TweenPlayer>();
        var         steps          = CalMoveSteps(from, to);
        Tween       attackTween    = m_AttackPlayer.AddClip("attack", steps * Config.AttackStepTime);

        attackTween.SetTweenType(TweenType.LocalPosition);
        attackTween.SetDelayTime(0.8f);
        attackTween.SetOnComplete(OnRemoteAttackComplete, args);

        App.SoundManager.PlaySoundClip(Config.Sound.MagicAttack, 0.6f);

        var dx = Config.PieceWidth * (to.x - m_X);
        var dy = Config.PieceWidth * (to.y - m_Z);

        attackTween.SetTo(new Vector3(dx, m_Attack.transform.localPosition.y, dy));
        var angle      = GetAngleByDeltaXY(dx, dy);
        var localAngle = (angle) % 360;

        m_AttackPlayer.gameObject.transform.rotation = Quaternion.Euler(0, localAngle, 0);
        //if (pieceColor == Config.PieceColor.WHITE)
        //{
        //    effectPlayer.LocalRotation = Quaternion.Euler(0, 180, 0);
        //}
        effectPlayer.enabled = true;
        m_AttackPlayer.StartPlay();
    }