Exemple #1
0
 public override void Shoot(DamageData damageData)
 {
     if (nextAmountbullet == 1)
     {
         Vector3    DirShoot = damageData.Direction;
         BulletBase bull     = pool.Spawn(id_pool_bullet, PositionStartAttack, MathQ.DirectionToQuaternion(DirShoot)) as BulletBase;
         SetUpDamageData(damageData);
         bull.StartUp(damageData);
         nextAmountbullet = 2;
     }
     else if (nextAmountbullet == 2)
     {
         vitriTren = true;
         DamageData dam = damageData.Clone;
         SetUpDamageData(dam);
         BulletBase bull = pool.Spawn(id_pool_bullet, PositionStartAttack, MathQ.DirectionToQuaternion(dam.Direction)) as BulletBase;
         bull.StartUp(dam);
         vitriTren = false;
         dam       = damageData.Clone;
         SetUpDamageData(dam);
         bull = pool.Spawn(id_pool_bullet, PositionStartAttack, MathQ.DirectionToQuaternion(dam.Direction)) as BulletBase;
         bull.StartUp(dam);
         nextAmountbullet = 1;
     }
 }
Exemple #2
0
    public virtual void Shoot(DamageData damageData)
    {
        Vector3    DirShoot = damageData.Direction;
        BulletBase bull     = pool.Spawn(id_pool_bullet, PositionStartAttack, MathQ.DirectionToQuaternion(DirShoot)) as BulletBase;

        SetUpDamageData(damageData);
        bull.StartUp(damageData);
    }
Exemple #3
0
 private void Rotate()
 {
     if (Host == null)
     {
         return;
     }
     transform.rotation = MathQ.DirectionToQuaternion(Host.DirectFire);
 }
Exemple #4
0
 // Được gọi mỗi lần Update
 private void RotationGun()
 {
     if (Host == null)
     {
         return;
     }
     transform.rotation = MathQ.DirectionToQuaternion(Host.DirectFire);
     isLeftDir          = Host.DirectFire.x < 0;
     render.flipY       = isLeftDir;
 }
Exemple #5
0
 public void StartUp(float speed, Vector2 DirectMove, int hp)
 {
     this.speedAdd      = speed;
     this.DirectMove    = DirectMove.normalized;
     this.hp            = hp;
     transform.rotation = MathQ.DirectionToQuaternion(DirectMove);
     levelScale         = (int)(hp / HpPerLevel) + 1;
     maxScale           = levelScale;
     UpdateScale();
 }
Exemple #6
0
    protected virtual void OnBeginAttack()
    {
        Vector2     dirAttack = getRotationToPlayer((TargetFire.center - PositionSpawnBullet).normalized, OffsetAngleAttack);
        BulletEnemy bullet    = pool.Spawn(id_bul, PositionSpawnBullet, MathQ.DirectionToQuaternion(dirAttack)) as BulletEnemy;
        DamageData  dam       = new DamageData();

        SetUpDamageData(dam);
        dam.Direction = dirAttack;
        bullet.StartUp(dam);
        SetNewAction(Action.Idle);
        OnBeginIdle();
    }
 public virtual void SpawnBui(int Amount, int DirZ, int Off)
 {
     if (pooling == null)
     {
         Debug.Log("Dust need Prefab");
         return;
     }
     for (int i = 0; i < Amount; i++)
     {
         Vector3 pos = new Vector3(Random.Range(-RangeSpawn.x, RangeSpawn.x), Random.Range(-RangeSpawn.y, RangeSpawn.y), 0) + (Vector3)Center + Offset;
         Vector3 dir = MathQ.RotationToDirection(DirZ + Random.Range(-Off, Off));
         (pooling.Spawn(id_dust, pos, MathQ.DirectionToQuaternion(new Vector3(0, 0, Random.Range(0, 360)))) as Dust)
         .SetUp(1, dir, Random.Range(RangeSpeed.x, RangeSpeed.y), Random.Range(RangeSize.x, RangeSize.y), color);
     }
 }
Exemple #8
0
    protected virtual void OnBeginAttack()
    {
        float z = MathQ.DirectionToRotation(DirectFire).z;

        for (int i = -1; i <= 1; i++)
        {
            Vector2     dirAttack = MathQ.RotationToDirection(z + OffsetAngleAttack * i);
            BulletEnemy bullet    = pool.Spawn(id_bul, PositionSpawnBullet, MathQ.DirectionToQuaternion(dirAttack)) as BulletEnemy;
            DamageData  dam       = new DamageData();
            SetUpDamageData(dam);
            dam.Direction = dirAttack;
            bullet.StartUp(dam);
        }
        SetNewAction(Action.Idle);
        OnBeginIdle();
    }
Exemple #9
0
    IEnumerator SpawnMeteorites(Vector2 Node1, Vector2 Node2, Vector2 Direction, bool isVer, Vector3 posZone, Vector2 posColliderEnd, Vector2 sizeColliderEnd)
    {
        yield return(new WaitForSeconds(3f));

        if (colliderEnd != null)
        {
            colliderEnd.gameObject.SetActive(true);
            colliderEnd.transform.position = posColliderEnd;
            colliderEnd.size = sizeColliderEnd;
        }
        CameraMove.Instance.AddPosition(new TaretVector3("Round Hail", ((Vector2)posZone + Data.position) / 2));
        PlayerController.PlayerCurrent.DirectFire     = -Direction;
        PlayerController.PlayerCurrent.LocKDirectFire = true;
        WaveHail waveCurrent           = Data.WavesHail[idcurrent];
        float    timeSpawned           = 0;
        float    timeWait              = 0;
        float    AmountPerSecond       = waveCurrent.Density * (isVer ? Data.Size.x : Data.Size.y);
        float    timeDelayPerMeteorite = 1 / AmountPerSecond;

        if (timeDelayPerMeteorite == 0)
        {
            Debug.Log("Timedelay = 0 nen fix lai 0.1f");
            timeDelayPerMeteorite = 0.1f;
        }
        spawning = true;
        while (timeSpawned < waveCurrent.Time)
        {
            yield return(null);

            timeSpawned += Time.deltaTime;
            timeWait    += Time.deltaTime;
            while (timeWait > timeDelayPerMeteorite)
            {
                Vector2   pos = GetRandomPositionInLine(Node1, Node2);
                Meteorite a   = pool.Spawn(idMeteo, pos, MathQ.DirectionToQuaternion(Direction)) as Meteorite;
                a.StartUp(waveCurrent.Speed, Direction, Random.Range(waveCurrent.RangeHp.x, waveCurrent.RangeHp.y));
                meteos.Add(a);
                a.OnDead += CheckAmountMeteorite;
                timeWait -= timeDelayPerMeteorite;
            }
        }
        if (zoneSpawn != null)
        {
            zoneSpawn.gameObject.SetActive(false);
        }
        spawning = false;
    }
 private void Attacking()
 {
     if (!attacked && Time.time - time_start_action > 7 * time_action / 12)
     {
         float z = Random.Range(0, 60);
         for (int i = 0; i < 6; i++)
         {
             float       zz         = z + 60 * i;
             Vector2     dirAttack  = MathQ.RotationToDirection(zz);
             Vector2     vitriradan = center + dirAttack * DistancePositonSpawnBull;
             BulletEnemy bullet     = pool.Spawn(id_bul, vitriradan, MathQ.DirectionToQuaternion(dirAttack)) as BulletEnemy;
             DamageData  dam        = new DamageData();
             SetUpDamageData(dam);
             dam.Direction = dirAttack;
             bullet.StartUp(dam);
         }
         attacked = true;
     }
 }
Exemple #11
0
    public virtual void SpawnBui(DamageData damage)
    {
        if (pooling == null)
        {
            Debug.Log("Dust need Prefab");
        }
        Vector3 DirZ   = MathQ.DirectionToRotation(damage.Direction);
        int     Amount = damage.Damage / 2 * MutiDus;
        float   Off    = 15;

        for (int i = 0; i < Amount; i++)
        {
            Vector3 pos = new Vector3(Random.Range(-RangeSpawn.x, RangeSpawn.x), Random.Range(-RangeSpawn.y, RangeSpawn.y), 0) + Offset;
            Vector3 dir = MathQ.RotationToDirection(DirZ.z + Random.Range(-Off, Off));
            pos = transform.TransformPoint(pos);
            (pooling.Spawn(id_dust, pos, MathQ.DirectionToQuaternion(new Vector3(0, 0, Random.Range(0, 360)))) as Dust)
            .SetUp(1, dir, Random.Range(RangeSpeed.x, RangeSpeed.y), Random.Range(RangeSize.x, RangeSize.y), color);
        }
    }
Exemple #12
0
    public virtual void Dead()
    {
        if (pooling == null)
        {
            Debug.Log("Dust need Prefab");
            return;
        }
        float DirZ   = 0;
        int   Amount = 60;
        float Off    = 180;

        for (int i = 0; i < Amount; i++)
        {
            Vector3 pos = new Vector3(Random.Range(-RangeSpawn.x, RangeSpawn.x), Random.Range(-RangeSpawn.y, RangeSpawn.y), 0) + Offset;
            Vector3 dir = MathQ.RotationToDirection(DirZ + Random.Range(-Off, Off));
            pos = transform.TransformPoint(pos);
            (pooling.Spawn(id_dust, pos, MathQ.DirectionToQuaternion(new Vector3(0, 0, Random.Range(0, 360)))) as Dust)
            .SetUp(1, dir, Random.Range(RangeSpeed.x, RangeSpeed.y), Random.Range(RangeSize.x, RangeSize.y), color);
        }
    }
Exemple #13
0
    private void Attacking2()
    {
        float startAngle = MathQ.DirectionToRotation(DirectFire).z - 20;

        startAngle = startAngle < -180 ? startAngle + 360 : startAngle;
        for (int i = 0; i < 2; i++)
        {
            float angle = startAngle + i * 20;
            if (angle >= 180)
            {
                angle -= 360;
            }
            Vector3    Direction = MathQ.RotationToDirection(angle);
            DamageData damage    = new DamageData();
            SetUpDamageData(damage);
            damage.Direction = Direction;
            BulletFollow bul = pool.Spawn(id_bull, positionSpawnBullet, MathQ.DirectionToQuaternion(Direction)) as BulletFollow;
            bul.SetTarget(Find.FindTargetNearest(center, 7f, targetFolow));
            bul.StartUp(damage);
        }
    }
Exemple #14
0
 protected virtual void UpdateRotation()
 {
     transform.rotation = MathQ.DirectionToQuaternion(damage.Direction);
 }