Beispiel #1
0
 public void OnRollEnd()
 {
     canControl  = true;
     rollDir     = Vector2.zero;
     inRollState = false;
     // 改变Player朝向
     faceDirection = stickLDirection;
     // 重启enemyCollider与playerCollider的碰撞
     if (!I_Manager.IsDead())
     {
         int enemyCollider  = LayerMask.NameToLayer("Enemy");
         int playerCollider = LayerMask.NameToLayer("Player");
         Physics.IgnoreLayerCollision(playerCollider, enemyCollider, false);
     }
     // 是否需要切换武器
     if (nextWeaponName != WeaponNameType.unknown)
     {
         PlayerData.Instance.curWeaponName = nextWeaponName;
         nextWeaponName = WeaponNameType.unknown;
         ChangeWeapon();
     }
     // 是否需要Reload
     if (curWeaponType == WeaponType.autoDistant || curWeaponType == WeaponType.singleLoader)
     {
         int bullets = PlayerData.Instance.GetCurLeftBullets();
         if (bullets <= 0)
         {
             ((DistantWeaponManager)I_Manager.I_WeaponManager).Reload();
         }
     }
 }
    /*--------------------- AttackEvent ---------------------*/
    /*------------ Self -> Manager ------------*/
    protected override void AttackEventFunc()
    {
        if (I_Manager.IsDead())
        {
            return;
        }
        base.AttackEventFunc();
        var targetsFound = GetEnemyInRange();

        BasicHurt(self, targetsFound);
    }
    /************************* OnReloadEnd **************************/

    protected override void AttackEventFunc()
    {
        base.AttackEventFunc();
        if (leftBullets > 0)
        {
            CreateBullet(self, I_Manager.GetCurWeaponName());
            I_BaseData.ShootOneBullet();
        }
        else
        {
            Reload();
        }
    }
Beispiel #4
0
    // 设置瞄准三角
    void SetAimTriangle()
    {
        WeaponType curWeaponType = I_Manager.GetWeaponType();

        if (focusTarget != null)
        {
            if (curWeaponType == WeaponType.autoDistant || curWeaponType == WeaponType.singleLoader)
            {
                float distance = (transform.position - focusTarget.position).magnitude;
                I_AimController.UpdateAim(distance / 10, 0);
                I_AimController.SetVisible(true);
            }
            else
            {
                I_AimController.SetVisible(false);
            }
        }
        else
        {
            aimHitPoint = null;
            // 设置瞄准三角是否可见
            if ((attackType == AimAttackType.attacking || attackType == AimAttackType.aming) &&
                (curWeaponType == WeaponType.autoDistant || curWeaponType == WeaponType.singleLoader))
            {
                AnimatorStateInfo stateInfo = bodyAnim.GetCurrentAnimatorStateInfo(0);
                I_AimController.SetVisible(!stateInfo.IsName("Base.Reload"));
                // 设置瞄准三角大小
                HasEnemyInRange(ref curAimTarget, ref aimHitPoint);
                if (curAimTarget != null)
                {
                    float   distance    = (transform.position - curAimTarget.position).magnitude;
                    Vector3 p2e         = curAimTarget.position - transform.position;
                    Vector2 p2e2D       = new Vector2(p2e.x, p2e.z);
                    Vector3 direction3D = new Vector3(stickLDirection.x, 0, stickLDirection.y);
                    float   degree      = Utils.GetAnglePY(p2e, direction3D);
                    degree = degree > 180 ? degree - 360 : degree;
                    I_AimController.UpdateAim(distance / 10, degree);
                    faceDirection = p2e2D.normalized * stickLDirection.magnitude;
                }
                else if (aimHitPoint != null)
                {
                    float distance = (transform.position - aimHitPoint.Value).magnitude;
                    I_AimController.UpdateAim(distance / 10, 0);
                    faceDirection = stickLDirection;
                }
                else
                {
                    faceDirection = stickLDirection;
                    float aimLangth = 3;
                    if (Constant.AimMaxDist.ContainsKey(curWeaponName))
                    {
                        aimLangth = Constant.AimMaxDist[curWeaponName] / 10;
                    }
                    I_AimController.UpdateAim(aimLangth, 0);
                }
            }
            else
            {
                faceDirection = stickLDirection;
                I_AimController.SetVisible(false);
            }
        }
    }