// Creating a single bullet
        public void CreateSingle(Vector2 position, Radial direction, Color color, BulletDraw shape = BulletDraw.circle)
        {
            // check if a bullet can be made
            if (activeCount == Count)
            {
                Debug.ErrorLog("Reached max number of bullets");
                return;
            }

            // find a location to add the bullet to
            int index;

            for (index = 0; index < Count; index++)
            {
                if (bulletArr[index].state == 0)
                {
                    break;
                }
                else if (index + 1 == Count)
                {
                    Debug.ErrorLog("Reached max number of bullets but failed to recognise that sooner");
                    return;
                }
            }

            // create and add bullet
            bulletArr[index].position  = position;
            bulletArr[index].direction = direction;
            bulletArr[index].state     = BulletState.spawning;
            bulletArr[index].draw      = shape;
            bulletArr[index].color     = color;
        }
Beispiel #2
0
        public void SpawnSingleAt(BulletLogic logicType, BulletDraw drawType, Radial radial, Vector2 position, Color color)
        {
            int index = 0;

            for (index = 0; index < Count; index++)
            {
                if (this[index].logicType == BulletLogic.None)
                {
                    break;
                }
                else
                {
                    IO.Debug.Log("Could not spawn bullet");
                    return;
                }
            }

            this[index].logicType      = logicType;
            this[index].drawType       = drawType;
            this[index].radial         = radial;
            this[index].position       = position;
            this[index].color          = color;
            this[index].TimeSinceAwake = 0f;
        }