Example #1
0
 void UpdateDirection()
 {
     if (follow != null && follow as UnityEngine.Object != null)
     {
         Vector3 targetFollow = follow.center;
         Vector2 Direct2      = (targetFollow - transform.position).normalized;
         float   zx           = MathQ.DirectionToRotation(Direct2).z;
         float   zc           = MathQ.DirectionToRotation(damage.Direction).z;
         float   zz;
         float   z = SpeedRotate * 360 * Time.deltaTime;
         if (!isLeft(damage.Direction, follow.center))
         {
             zz = zc - z;
         }
         else
         {
             zz = zc + z;
         }
         if ((zz - zx) * (zc - zx) <= 0)
         {
             zz = zx;
         }
         damage.Direction = MathQ.RotationToDirection(zz);
     }
 }
Example #2
0
    protected virtual Vector3 GiatSung(Vector3 direction)
    {
        Vector3 Do = MathQ.DirectionToRotation(direction);

        Do += new Vector3(0, 0, Random.Range(-DoGiat / 2, DoGiat / 2));
        return(MathQ.RotationToDirection(Do.z).normalized);
    }
Example #3
0
 private void OnDrawGizmos()
 {
     Gizmos.color = Color.red;
     for (int i = 0; i < Amount; i++)
     {
         float z = 360 * i / Amount;
         Gizmos.DrawLine(GetPositionSpawn(MathQ.RotationToDirection(z)), MathQ.RotationToDirection(z) * 10 + transform.position);
     }
 }
Example #4
0
    protected override void OnDrawGizmos()
    {
        base.OnDrawGizmos();
        Gizmos.color = Color.red;
        Vector2 dir = MathQ.RotationToDirection(OffsetAngleAttack);

        Gizmos.DrawLine(PositionSpawnBullet, PositionSpawnBullet + dir * 10);
        dir = MathQ.RotationToDirection(-OffsetAngleAttack);
        Gizmos.DrawLine(PositionSpawnBullet, PositionSpawnBullet + dir * 10);
    }
Example #5
0
    protected override void OnDrawGizmos()
    {
        base.OnDrawGizmos();
        Gizmos.color = Color.green;
        Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z + OffsetA) * 5f);
        Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z - OffsetA) * 5f);

        Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z + OffsetB) * 5f);
        Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z - OffsetB) * 5f);
    }
Example #6
0
    protected Vector2 getRotationToPlayer(Vector2 dir, int offset)
    {
        if (offset < 0)
        {
            offset = -offset;
        }
        offset = offset % 90;
        Vector3 Do = MathQ.DirectionToRotation(dir);

        Do += new Vector3(0, 0, Random.Range(-offset, offset));
        return(MathQ.RotationToDirection(Do.z).normalized);
    }
Example #7
0
 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);
     }
 }
Example #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();
    }
Example #9
0
    protected override void OnDrawGizmos()
    {
        base.OnDrawGizmos();
        Gizmos.color = Color.green;
        float startAngle = 0;

        for (int i = 0; i < AmountBulletExtra; i++)
        {
            float angle = startAngle + 360 / AmountBulletExtra * i;
            if (angle > 180)
            {
                angle -= 360;
            }
            Vector3 dir = MathQ.RotationToDirection(angle);
            Gizmos.DrawLine(transform.position, transform.position + dir * 3f);
        }
    }
Example #10
0
 public override void Shoot(DamageData damageData)
 {
     base.Shoot(damageData);
     for (int i = -1; i <= 1; i += 2)
     {
         int am = (int)Random.Range(RangeAmount.x, RangeAmount.y + 1);
         for (int j = 0; j < am; j++)
         {
             int     dolec    = i * (Random.Range(OffsetA, OffsetB + 1));
             Vector3 DirShoot = damageData.Direction;
             float   z        = MathQ.DirectionToRotation(DirShoot).z;
             z       += dolec;
             DirShoot = MathQ.RotationToDirection(z);
             SetUpDamageDataExtra(damageData, DirShoot);
             BulletBase bullet = pool.Spawn(id_pool_bullet_extra, PositionStartAttack, Quaternion.identity) as BulletBase;
             bullet.StartUp(damageData);
         }
     }
 }
Example #11
0
 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;
     }
 }
Example #12
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);
        }
    }
Example #13
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);
        }
    }
Example #14
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);
        }
    }
Example #15
0
 protected override Vector3 GiatSung(Vector3 direction)
 {
     if (nextAmountbullet == 1)
     {
         return(base.GiatSung(direction));
     }
     else
     {
         if (vitriTren)
         {
             if (isLeftDir)
             {
                 Vector3 Do = MathQ.DirectionToRotation(direction);
                 Do += new Vector3(0, 0, Random.Range(-DoGiat / 2, 0));
                 return(MathQ.RotationToDirection(Do.z).normalized);
             }
             else
             {
                 Vector3 Do = MathQ.DirectionToRotation(direction);
                 Do += new Vector3(0, 0, Random.Range(0, DoGiat / 2));
                 return(MathQ.RotationToDirection(Do.z).normalized);
             }
         }
         else
         {
             if (isLeftDir)
             {
                 Vector3 Do = MathQ.DirectionToRotation(direction);
                 Do += new Vector3(0, 0, Random.Range(0, DoGiat / 2));
                 return(MathQ.RotationToDirection(Do.z).normalized);
             }
             else
             {
                 Vector3 Do = MathQ.DirectionToRotation(direction);
                 Do += new Vector3(0, 0, Random.Range(-DoGiat / 2, 0));
                 return(MathQ.RotationToDirection(Do.z).normalized);
             }
         }
     }
 }
Example #16
0
    void Spawn()
    {
        if (bulletPrefab == null || !spawning)
        {
            return;
        }
        float z = Random.Range(0, 360 / Amount);

        for (int i = 0; i < Amount; i++)
        {
            float newZ = z + 360 * i / Amount;
            if (newZ > 180)
            {
                newZ -= 360;
            }
            Vector3    dir    = MathQ.RotationToDirection(newZ);
            BulletBase bul    = pool.Spawn(id_bul, GetPositionSpawn(dir), Quaternion.Euler(MathQ.DirectionToRotation(dir)), null) as BulletBase;
            DamageData damage = SetUpDamageData();
            damage.Direction = dir;
            bul.StartUp(damage);
        }
    }
Example #17
0
    private void Spawn()
    {
        if (pooling == null)
        {
            return;
        }
        float startAngle = MathQ.DirectionToRotation(damage.Direction).z + Random.Range(0, 360 / AmountBulletExtra);

        for (int i = 0; i < AmountBulletExtra; i++)
        {
            DamageData damage = this.damage.Clone;
            float      angle  = startAngle + 360 / AmountBulletExtra * i;
            if (angle > 180)
            {
                angle -= 360;
            }
            Vector3 dir = MathQ.RotationToDirection(angle);
            damage.Direction = dir;
            BulletExtraBoring bull = pooling.Spawn(id_pooling, transform.position, Quaternion.identity) as BulletExtraBoring;
            bull.StartUp(damage);
            bull.skipGameobject = targetHit;
        }
    }
Example #18
0
 protected virtual void OnDrawGizmos()
 {
     Gizmos.color = Color.red;
     Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z + DoGiat / 2) * 10f);
     Gizmos.DrawLine(PositionStartAttack, PositionStartAttack + MathQ.RotationToDirection(transform.rotation.eulerAngles.z - DoGiat / 2) * 10f);
 }