Exemplo n.º 1
0
        public static T AngularAccelerate <T> (this T danmakus, DynamicFloat deltaSpeed)  where T : class, IEnumerable <Danmaku>
        {
            if (danmakus == null)
            {
                return(null);
            }
            var arrayTest = danmakus as Danmaku[];

            if (arrayTest != null)
            {
                for (int i = 0; i < arrayTest.Length; i++)
                {
                    Danmaku danmaku = arrayTest[i];
                    if (danmaku != null)
                    {
                        danmaku.AngularSpeed += deltaSpeed.Value;
                    }
                }
            }
            else
            {
                foreach (var danmaku in danmakus)
                {
                    if (danmaku != null)
                    {
                        danmaku.AngularSpeed += deltaSpeed.Value;
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public static T Speed <T> (this T danmakus, DynamicFloat velocity) where T : class, IEnumerable <Danmaku>
        {
            if (danmakus == null)
            {
                return(null);
            }
            var arrayTest = danmakus as Danmaku[];

            if (arrayTest != null)
            {
                for (int i = 0; i < arrayTest.Length; i++)
                {
                    Danmaku danmaku = arrayTest[i];
                    if (danmaku != null)
                    {
                        danmaku.Speed = velocity.Value;
                    }
                }
            }
            else
            {
                foreach (var danmaku in danmakus)
                {
                    if (danmaku != null)
                    {
                        danmaku.Speed = velocity.Value;
                    }
                }
            }
            return(danmakus);
        }
Exemplo n.º 4
0
        public static T Rotate <T> (this T danmakus, DynamicFloat delta) where T : class, IEnumerable <Danmaku>
        {
            if (danmakus == null)
            {
                return(null);
            }
            var arrayTest = danmakus as Danmaku[];

            if (arrayTest != null)
            {
                for (int i = 0; i < arrayTest.Length; i++)
                {
                    Danmaku danmaku = arrayTest[i];
                    if (danmaku != null)
                    {
                        danmaku.Rotation += delta;
                    }
                }
            }
            else
            {
                foreach (var danmaku in danmakus)
                {
                    if (danmaku != null)
                    {
                        danmaku.Rotation += delta;
                    }
                }
            }
            return(danmakus);
        }
Exemplo n.º 5
0
 public override bool Equals(object obj)
 {
     if (obj is DynamicFloat)
     {
         DynamicFloat df = (DynamicFloat)obj;
         return(df == this);
     }
     return(false);
 }
Exemplo n.º 6
0
        public Danmaku SpawnDanmaku(DanmakuPrefab bulletType, Vector2 location, DynamicFloat rotation, CoordinateSystem coordSys = CoordinateSystem.View)
        {
            if (TargetField == null)
            {
                TargetField = this;
            }
            Danmaku bullet = Danmaku.GetInactive(bulletType, TargetField.WorldPoint(location, coordSys), rotation);

            bullet.Field = TargetField;
            bullet.Activate();
            return(bullet);
        }
 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;
 }
        public static Danmaku GetInactive(Vector2 position, DynamicFloat rotation)
        {
            if (danmakuPool == null)
            {
                new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
            }
            Danmaku danmaku = danmakuPool.Get();

            danmaku.position.x = position.x;
            danmaku.position.y = position.y;
            danmaku.Rotation   = rotation.Value;
            return(danmaku);
        }
Exemplo n.º 9
0
 protected void FireSingle(Vector2 position,
                           DynamicFloat rotation)
 {
     if (SubModifier == null)
     {
         data.Position = position;
         data.Rotation = rotation;
         data.Fire();
     }
     else
     {
         SubModifier.OnFire(position, rotation);
     }
 }
Exemplo n.º 10
0
        public void Fire(FireBuilder builder, bool useRotation = true)
        {
            Vector2      tempPos = builder.Position;
            DynamicFloat tempRot = builder.Rotation;

            builder.Position = Position;
            if (useRotation)
            {
                builder.Rotation = Rotation;
            }
            builder.Fire();
            builder.Position = tempPos;
            builder.Rotation = tempRot;
        }
Exemplo n.º 11
0
        public static T Fire <T>(this T danmakus, FireBuilder builder, bool useRotation = true) where T : class, IEnumerable <Danmaku>
        {
            if (danmakus == null)
            {
                return(null);
            }
            if (builder == null)
            {
                throw new System.ArgumentNullException("Fire Builder cannot be null!");
            }
            var          arrayTest = danmakus as Danmaku[];
            Vector2      tempPos   = builder.Position;
            DynamicFloat tempRot   = builder.Rotation;

            if (arrayTest != null)
            {
                for (int i = 0; i < arrayTest.Length; i++)
                {
                    Danmaku danmaku = arrayTest[i];
                    if (danmaku != null)
                    {
                        builder.Position = danmaku.Position;
                        if (useRotation)
                        {
                            builder.Rotation = danmaku.Rotation;
                        }
                        builder.Fire();
                    }
                }
            }
            else
            {
                foreach (var danmaku in danmakus)
                {
                    if (danmaku != null)
                    {
                        builder.Position = danmaku.Position;
                        if (useRotation)
                        {
                            builder.Rotation = danmaku.Rotation;
                        }
                        builder.Fire();
                    }
                }
            }
            builder.Position = tempPos;
            builder.Rotation = tempRot;
            return(danmakus);
        }
 public static void GetInactive(Vector2 position, DynamicFloat rotation, Danmaku[] prealloc)
 {
     if (danmakuPool == null)
     {
         new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
     }
     danmakuPool.Get(prealloc);
     for (int i = 0; i < prealloc.Length; i++)
     {
         Danmaku danmaku = prealloc[i];
         danmaku.position.x = position.x;
         danmaku.position.y = position.y;
         danmaku.Rotation   = rotation.Value;
     }
 }
Exemplo n.º 13
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);
        }
 public static Danmaku[] GetInactive(Vector2 position, DynamicFloat rotation, DynamicInt count)
 {
     if (danmakuPool == null)
     {
         new GameObject("Danmaku Game Controller").AddComponent <DanmakuGameController>();
     }
     Danmaku[] array = new Danmaku[count];
     GetInactive(position, rotation, array);
     danmakuPool.Get(array);
     for (int i = 0; i < array.Length; i++)
     {
         Danmaku danmaku = array[i];
         danmaku.position.x = position.x;
         danmaku.position.y = position.y;
         danmaku.Rotation   = rotation.Value;
     }
     return(array);
 }
Exemplo n.º 15
0
 public FireBuilder WithRotation(float min, float max)
 {
     Rotation = new DynamicFloat(min, max);
     return(this);
 }
Exemplo n.º 16
0
 public FireBuilder WithAngularSpeed(DynamicFloat angularSpeed)
 {
     AngularSpeed = angularSpeed;
     return(this);
 }
Exemplo n.º 17
0
 public FireBuilder WithAngularSpeed(float min, float max)
 {
     AngularSpeed = new DynamicFloat(min, max);
     return(this);
 }
Exemplo n.º 18
0
        public void Fire()
        {
            Vector2      actualPosition = Position;
            DynamicFloat actualRotation = Rotation;

            if (positionSource != null)
            {
                actualPosition = positionSource.position;
            }

            if (rotationSource != null)
            {
                actualRotation = rotationSource.Rotation2D();
            }

            if (targeted)
            {
                if (targetPosition != null)
                {
                    actualRotation += DanmakuUtil.AngleBetween2D(actualPosition, (Vector2)targetPosition);
                }
                else if (targetObject != null)
                {
                    actualRotation += DanmakuUtil.AngleBetween2D(actualPosition, targetObject.position);
                }
            }

            Vector2      tempPos      = Position;
            DynamicFloat tempRotation = Rotation;

            Position = actualPosition;
            Rotation = actualRotation;

            if (modifiers.Count <= 0)
            {
                data.Fire();
            }
            else if (modifiers.Count == 1)
            {
                DanmakuModifier singleModifier = modifiers[0];
                if (singleModifier == null)
                {
                    data.Fire();
                }
                else
                {
                    singleModifier.Fire(data);
                }
            }
            else
            {
                DanmakuModifier[] oldSubModifiers = new DanmakuModifier[modifiers.Count];
                DanmakuModifier   previous = null, current, initial = null;
                for (int i = 0; i < oldSubModifiers.Length; i++)
                {
                    current = modifiers[i];
                    if (current != null)
                    {
                        oldSubModifiers[i] = current.SubModifier;
                        if (previous != null)
                        {
                            previous.SubModifier = current;
                        }
                        else
                        {
                            initial = current;
                        }
                        previous = current;
                    }
                }

                if (initial != null)
                {
                    initial.Fire(data);
                }
                else
                {
                    data.Fire();
                }

                for (int i = 0; i < oldSubModifiers.Length; i++)
                {
                    current = modifiers[i];
                    if (current != null)
                    {
                        current.SubModifier = oldSubModifiers[i];
                    }
                }
            }

            data.Position = tempPos;
            data.Rotation = tempRotation;
        }
Exemplo n.º 19
0
 public abstract void OnFire(Vector2 position, DynamicFloat rotation);
Exemplo n.º 20
0
 public FireBuilder WithSpeed(DynamicFloat speed)
 {
     Speed = speed;
     return(this);
 }
Exemplo n.º 21
0
 public FireBuilder WithRotation(DynamicFloat rotation)
 {
     Rotation = rotation;
     return(this);
 }