コード例 #1
0
 private void CrashAnim(bool play)
 {
     if (play)
     {
         if (crashState == null)
         {
             crashState = playerLado.animation.FadeIn("8_Moto(Batendo)", 0.1f, -1, 10, null, AnimationFadeOutMode.Single);
         }
         else
         {
             crashState.weight = 1;
             crashState.Play();
         }
         Debug.Log("Crash");
         state = State.MotoCrash;
     }
     else
     {
         if (crashState == null)
         {
             return;
         }
         else
         {
             crashState.weight = 0;
             crashState.Stop();
         }
     }
 }
コード例 #2
0
ファイル: MonsterModel.cs プロジェクト: tuyiherizon/XiaoChu2
    private IEnumerator PlayAttackAfter(DragonBones.AnimationState animState)
    {
        yield return(new WaitForSeconds(animState.totalTime));

        _DragonArmature.animation.timeScale = 1;
        PlayIdle();
    }
コード例 #3
0
        private void _animationEventHandler(string type, EventObject eventObject)
        {
            switch (type)
            {
            case EventObject.FADE_IN_COMPLETE:
                if (eventObject.animationState.name == "jump_1")
                {
                    _isJumpingB = true;
                    _speed.y    = -JUMP_SPEED;
                    _armatureComponent.animation.FadeIn("jump_2", -1, -1, 0, NORMAL_ANIMATION_GROUP);
                }
                else if (eventObject.animationState.name == "jump_4")
                {
                    _updateAnimation();
                }
                break;

            case EventObject.FADE_OUT_COMPLETE:
                if (eventObject.animationState.name == "attack_01")
                {
                    _isAttackingB = false;
                    _attackState  = null;
                }
                break;
            }
        }
コード例 #4
0
    protected override void OnStart()
    {
        // Load data
        UnityFactory.factory.LoadDragonBonesData("mecha_1406/mecha_1406_ske");
        UnityFactory.factory.LoadTextureAtlasData("mecha_1406/mecha_1406_tex");
        UnityFactory.factory.LoadDragonBonesData("floor_board/floor_board_ske");
        UnityFactory.factory.LoadTextureAtlasData("floor_board/floor_board_tex");
        // Build armature
        this._armatureComp   = UnityFactory.factory.BuildArmatureComponent("mecha_1406");
        this._floorBoardComp = UnityFactory.factory.BuildArmatureComponent("floor_board");
        // Get bone
        this._chestBone      = this._armatureComp.armature.GetBone("chest");
        this._leftFootBone   = this._armatureComp.armature.GetBone("foot_l");
        this._rightFootBone  = this._armatureComp.armature.GetBone("foot_r");
        this._circleBone     = this._floorBoardComp.armature.GetBone("circle");
        this._floorBoardBone = this._floorBoardComp.armature.GetBone("floor_board");
        // Play animation
        this._armatureComp.ArmAnimation.Play("idle");
        this._aimState             = this._armatureComp.ArmAnimation.FadeIn("aim", 0.1f, 1, 0, "aimGroup");
        this._aimState.resetToPose = false;
        this._aimState.Stop();
        //
        this._floorBoardComp.ArmAnimation.Play("idle");
        this._floorBoardComp.armature.GetSlot("player").display = this._armatureComp.gameObject;
        // Set localPosition
        this._armatureComp.transform.localPosition   = Vector3.zero;
        this._floorBoardComp.transform.localPosition = new Vector4(0.0f, -0.25f, 0.0f);

        //
        this._floorBoardComp.CloseCombineMeshs();

        //
        EnableDrag(this._floorBoardComp.armature.GetSlot("circle").display as GameObject);
    }
コード例 #5
0
    /**
     * 更新动画
     */
    private void _updateAnimation()
    {
        if (_curState == PlayerState.IDEL)
        {
            if (_idelState == null)
            {
                _idelState = _armatureComponent.animation.FadeIn("idle_1", -1.0f, -1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup);
            }

            if (_runState != null)
            {
//				_runState.Stop ();     //停止的话, 动作还是保持跑步的状态
                _runState.FadeOut(0.1f);                   //淡出动画
                _runState = null;
            }
        }
        else if (_curState == PlayerState.RUN)
        {
            if (_runState == null)
            {
                _runState           = _armatureComponent.animation.FadeIn("run_1", -1.0f, -1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup);
                _runState.timeScale = 1.2f;
            }

            if (_idelState != null)
            {
                _idelState.FadeOut(0.1f);
                _idelState = null;
            }
        }
        else
        {
        }
    }
コード例 #6
0
 public void JumpAnimation(bool isJump)
 {
     if (IsDead)
     {
         return;
     }
     if (IsJumping)
     {
         if (_jumpState.isCompleted)
         {
             IsJumping  = false;
             _jumpState = null;
             SetIdleAnimation();
             UpdateAnimation();
         }
         return;
     }
     if (!IsJumping && isJump)
     {
         IsJumping              = true;
         _jumpState             = _armatureComponent.animation.FadeIn("jump", -1.0f, -1, 0);
         _jumpState.resetToPose = false;
         _jumpState.playTimes   = 1;
         _walkState             = null;
     }
 }
コード例 #7
0
    static int RemoveBoneMask(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                obj.RemoveBoneMask(arg0);
                return(0);
            }
            else if (count == 3)
            {
                DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                bool   arg1 = LuaDLL.luaL_checkboolean(L, 3);
                obj.RemoveBoneMask(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.AnimationState.RemoveBoneMask"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #8
0
    private void ChutandoAnim(bool play)
    {
        if (play)
        {
            playerLado.animation.lastAnimationState.weight = 0;

            if (chuteState == null)
            {
                chuteState = playerLado.animation.FadeIn("3_Bicuda", 0.1f, -1, 4, null, AnimationFadeOutMode.None);
                chuteState.displayControl = true;
                chuteState.resetToPose    = true;
            }
            else
            {
                chuteState.displayControl = true;
                chuteState.weight         = 1;
                chuteState.Play();
            }
            state = State.Chutando;
        }
        else
        {
            if (chuteState == null)
            {
                return;
            }
            else
            {
                chuteState.displayControl = false;
                chuteState.Stop();
                chuteState.weight = 0;
            }
        }
    }
コード例 #9
0
    private void FallingAnim(bool play)
    {
        if (play)
        {
            playerLado.animation.lastAnimationState.weight = 0;

            if (fallState == null)
            {
                fallState = playerLado.animation.FadeIn("1_NoAr(2_Descendo)", 0.1f, -1, 20, null, AnimationFadeOutMode.Single);
                fallState.displayControl = false;
            }
            else
            {
                //fallState.displayControl = true;
                fallState.weight = 1;
                fallState.Play();
            }
            state = State.Falling;
        }
        else
        {
            if (fallState == null)
            {
                return;
            }
            else
            {
                fallState.displayControl = false;
                fallState.Stop();
                fallState.weight = 0;
            }
        }
    }
コード例 #10
0
    private void MotoWalkAnim(bool play)
    {
        if (play)
        {
            if (motoWalkState == null)
            {
                motoWalkState = playerLado.animation.FadeIn("8_Moto(Andando)", -1, -1, 21, null, AnimationFadeOutMode.Single);
            }
            else
            {
                motoWalkState.weight = 1f;
                motoWalkState.Play();
            }
            state = State.MotoWalk;
        }

        else
        {
            if (motoWalkState == null)
            {
                return;
            }
            else
            {
                motoWalkState.Stop();
                motoWalkState.weight = 0;
            }
        }
    }
コード例 #11
0
 private void MotoUpAnim(bool play)
 {
     if (play)
     {
         if (motoJumpState == null)
         {
             motoJumpState = playerLado.animation.FadeIn("8_Moto(SubindoNoAr)", -1, -1, 22, null, AnimationFadeOutMode.Single);
         }
         else
         {
             motoJumpState.weight = 1;
             motoJumpState.Play();
         }
         state = State.MotoUp;
     }
     else
     {
         if (motoJumpState == null)
         {
             return;
         }
         else
         {
             motoJumpState.Stop();
             motoJumpState.weight = 0;
         }
     }
 }
コード例 #12
0
 private void MotoFallAnim(bool play)
 {
     if (play)
     {
         if (motoFallState == null)
         {
             motoFallState = playerLado.animation.FadeIn("8_Moto(DescendoNoAr)", 0.1f, -1, 20, null, AnimationFadeOutMode.Single);
         }
         else
         {
             motoFallState.weight = 1;
             motoFallState.Play();
         }
         state = State.MotoDown;
     }
     else
     {
         if (motoFallState == null)
         {
             return;
         }
         else
         {
             motoFallState.Stop();
             motoFallState.weight = 0;
         }
     }
 }
コード例 #13
0
    private void MotoLandAnim(bool play)
    {
        if (play)
        {
            if (motoLandState == null)
            {
                motoLandState             = playerLado.animation.FadeIn("8_Moto(Aterrisando)", 0.1f, -1, 3, null, AnimationFadeOutMode.Single);
                motoLandState.resetToPose = true;
            }
            else
            {
                motoLandState.weight = 1;
                motoLandState.Play();
            }

            state = State.MotoLand;
        }
        else
        {
            if (motoLandState == null)
            {
                return;
            }
            else
            {
                motoLandState.Stop();
                motoLandState.weight = 0;
            }
        }
    }
コード例 #14
0
 private void ManobraAnim(bool play)
 {
     if (play)
     {
         if (trickState == null)
         {
             trickState             = playerLado.animation.FadeIn("8_Moto(Empinando)", 0.1f, -1, 4, null, AnimationFadeOutMode.Single);
             trickState.resetToPose = true;
         }
         else
         {
             trickState.weight = 1;
             trickState.Play();
         }
         state = State.MotoGrau;
     }
     else
     {
         if (trickState == null)
         {
             return;
         }
         else
         {
             trickState.Stop();
             trickState.weight = 0;
         }
     }
 }
コード例 #15
0
 static int FadeIn(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 11);
         DragonBones.Animation obj = (DragonBones.Animation)ToLua.CheckObject(L, 1, typeof(DragonBones.Animation));
         string arg0 = ToLua.CheckString(L, 2);
         float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
         int    arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
         int    arg3 = (int)LuaDLL.luaL_checknumber(L, 5);
         string arg4 = ToLua.CheckString(L, 6);
         DragonBones.AnimationFadeOutMode arg5 = (DragonBones.AnimationFadeOutMode)ToLua.CheckObject(L, 7, typeof(DragonBones.AnimationFadeOutMode));
         bool arg6 = LuaDLL.luaL_checkboolean(L, 8);
         bool arg7 = LuaDLL.luaL_checkboolean(L, 9);
         bool arg8 = LuaDLL.luaL_checkboolean(L, 10);
         bool arg9 = LuaDLL.luaL_checkboolean(L, 11);
         DragonBones.AnimationState o = obj.FadeIn(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #16
0
    private void WalkAnim(bool play)
    {
        if (play)
        {
            playerLado.animation.lastAnimationState.weight = 0;
            landParticles.WalkParticles();
            if (walkState == null)
            {
                walkState = playerLado.animation.FadeIn("0_Corrida_V2", -1, -1, 21, null, AnimationFadeOutMode.Single);
                walkState.displayControl = false;
            }
            else
            {
                //walkState.displayControl = true;
                walkState.weight = 1f;
                walkState.Play();
            }
            state = State.Walking;
        }

        else
        {
            landParticles.particleLoop.Stop();
            if (walkState == null)
            {
                return;
            }
            else
            {
                walkState.displayControl = false;
                walkState.Stop();
                walkState.weight = 0;
            }
        }
    }
コード例 #17
0
 private void UpdateAnimation()
 {
     if (IsDead == false)
     {
         if (IsJumping)
         {
             return;
         }
         if (IsAttack)
         {
             return;
         }
         if (MoveDirection == 0)
         {
             SetIdleAnimation();
         }
         else
         {
             if (_walkState == null)
             {
                 if (MoveDirection == -1 || MoveDirection == 1)
                 {
                     _walkState = _armatureComponent.animation.FadeIn("walk", -1.0f, -1, 0);
                     this._walkState.resetToPose = false;
                 }
                 else if (MoveDirection == 2)
                 {
                     _walkState = _armatureComponent.animation.FadeIn("walk_up", -1.0f, -1, 0);
                     this._walkState.resetToPose = false;
                 }
             }
         }
     }
 }
コード例 #18
0
    private void JumpAnim(bool play)
    {
        if (play)
        {
            playerLado.animation.lastAnimationState.weight = 0;
            landParticles.PlayLand();

            if (jumpState == null)
            {
                jumpState = playerLado.animation.FadeIn("1_NoAr(1_Subindo)", -1, -1, 22, null, AnimationFadeOutMode.Single);
                jumpState.displayControl = false;
            }
            else
            {
                //jumpState.displayControl = true;
                jumpState.weight = 1;
                jumpState.Play();
            }
            state = State.Rising;
        }
        else
        {
            if (jumpState == null)
            {
                return;
            }
            else
            {
                jumpState.displayControl = false;
                jumpState.Stop();
                jumpState.weight = 0;
            }
        }
    }
コード例 #19
0
 public void AttackAnimationGlobal(bool isAttack, ref bool isAttackType, string animationName)
 {
     if (IsDead)
     {
         return;
     }
     if (IsAttack && isAttackType)
     {
         if (_attackState.isCompleted)
         {
             IsAttack     = isAttackType = false;
             _attackState = null;
             SetIdleAnimation();
             UpdateAnimation();
         }
         return;
     }
     if (!IsAttack && isAttack)
     {
         IsAttack                 = isAttackType = true;
         _attackState             = _armatureComponent.animation.FadeIn(animationName, -1.0f, -1, 0);
         _attackState.resetToPose = false;
         _attackState.playTimes   = 1;
         _walkState               = null;
     }
 }
コード例 #20
0
    private void IdleAnim(bool play)
    {
        if (play)
        {
            landParticles.particleLoop.Stop();
            playerFrente.animation.lastAnimationState.weight = 0;
            if (idleState == null)
            {
                idleState = playerFrente.animation.FadeIn("0_Idle", 0.1f, -1, 15, null, AnimationFadeOutMode.None);
                idleState.displayControl = true;
            }
            else
            {
                idleState.displayControl = true;
                idleState.weight         = 1;
                idleState.Play();
            }

            state = State.Idle;
        }
        else
        {
            if (idleState == null)
            {
                return;
            }
            else
            {
                idleState.displayControl = fallState;
                idleState.weight         = 0;
                idleState.Stop();
            }
        }
    }
コード例 #21
0
    static int FadeOut(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1);
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                obj.FadeOut(arg0);
                return(0);
            }
            else if (count == 3)
            {
                DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1);
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                bool  arg1 = LuaDLL.luaL_checkboolean(L, 3);
                obj.FadeOut(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.AnimationState.FadeOut"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #22
0
    private void GanhouAnim(bool play)
    {
        if (play)
        {
            playerFrente.animation.lastAnimationState.weight = 0;
            if (winState == null)
            {
                winState = playerFrente.animation.FadeIn("2_Vencer", 0.1f, -1, 12, null, AnimationFadeOutMode.Single);
                winState.displayControl = true;
            }
            else
            {
                winState.displayControl = true;
                winState.weight         = 1;
                winState.Play();
            }

            state = State.Ganhou;
        }
        else
        {
            if (winState == null)
            {
                return;
            }
            else
            {
                winState.displayControl = false;
                winState.weight         = 0;
                winState.Stop();
            }
        }
    }
コード例 #23
0
    /**
     * 攻击
     */
    private void _fight()
    {
        _curState = PlayerState.ATTACK;

        _attackState = _armatureComponent.animation.FadeIn("attack_1", -1, 1, 0, ATTACK_ANIMATION_GROUP);
        _attackState.autoFadeOutTime = 0.1f;
    }
コード例 #24
0
    private void PerdeuAnim(bool play)
    {
        if (play)
        {
            playerFrente.animation.lastAnimationState.weight = 0;
            if (loseState == null)
            {
                loseState = playerFrente.animation.FadeIn("2_Perder", 0.1f, -1, 11, null, AnimationFadeOutMode.Single);
                loseState.displayControl = true;
            }
            else
            {
                loseState.displayControl = true;
                loseState.weight         = 1;
                loseState.Play();
            }

            state = State.Perdeu;
        }
        else
        {
            if (loseState == null)
            {
                return;
            }
            else
            {
                loseState.displayControl = false;
                loseState.weight         = 0;
                loseState.Stop();
            }
        }
    }
コード例 #25
0
    static int GotoAndStopByProgress(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                DragonBones.Animation obj = (DragonBones.Animation)ToLua.CheckObject <DragonBones.Animation>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                DragonBones.AnimationState o = obj.GotoAndStopByProgress(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                DragonBones.Animation obj = (DragonBones.Animation)ToLua.CheckObject <DragonBones.Animation>(L, 1);
                string arg0 = ToLua.CheckString(L, 2);
                float  arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                DragonBones.AnimationState o = obj.GotoAndStopByProgress(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.Animation.GotoAndStopByProgress"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #26
0
    private void StunAnim(bool play)
    {
        if (play)
        {
            playerFrente.animation.lastAnimationState.weight = 0;
            if (stunState == null)
            {
                stunState = playerFrente.animation.FadeIn("3_Atordoado", 0.1f, -1, 10, null, AnimationFadeOutMode.Single);
                stunState.displayControl = true;
            }
            else
            {
                stunState.displayControl = true;
                stunState.weight         = 1;
                stunState.Play();
            }

            state = State.Stun;
        }
        else
        {
            if (stunState == null)
            {
                return;
            }
            else
            {
                stunState.displayControl = false;
                stunState.weight         = 0;
                stunState.Stop();
            }
        }
    }
コード例 #27
0
    void AnimationEventHandler(string type, EventObject eventObject)
    {
        Debug.Log(type + " : " + eventObject.animationState.name);
        switch (type)
        {
        case EventObject.FADE_IN_COMPLETE:
            if (eventObject.animationState.name == "jump_1")
            {
                if (IsGrounded)
                {
                    _doJumpBurst = true;
                    _animState   = _armatureComponent.animation.FadeIn("jump_2");
                    //_rigidBody.velocity = new Vector2(_rigidBody.velocity.x, _jumpSpeed);
                }
            }
            else if (eventObject.animationState.name == "jump_4")
            {
                _isJumping = false;
            }
            break;

        case EventObject.FADE_OUT_COMPLETE:
            break;

        default:
            break;
        }
    }
コード例 #28
0
        private void _updateAnimation()
        {
            if (_isJumping || _isFalling)
            {
                return;
            }

            if (_moveDir == 0.0f)
            {
                _armatureComponent.animation.FadeIn(idleState, -1.0f, -1, 0, NORMAL_ANIMATION_GROUP).resetToPose = false;
                _walkState = null;
            }
            else
            {
                if (_walkState == null)
                {
                    _walkState = _armatureComponent.animation.FadeIn(walkState, -1.0f, -1, 0, NORMAL_ANIMATION_GROUP);
                    this._walkState.resetToPose = false;
                }

                //if (this._moveDir * this._faceDir > 0.0f)
                //{
                //    this._walkState.timeScale = MAX_MOVE_SPEED_FRONT / NORMALIZE_MOVE_SPEED;
                //}
                //else
                //{
                //    this._walkState.timeScale = -MAX_MOVE_SPEED_FRONT / NORMALIZE_MOVE_SPEED;
                //}
            }
        }
コード例 #29
0
    /**
     * 跳跃
     */
    private void _jump()
    {
        // 判断是否在地面上
        if (PlayerIsOnGround())
        {
            // 1. 改变状态
            _curState = PlayerState.JUMP;

            // 2. 淡入跳跃动画
            _jumpState                 = _armatureComponent.animation.FadeIn("jump", -1.0f, 1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup);
            _jumpState.timeScale       = 0.7f;        // 控制 某个动画状态 的 播放速度
            _jumpState.autoFadeOutTime = 0.1f;        // 对于限定播放次数的动画, 会自动淡出

            // 3. 添加位移
            rb.AddForce(new Vector2(0, accel));

            // 4. 将 Jump 同组的其他动画停掉, 并设置成 null
            // 将idel 状态停掉, 并设置成null
            if (_idelState != null)
            {
                _idelState.FadeOut(0.1f);
                _idelState = null;
            }

            // 将run 状态停掉, 并设置成null
            if (_runState != null)
            {
                _runState.FadeOut(0.1f);
                _runState = null;
            }
        }
    }
コード例 #30
0
    void Update()
    {
        animationState = armatureComponent.animation.lastAnimationState;

        //get some values for condition check
        grounded  = characterController2D.m_Grounded;
        speed     = Mathf.Abs(playerMovement.horizontalMove);
        yVelocity = characterController2D.velocity.y;

        if (speed == 0 && grounded)
        {
            Idle();
        }

        if (speed != 0 && grounded)
        {
            Run(speed / 3);
        }

        if (yVelocity > 0.5f)
        {
            Jump();
        }

        if (yushaSkills.isFlying)
        {
            OpenUmbrella();
        }
    }