Exemple #1
0
    void SpawnEnemy()
    {
        GameObject go = op.Enable("Enemy");

        go.transform.position =
            (Random.Range(0, 2) == 1 ? leftSpawn.position : rightSpawn.position);
        EnemyUnit enemy = go.GetComponent <EnemyUnit>();

        enemy.SetTarget(playerManager.playerTransform);
        go.layer = gameObject.layer;
        noneSetTarget.Enqueue(go.transform);

        int rand = Random.Range(0, 101);

        if (rand < 10)
        {
            enemy.approachDistance = 5;
            enemy.engageDistance   = 9;
            enemy.UseWeapon(0);
        }
        else if (rand < 40)
        {
            enemy.approachDistance = 3;
            enemy.engageDistance   = 7;
            enemy.UseWeapon(1);
        }
        else if (rand < 95)
        {
            enemy.approachDistance = 2;
            enemy.engageDistance   = 6;
            enemy.UseWeapon(2);
        }
        else
        {
            enemy.approachDistance = 10;
            enemy.engageDistance   = 12;
            enemy.UseWeapon(3);
        }
    }
Exemple #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="dmgBouns">피해량 변동치(n배 : n)</param>
    /// <param name="speedBouns">탄속 변동치(n배 : n) min: 0.01</param>
    /// <param name="fireRate">연사 변동치(n배 : n) min: 0.1</param>
    /// <param name="costMagazine">탄 소모 변동치(n배 : n) min: 1</param>
    public void Shoot(float dmgBouns = 1f, float speedBouns = 1f, float fireRate = 1f, int costMagazine = 1)
    {
        if (dmgBouns < 0)
        {
            dmgBouns = 0;
        }
        if (speedBouns < 0.01f)
        {
            speedBouns = 0.01f;
        }
        if (fireRate < 0.1f)
        {
            fireRate = 0.1f;
        }
        if (costMagazine < 1)
        {
            costMagazine = 1;
        }

        if (Time.realtimeSinceStartup - fireTime < wpInfo.firerate / fireRate)
        {
            return;
        }
        if (wpInfo.curMagazine < 1)
        {
            return;
        }
        if (!weapons[useSlot])
        {
            return;
        }
        float      z  = transform.eulerAngles.z;
        GameObject go = op.Enable("Bullet1");
        Bullet     b  = go.GetComponent <Bullet>();

        go.layer = bulletLayer;
        b.Shoot(wpInfo.muzzle.position,
                transform.eulerAngles.z
                + Random.Range(-curMoa, curMoa),
                wpInfo.dmgNormal * dmgBouns,
                wpInfo.dmgCritical * dmgBouns,
                wpInfo.bulletSpeed * speedBouns,
                wpInfo.deadTime / speedBouns);
        fireTime            = Time.realtimeSinceStartup;
        wpInfo.curMagazine -= costMagazine;
        wpInfo.ShootSound();
        if (wpInfo.curMagazine <= 0)
        {
            wpInfo.curMagazine = 0;
            wpInfo.ClipSound();
            Reload();
        }

        if (wpInfo.moa <= wpInfo.spread)
        {
            curMoa = Vector2.Lerp(new Vector2(curMoa, 0), new Vector2(wpInfo.spread, 0), wpInfo.recoil).x;
            if (curMoa > wpInfo.spread)
            {
                curMoa = wpInfo.spread;
            }
        }
        else
        {
            curMoa = Vector2.Lerp(new Vector2(curMoa, 0), new Vector2(wpInfo.spread, 0), wpInfo.recoil).x;
            if (curMoa < wpInfo.spread)
            {
                curMoa = wpInfo.spread;
            }
        }
    }