Example #1
0
        public static DanmakuField FindClosest(Vector2 position)
        {
            if (fields == null)
            {
                fields = new List <DanmakuField>();
                fields.AddRange(Object.FindObjectsOfType <DanmakuField>());
            }
            if (fields.Count == 0)
            {
                DanmakuField encompassing = new GameObject("Danmaku Field").AddComponent <DanmakuField>();
                encompassing.useClipBoundary = false;
                fields.Add(encompassing);
            }
            if (fields.Count == 1)
            {
                return(fields[0]);
            }
            DanmakuField closest = null;
            float        minDist = float.MaxValue;

            for (int i = 0; i < fields.Count; i++)
            {
                DanmakuField field    = fields[i];
                Vector2      diff     = field.bounds.Center - position;
                float        distance = diff.sqrMagnitude;
                if (distance < minDist)
                {
                    closest = field;
                    minDist = distance;
                }
            }
            return(closest);
        }
        public FireBuilder InField(DanmakuField field)
        {
            if (field == null)
            {
                throw new ArgumentNullException("Field cannot be null!");
            }

            Field = field;
            return(this);
        }
 public void Copy(FireData other)
 {
     Prefab       = other.Prefab;
     Field        = other.Field;
     Position     = other.Position;
     Rotation     = other.Rotation;
     Speed        = other.Speed;
     AngularSpeed = other.AngularSpeed;
     Controller   = other.Controller;
     Damage       = other.Damage;
     Group        = other.Group;
 }
Example #4
0
        public Danmaku Fire(FireData data)
        {
            if (TargetField == null)
            {
                TargetField = this;
            }
            DanmakuField old = data.Field;

            data.Field = TargetField;
            Danmaku danmaku = data.Fire();

            data.Field = old;
            return(danmaku);
        }
        internal FireBuilder(DanmakuPrefab prefab, DanmakuField field = null)
        {
            if (prefab == null)
            {
                throw new ArgumentNullException();
            }

            data = new FireData()
            {
                Prefab = prefab,
                Field  = field
            };
            modifiers = new List <DanmakuModifier>();
        }
Example #6
0
 void Awake()
 {
     boundary = GetComponent <BoxCollider2D> ();
     if (field == null)
     {
         print("No field provided, searching in ancestor GameObjects...");
         field = GetComponentInParent <DanmakuField>();
     }
     if (field == null)
     {
         Debug.LogError("Field Boundary without a DanmakuField");
     }
     else
     {
         UpdatePosition();
     }
 }
Example #7
0
 /// <summary>
 /// Immediately deactivates this Danmaku and ceases all processing done on it.
 /// Calling this generally unadvised. Use <see cref="Deactivate"/> whenever possible.
 /// This method should only be used when dealing with Projectiles while the game is paused or when ProjectileManager is not enabled
 /// </summary>
 public void DeactivateImmediate()
 {
     if (is_active && OnDeactivate != null)
     {
         OnDeactivate(this);
     }
     if (tasks != null)
     {
         tasks.Clear();
     }
     ControllerUpdate = null;
     OnActivate       = null;
     OnDeactivate     = null;
     Field            = null;
     controllerCheck  = false;
     Damage           = 0;
     runtime.Remove(this);
     CollisionCheck = true;
     is_active      = false;
     danmakuPool.Return(this);
 }