コード例 #1
0
        public Danmaku FireCurved(DanmakuPrefab prefab,
                                  Vector2 location,
                                  DynamicFloat rotation,
                                  DynamicFloat speed,
                                  DynamicFloat angularSpeed,
                                  CoordinateSystem coordSys = CoordinateSystem.View,
                                  DanmakuModifier modifier  = null)
        {
            if (TargetField == null)
            {
                TargetField = this;
            }
            Vector2 position = TargetField.WorldPoint(location, coordSys);

            if (modifier == null)
            {
                Danmaku danmaku = Danmaku.GetInactive(prefab, position, rotation);
                danmaku.Field = this;
                danmaku.Activate();
                danmaku.Speed        = speed;
                danmaku.AngularSpeed = angularSpeed;
                return(danmaku);
            }
            else
            {
                FireData temp = new FireData();
                temp.Prefab       = prefab;
                temp.Speed        = speed;
                temp.AngularSpeed = angularSpeed;
                temp.Field        = this;
                modifier.Initialize(temp);
                modifier.OnFire(position, rotation);
                return(null);
            }
        }
コード例 #2
0
 public static Danmaku[] GetInactive(FireData data, DynamicInt count)
 {
     if (danmakuPool == null)
     {
         new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
     }
     if (data == null)
     {
         throw new System.ArgumentNullException();
     }
     Danmaku[] danmakus = new Danmaku[count];
     danmakuPool.Get(danmakus);
     for (int i = 0; i < danmakus.Length; i++)
     {
         Danmaku danmaku = danmakus[i];
         danmaku.MatchPrefab(data.Prefab);
         danmaku.position.x   = data.Position.x;
         danmaku.position.y   = data.Position.y;
         danmaku.Rotation     = data.Rotation.Value;
         danmaku.Speed        = data.Speed.Value;
         danmaku.AngularSpeed = data.AngularSpeed.Value;
         danmaku.AddController(data.Controller);
         danmaku.Damage = data.Damage.Value;
     }
     return(danmakus);
 }
コード例 #3
0
        public FireData Clone()
        {
            FireData copy = new FireData();

            copy.Copy(this);
            return(copy);
        }
コード例 #4
0
        public static Danmaku GetInactive(FireData data)
        {
            if (danmakuPool == null)
            {
                new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
            }
            if (data == null)
            {
                throw new System.ArgumentNullException();
            }
            Danmaku danmaku = danmakuPool.Get();

            danmaku.MatchPrefab(data.Prefab);
            danmaku.position.x   = data.Position.x;
            danmaku.position.y   = data.Position.y;
            danmaku.Rotation     = data.Rotation.Value;
            danmaku.Speed        = data.Speed.Value;
            danmaku.AngularSpeed = data.AngularSpeed.Value;
            danmaku.AddController(data.Controller);
            danmaku.Damage = data.Damage.Value;
            if (data.Group != null)
            {
                data.Group.Add(danmaku);
            }
            return(danmaku);
        }
コード例 #5
0
 internal void Initialize(FireData data)
 {
     this.data = data;
     if (subModifier != null)
     {
         subModifier.Initialize(data);
     }
     OnInitialize();
 }
コード例 #6
0
 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;
 }
コード例 #7
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);
        }
コード例 #8
0
        internal FireBuilder(DanmakuPrefab prefab, DanmakuField field = null)
        {
            if (prefab == null)
            {
                throw new ArgumentNullException();
            }

            data = new FireData()
            {
                Prefab = prefab,
                Field  = field
            };
            modifiers = new List <DanmakuModifier>();
        }
コード例 #9
0
        public static T Fire <T>(this T danmakus, FireData data, bool useRotation = true) where T : class, IEnumerable <Danmaku>
        {
            if (danmakus == null)
            {
                return(null);
            }
            if (data == null)
            {
                throw new System.ArgumentNullException("Fire Data cannot be null!");
            }
            var          arrayTest = danmakus as Danmaku[];
            Vector2      tempPos   = data.Position;
            DynamicFloat tempRot   = data.Rotation;

            if (arrayTest != null)
            {
                for (int i = 0; i < arrayTest.Length; i++)
                {
                    Danmaku danmaku = arrayTest[i];
                    if (danmaku != null)
                    {
                        data.Position = danmaku.Position;
                        if (useRotation)
                        {
                            data.Rotation = danmaku.Rotation;
                        }
                        data.Fire();
                    }
                }
            }
            else
            {
                foreach (var danmaku in danmakus)
                {
                    if (danmaku != null)
                    {
                        data.Position = danmaku.Position;
                        if (useRotation)
                        {
                            data.Rotation = danmaku.Rotation;
                        }
                        data.Fire();
                    }
                }
            }
            data.Position = tempPos;
            data.Rotation = tempRot;
            return(danmakus);
        }
コード例 #10
0
        /// <summary>
        /// Fires a single bullet from the bullet's current position.
        /// </summary>
        ///
        /// <remarks>
        /// By default, firing using this method also uses the rotation of the bullet to fire the bullet.
        /// Set <c>useRotation</c> to false to disable this.
        /// </remarks>
        /// <param name="data">the data used to create the .</param>
        /// <param name="useRotation">If set to <c>true</c>, the bullet will use the current rotation of the bullet to fire with.</param>
        public Danmaku Fire(FireData data, bool useRotation = true)
        {
            Vector2      tempPos = data.Position;
            DynamicFloat tempRot = data.Rotation;

            data.Position = Position;
            if (useRotation)
            {
                data.Rotation = Rotation;
            }
            Danmaku danmaku = data.Fire();

            data.Position = tempPos;
            data.Rotation = tempRot;
            return(danmaku);
        }
コード例 #11
0
 public static void GetInactive(FireData data, Danmaku[] prealloc)
 {
     if (danmakuPool == null)
     {
         new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
     }
     if (data == null)
     {
         throw new System.ArgumentNullException();
     }
     danmakuPool.Get(prealloc);
     for (int i = 0; i < prealloc.Length; i++)
     {
         Danmaku danmaku = prealloc[i];
         danmaku.MatchPrefab(data.Prefab);
         danmaku.position.x   = data.Position.x;
         danmaku.position.y   = data.Position.y;
         danmaku.Rotation     = data.Rotation.Value;
         danmaku.Speed        = data.Speed.Value;
         danmaku.AngularSpeed = data.AngularSpeed.Value;
         danmaku.AddController(data.Controller);
         danmaku.Damage = data.Damage.Value;
     }
 }
コード例 #12
0
 public void Fire(FireData data)
 {
     Initialize(data);
     OnFire(data.Position, data.Rotation);
 }
コード例 #13
0
 internal FireBuilder(FireBuilder other)
 {
     data      = new FireData();
     modifiers = new List <DanmakuModifier>();
     Copy(other);
 }