示例#1
0
    /************************内置发射函数****************************/
    public GameObject LaunchABullet(BulletData.BulletType type, float rotation, Vector3 position, Vector3 velocity)
    {
        GameObject Dmk = Create(type, rotation, position);

        Dmk.GetComponent <Bullet>().velocity = velocity;
        return(Dmk);
    }
示例#2
0
    /************************基础发射函数****************************/
    public GameObject Create(BulletData.BulletType type, float rotation, Vector3 pos)
    {
        Quaternion rot = Angle2R(rotation);

        BulletClone = (GameObject)Instantiate(Bullet, pos, rot);
        BulletClone.GetComponent <SpriteRenderer>().sprite = BulletData.instance.GetSprite(type);
        BulletClone.GetComponent <Bullet> ().setOwner(gameObject);
        return(BulletClone);
    }
示例#3
0
    public GameObject[] LaunchALine(BulletData.BulletType type, Vector3 offset, int amount, float midAngle, float distance, float minspeed, float maxspeed)
    {
        GameObject[] dmks       = new GameObject[amount];
        float        addspeed   = (maxspeed - minspeed) / (amount - 1);
        Vector3      direction1 = Angle2V(midAngle);
        Vector3      p          = position + offset + direction1 * distance;

        for (int i = 0; i < amount; i++)
        {
            Vector3 sp = direction1 * minspeed;
            minspeed += addspeed;
            float      localR = Vector2A(direction1);
            GameObject dmk    = LaunchABullet(type, localR, p, sp);
            dmks[i] = dmk;
        }
        return(dmks);
    }
示例#4
0
    public GameObject[] LaunchABarrier(BulletData.BulletType type, Vector3 offset, float speed, int amount, float midAngle, float spreadAngle, float distance)
    {                               //数量 发射角度范围(0-360为整圈) 实际发射点距中心的距离 发射一圈
        GameObject[] dmks = new GameObject[amount];
        float        intervalAngle; //计算每颗之间的夹角

        if (spreadAngle % 360f == 0f)
        {
            intervalAngle = spreadAngle / (amount);
            midAngle     += 180f;
        }
        else
        {
            if (amount != 1 && amount != 0)
            {
                intervalAngle = spreadAngle / (amount - 1);
            }
            else
            {
                intervalAngle = 360f;
            }
        }
        float   minAngle   = midAngle - (spreadAngle / 2);
        float   maxAngle   = midAngle + (spreadAngle / 2);
        Vector3 direction1 = Vector3.zero;

        if (amount != 1 && amount != 0)
        {
            direction1 = Angle2V(minAngle);
        }
        else
        {
            if (amount == 1)
            {
                direction1 = Angle2V(midAngle);
            }
        }
        for (int i = 0; i < amount; i++)
        {
            Vector3 p      = position + offset + direction1 * distance;
            Vector3 sp     = direction1 * speed;
            float   localR = Vector2A(direction1);
            dmks[i]    = LaunchABullet(type, localR, p, sp);
            direction1 = VectorRotate(direction1, intervalAngle);
        }
        return(dmks);
    }
示例#5
0
    public GameObject[] LaunchRandom(BulletData.BulletType type, Vector3 offset, int amount, float midAngle, float spreadAngle, float distance, float speed)
    {
        GameObject[] dmks     = new GameObject[amount];
        float        minAngle = midAngle - (spreadAngle / 2);
        float        maxAngle = midAngle + (spreadAngle / 2);

        for (int i = 0; i < amount; i++)
        {
            float      angle1     = getRandom(minAngle, maxAngle);
            Vector3    direction1 = Angle2V(angle1);
            Vector3    p          = position + offset + direction1 * distance;
            Vector3    sp         = direction1 * speed;
            float      localR     = Vector2A(direction1);
            GameObject dmk        = LaunchABullet(type, localR, p, sp);
            dmks[i] = dmk;
        }
        return(dmks);
    }
示例#6
0
    public GameObject[] LaunchHorizon(BulletData.BulletType type, Vector3 offset, int amount, float midAngle, float distance, float length, float speed)
    {
        GameObject[] dmks         = new GameObject[amount];
        float        interval     = (length) / (amount - 1);
        Vector3      direction1   = Angle2V(midAngle + 90f);
        Vector3      direction2   = Angle2V(midAngle);
        Vector3      baseposition = position + offset - direction1 * (length / 2f);

        for (int i = 0; i < amount; i++)
        {
            Vector3 p  = baseposition + direction2 * distance;
            Vector3 sp = direction2 * speed;
            baseposition += direction1 * interval;
            float      localR = Vector2A(direction2);
            GameObject dmk    = LaunchABullet(type, localR, p, sp);
            dmks[i] = dmk;
        }
        return(dmks);
    }
示例#7
0
 public Sprite GetSprite(BulletData.BulletType BT)
 {
     return(DmkSprite[(int)BT]);
 }