示例#1
0
    bool CheckHits(int length, SShot shot, out RaycastHit hit)
    {
        RaycastHit nearesthit;
        float      distance;

        RaycastHit t_hit;
        int        i = 0;

        for (; i < length; i++)
        {
            t_hit = hits[i];
            if (!ShipIdentification.IsThisShip(t_hit.transform, shot.friend))
            {
                nearesthit = t_hit;
                distance   = t_hit.distance;
                i++;
                goto begin;
            }
        }
        hit = new RaycastHit();
        return(false);

begin:
        float t_distance;

        for (; i < length; i++)
        {
            t_hit = hits[i];
            if (!ShipIdentification.IsThisShip(t_hit.transform, shot.friend))
            {
                t_distance = t_hit.distance;
                if (t_distance < distance)
                {
                    nearesthit = t_hit;
                    distance   = t_distance;
                }
            }
        }
        hit = nearesthit;
        return(true);
    }
示例#2
0
    public void Fire(IShot shot, Vector3 start, Vector3 dir, float speed, float lifeTime, ShipController friend)
    {
        if (count == shots.Length)
        {
            int l  = shots.Length;
            int wl = shots.Length * 2 + 1;
            Algs.IncreseArray(ref shots, wl);
            Algs.IncreseArray(ref verts, wl * size);
            Algs.IncreseArray(ref uvs, wl * size);

            for (int i = l; i < wl; i++)
            {
                shots[i] = new SShot();
            }
        }

        shots[count].pos      = start;
        shots[count].back     = shots[count].pos;
        shots[count].velocity = dir * speed;
        shots[count].dead     = Time.time + lifeTime;
        shots[count].friend   = friend;
        shots[count].shot     = shot;
        count++;
    }
示例#3
0
 protected abstract void UpdateShot(ProxyArray <Vector3> verts, ProxyArray <Vector2> uvs, SShot shot);
示例#4
0
    protected override void UpdateShot(ProxyArray <Vector3> verts, ProxyArray <Vector2> uvs, SShot shot)
    {
        Vector3 up = shot.up * .75f;

        verts[0] = shot.back - up;
        verts[1] = shot.pos - up;
        verts[2] = shot.back + up;
        verts[3] = shot.pos + up;


        uvs[0] = uvRect.leftBot;
        uvs[1] = uvRect.rightBot;
        uvs[2] = uvRect.leftTop;
        uvs[3] = uvRect.rightTop;

        /*
         * tris[0] = 0;
         * tris[1] = 2;
         * tris[2] = 1;
         *
         * tris[3] = 2;
         * tris[4] = 3;
         * tris[5] = 1;*/
    }
示例#5
0
    protected override void UpdateShot(ProxyArray <Vector3> verts, ProxyArray <Vector2> uvs, SShot shot)
    {
        Vector3 up         = shot.up * width;
        Vector3 rocketBack = shot.pos - shot.velocity / (shot.speed / length);

        //rocket
        verts[0] = rocketBack - up;
        verts[1] = shot.pos - up;
        verts[2] = rocketBack + up;
        verts[3] = shot.pos + up;


        uvs[0] = uvRocket.leftBot;
        uvs[1] = uvRocket.rightBot;
        uvs[2] = uvRocket.leftTop;
        uvs[3] = uvRocket.rightTop;

        /*
         * tris[0] = 0;
         * tris[1] = 2;
         * tris[2] = 1;
         *
         * tris[3] = 2;
         * tris[4] = 3;
         * tris[5] = 1;*/

        //trail

        verts[4] = shot.back - up;
        verts[5] = rocketBack - up;
        verts[6] = shot.back + up;
        verts[7] = rocketBack + up;


        uvs[4] = uvTrail.leftBot;
        uvs[5] = uvTrail.rightBot;
        uvs[6] = uvTrail.leftTop;
        uvs[7] = uvTrail.rightTop;

        /*
         * tris[6] = 4;
         * tris[7] = 6;
         * tris[8] = 5;
         *
         * tris[9] = 6;
         * tris[10] = 7;
         * tris[11] = 5;*/
    }