Ejemplo n.º 1
0
 /************************* OnReloadEnd **************************/
 void OnReloadEndEventFunc()
 {
     I_BaseData.ReloadWeapon();
     if (ReloadCallback != null)
     {
         ReloadCallback();
         ReloadCallback = null;
     }
 }
Ejemplo n.º 2
0
    /************************* OnReloadEnd **************************/

    protected override void AttackEventFunc()
    {
        base.AttackEventFunc();
        if (leftBullets > 0)
        {
            CreateBullet(self, I_Manager.GetCurWeaponName());
            I_BaseData.ShootOneBullet();
        }
        else
        {
            Reload();
        }
    }
Ejemplo n.º 3
0
    public void OnRollStart()
    {
        canControl   = false;
        curAimTarget = null;
        inRollState  = true;
        // 取消播放Reload音效
        Transform weapon = I_BaseData.curWeaponTransform;
        Transform child  = weapon.Find("SndReload");

        if (child != null)
        {
            AudioSource audio = child.GetComponent <AudioSource>();
            if (audio.clip.name == "sndReloadClip" && audio.isPlaying)
            {
                audio.Stop();
            }
        }
        // 耐力扣除
        I_BaseData.ChangeCurStrength(-Constant.rollStrength * GlobalData.diffRate);
        // 隐藏瞄准三角
        I_AimController.SetVisible(false);
        // 取消enemyCollider与playerCollider的碰撞
        int enemyCollider  = LayerMask.NameToLayer("Enemy");
        int playerCollider = LayerMask.NameToLayer("Player");

        Physics.IgnoreLayerCollision(playerCollider, enemyCollider);
        // 翻滚
        Vector2 faceDir;

        if (rollDir == Vector2.zero)
        {
            faceDir = moveDir == Vector3.zero ? new Vector2(transform.forward.x, transform.forward.z) :
                      new Vector2(moveDir.x, moveDir.z);
        }
        else
        {
            faceDir = new Vector2(rollDir.x, rollDir.y);
        }
        transform.eulerAngles = new Vector3(0, Utils.GetAnglePY(Vector3.forward, new Vector3(faceDir.x, 0, faceDir.y)), 0);
        rb.velocity           = Vector3.zero;
        iTween.MoveBy(transform.gameObject, iTween.Hash(
                          "z", 22,
                          "time", 0.44, "EaseType", "linear"
                          ));
    }
Ejemplo n.º 4
0
    /*---------------- KillerNotifyEvent ------------------*/

    protected int GetWeaponLevel(WeaponNameType weaponName)
    {
        return(I_BaseData.GetWeaponLevel(weaponName));
    }
Ejemplo n.º 5
0
    /*--------------- RollEvent -----------------*/

    public void MeleeCostStrength()
    {
        I_BaseData.ChangeCurStrength(-Constant.knifeAttackStrength * GlobalData.diffRate);
    }
Ejemplo n.º 6
0
    new void Update()
    {
        base.Update();
        // 增加耐力
        if (!inRollState && !knifeAttacking)
        {
            float delta = Constant.strengthRestoreSpeed * Time.deltaTime;
            I_BaseData.ChangeCurStrength(delta);
        }
        if (!canControl)
        {
            return;
        }
        // 确定武器的攻击状态
        if (attackType != AimAttackType.none)
        {
            btnATouchedTime += Time.deltaTime;
            if (curWeaponType == WeaponType.singleLoader)
            {
                if (faceDirection.sqrMagnitude >= 0.64 * attackBoundary * attackBoundary)
                {
                    attackType = AimAttackType.aming;
                }
                else
                {
                    attackType = AimAttackType.unknown;
                }
            }
            else if (curWeaponType == WeaponType.autoDistant)
            {
                if (attackType == AimAttackType.unknown)
                {
                    if (btnATouchedTime >= aimAttackBoundaryTime)
                    {
                        attackType = AimAttackType.aming;
                    }
                    else
                    {
                        if (faceDirection.sqrMagnitude >= 1.21f * attackBoundary * attackBoundary && leftBullets > 0)
                        {
                            attackType = AimAttackType.attacking;
                            ShowAttackAnim(true);
                        }
                    }
                }
            }
            else if (curWeaponType == WeaponType.melee)
            {
                // 开启Knife攻击状态
                if (I_BaseData.curStrength > Constant.minKnifeAttackStrength * GlobalData.diffRate)
                {
                    if (attackType == AimAttackType.aming)
                    {
                        bool hasEnemy = I_KnifeManager.GetEnemyInRange().Count > 0;
                        if (hasEnemy || faceDirection.sqrMagnitude >= 1.21f * attackBoundary * attackBoundary)
                        {
                            attackType = AimAttackType.attacking;
                            ShowAttackAnim(true);
                            knifeAttacking = true;
                        }
                    }
                }
            }
        }
#if UNITY_EDITOR
        //float x = Input.GetAxisRaw("Horizontal");
        //float y = Input.GetAxisRaw("Vertical");
        //moveDirPC = new Vector3(x, 0, y).normalized;
#endif
    }