Beispiel #1
0
    //FUNCTION:切换 单手-双手动画
    public void ChangeDualHand(bool righthand)
    {
        bool twoHand = ac.animator.GetBool("twoHand");

        if (!twoHand)
        {
            if (righthand)
            {
                wm.SetWeaponOnUseVisiable(false, false);
                WeaponData wd = wm.GetWeaponDataOnUse(true);
                SetAtkAnimationInt(wd.weaponItem.wpAtkMotionID);
                AnimatorFactory.SetLocalMotion(ac.animator, wd.weaponItem.localMotionID2H);
            }
            else
            {
                wm.SetWeaponOnUseVisiable(false, true);
                WeaponData wd = wm.GetWeaponDataOnUse(false);
                SetAtkAnimationInt(wd.weaponItem.wpAtkMotionID);
                AnimatorFactory.SetLocalMotion(ac.animator, wd.weaponItem.localMotionID2H);
                //TODO:并且将左手武器送入又手
            }
        }
        //武器卸载
        else
        {
            wm.SetAllWeaponOnUseVisiable(true);
            SetAtkAnimationInt(wm.wcR.weaponDataOnUse.weaponItem.wpAtkMotionID);
            AnimatorFactory.SetLocalMotion(ac.animator, wm.wcR.weaponDataOnUse.weaponItem.localMotionID1H);
        }

        ac.animator.SetBool("twoHand", !twoHand);
    }
        partial void Apply(bool isSizeChanged, bool isOriginChanged)
        {
            if (Transform.IsAnimating)
            {
                // The transform is animating, so we disable the matrix "static transform" and let the animation apply its values
                Matrix.SetValues(_identity);
                if (isSizeChanged)
                {
                    // Even if while animating, we must update the PivotX and PivotY
                    AnimatorFactory.UpdatePivotWhileAnimating(
                        Transform,
                        CurrentSize.Width * CurrentOrigin.X,
                        CurrentSize.Height * CurrentOrigin.Y);
                }
            }
            else if (CurrentSize.IsEmpty || CurrentSize.Width == 0 || CurrentSize.Width == 0)
            {
                // Element was not measured yet (or unloaded ?), as on Android the Matrix includes the center,
                // it's dependent of the element size, so we cannot get a valid transform matrix.
                // Instead we just make sure to reset all values.
                Matrix.SetValues(_identity);
                Owner.PivotX = 0;
                Owner.PivotY = 0;
            }
            else
            {
                // The element is measured and not animating, we can update the "static transform" matrix.
                var matrix = Transform.ToMatrix(CurrentOrigin, CurrentSize);

                Matrix.SetValues(new[]
                {
                    matrix.M11, matrix.M21, ViewHelper.LogicalToPhysicalPixels(matrix.M31),
                    matrix.M12, matrix.M22, ViewHelper.LogicalToPhysicalPixels(matrix.M32),
                    0, 0, 1
                });
                Owner.PivotX = 0;
                Owner.PivotY = 0;

                if (!isSizeChanged)
                {
                    // A property on the Transform was change, request a redraw to apply the updated matrix
                    Owner.Invalidate();

                    // This is necessary to ensure descendants are redrawn properly esp. when animating, since hardware-accelerated
                    // animations don't take getChildStaticTransformation() into account properly
                    InvalidateDescendants();
                }
            }

            if (Owner is UnoViewGroup uvg)
            {
                uvg.IsAnimationInProgress = Transform.IsAnimating;
            }
        }
Beispiel #3
0
 private void Awake()
 {
     if (instance)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
Beispiel #4
0
    /// <summary>
    /// 装备武器
    /// </summary>
    /// <param name="weaponItem"></param>
    /// <param name="pos"></param>
    /// <param name="rh"></param>
    public void EquipWeapon(WeaponItem weaponItem, int pos, bool rh)
    {
        WeaponController wc = rh ? wcR : wcL;

        wc.EquipWeapon(weaponItem, pos); //更改模型、wd引用

        //tips:黑魂以右手作为localMothion动画的判断
        if (wc.weaponDataOnUse == GetWeaponDataOnUse(true))
        {
            AnimatorFactory.SetLocalMotion(animator, wc.weaponDataOnUse.weaponItem.localMotionID1H);
        }

        //更新UI
        if (rh)
        {
            am.inventory.InventoryUI.rhwpISM.UpdateItem(pos, weaponItem);
        }
        else
        {
            am.inventory.InventoryUI.lhwpISM.UpdateItem(pos, weaponItem);
        }
    }
Beispiel #5
0
    /// <summary>
    /// 切换到下一把武器
    /// </summary>
    /// <param name="rh"></param>
    public void Switch2NextWeapon(bool rh)
    {
        WeaponController wc      = rh ? wcR : wcL;
        WeaponData       current = wc.weaponDataOnUse;
        WeaponData       next    = wc.GetNextWeapon();

        wc.SetWeaponVisiable(current.gameObject, false);
        wc.SetWeaponVisiable(next.gameObject, true);

        wc.weaponDataOnUse = next;

        //如果是玩家,则进行UI更新.
        // if(am.gameObject.CompareTag("Player"))
        // ChangeWeaponEvent.Invoke((int)wc.weaponDataOnUse.weapon.GetID(),rh);
        if (wc.weaponDataOnUse.weaponItem == null)
        {
            wc.EquipWeapon((WeaponItem)Item.GetItem(ItemEnum.Fist), next.transform.GetSiblingIndex());
        }
        am.SetAtkAnimationInt(wc.weaponDataOnUse.weaponItem.wpAtkMotionID);
        AnimatorFactory.SetLocalMotion(animator, wc.weaponDataOnUse.weaponItem.localMotionID1H);

        SetAllWeaponOnUseVisiable(true);
    }