예제 #1
0
        private void AddProjectileSpawns(List <KeyValuePair <Guid, int> > spawnDeaths)
        {
            for (byte x = 0; x < ProjectileBase.SPAWN_LOCATIONS_WIDTH; x++)
            {
                for (byte y = 0; y < ProjectileBase.SPAWN_LOCATIONS_HEIGHT; y++)
                {
                    for (byte d = 0; d < ProjectileBase.MAX_PROJECTILE_DIRECTIONS; d++)
                    {
                        if (Base.SpawnLocations[x, y].Directions[d] == true && mSpawnedAmount < Spawns.Length)
                        {
                            var s = new ProjectileSpawn(
                                FindProjectileRotationDir(Dir, d),
                                (byte)(X + FindProjectileRotationX(Dir, x - 2, y - 2)),
                                (byte)(Y + FindProjectileRotationY(Dir, x - 2, y - 2)), (byte)Z, MapId, Base, this
                                );

                            Spawns[mSpawnedAmount] = s;
                            mSpawnedAmount++;
                            mSpawnCount++;
                            if (CheckForCollision(s))
                            {
                                s.Dead = true;
                            }
                        }
                    }
                }
            }

            mQuantity++;
            mSpawnTime = Globals.Timing.Milliseconds + Base.Delay;
        }
예제 #2
0
 public void KillSpawn(ProjectileSpawn spawn)
 {
     if (spawn != null && Spawns.Contains(spawn))
     {
         for (var i = 0; i < Spawns.Length; i++)
         {
             if (spawn == Spawns[i])
             {
                 Spawns[i]?.Dispose(i);
                 Spawns[i] = null;
                 mSpawnCount--;
             }
         }
     }
 }
예제 #3
0
        public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
        {
            float newx     = spawn.X;
            float newy     = spawn.Y;
            var   newMapId = spawn.MapId;

            if (move)
            {
                spawn.Distance++;
                spawn.TransmittionTimer += (long)((float)Base.Speed / (float)Base.Range);
                newx = spawn.X + GetRangeX(spawn.Dir, 1);
                newy = spawn.Y + GetRangeY(spawn.Dir, 1);
            }

            var killSpawn = false;
            var map       = MapInstance.Get(spawn.MapId);

            if (Math.Round(newx) < 0)
            {
                if (MapInstance.Get(map.Left) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Left;
                    newx     = Options.MapWidth - 1;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (Math.Round(newx) > Options.MapWidth - 1)
            {
                if (MapInstance.Get(map.Right) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Right;
                    newx     = 0;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (Math.Round(newy) < 0)
            {
                if (MapInstance.Get(map.Up) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Up;
                    newy     = Options.MapHeight - 1;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (Math.Round(newy) > Options.MapHeight - 1)
            {
                if (MapInstance.Get(map.Down) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Down;
                    newy     = 0;
                }
                else
                {
                    killSpawn = true;
                }
            }

            spawn.X     = newx;
            spawn.Y     = newy;
            spawn.MapId = newMapId;

            return(killSpawn);
        }
예제 #4
0
        public bool CheckForCollision(ProjectileSpawn spawn)
        {
            var killSpawn = MoveFragment(spawn, false);

            //Check Map Entities For Hits
            var map = MapInstance.Get(spawn.MapId);

            if (!killSpawn && map != null)
            {
                var attribute = map.Attributes[(int)spawn.X, (int)spawn.Y];

                //Check for Z-Dimension
                if (!spawn.ProjectileBase.IgnoreZDimension)
                {
                    if (attribute != null && attribute.Type == MapAttributes.ZDimension)
                    {
                        if (((MapZDimensionAttribute)attribute).GatewayTo > 0)
                        {
                            spawn.Z = (byte)(((MapZDimensionAttribute)attribute).GatewayTo - 1);
                        }
                    }
                }

                //Check for grapplehooks.
                if (attribute != null &&
                    attribute.Type == MapAttributes.GrappleStone &&
                    Base.GrappleHook == true &&
                    !spawn.Parent.HasGrappled)
                {
                    if (spawn.Dir <= 3) //Don't handle directional projectile grapplehooks
                    {
                        spawn.Parent.HasGrappled = true;

                        //Only grapple if the player hasnt left the firing position.. if they have then we assume they dont wanna grapple
                        if (Owner.X == X && Owner.Y == Y && Owner.MapId == MapId)
                        {
                            Owner.Dir = spawn.Dir;
                            new Dash(
                                Owner, spawn.Distance, (byte)Owner.Dir, Base.IgnoreMapBlocks,
                                Base.IgnoreActiveResources, Base.IgnoreExhaustedResources, Base.IgnoreZDimension
                                );
                        }

                        killSpawn = true;
                    }
                }

                if (attribute != null &&
                    (attribute.Type == MapAttributes.Blocked || attribute.Type == MapAttributes.Animation && ((MapAnimationAttribute)attribute).IsBlock) &&
                    !spawn.ProjectileBase.IgnoreMapBlocks)
                {
                    killSpawn = true;
                }
            }

            if (!killSpawn && map != null)
            {
                var entities = map.GetEntities();
                for (var z = 0; z < entities.Count; z++)
                {
                    if (entities[z] != null &&
                        (entities[z].X == Math.Round(spawn.X) || entities[z].X == Math.Ceiling(spawn.X) || entities[z].X == Math.Floor(spawn.X)) &&
                        (entities[z].Y == Math.Round(spawn.Y) || entities[z].Y == Math.Ceiling(spawn.Y) || entities[z].Y == Math.Floor(spawn.Y)) &&
                        entities[z].Z == spawn.Z)
                    {
                        killSpawn = spawn.HitEntity(entities[z]);
                        if (killSpawn && !spawn.ProjectileBase.PierceTarget)
                        {
                            return(killSpawn);
                        }
                    }
                    else
                    {
                        if (z == entities.Count - 1)
                        {
                            if (spawn.Distance >= Base.Range)
                            {
                                killSpawn = true;
                            }
                        }
                    }
                }
            }

            return(killSpawn);
        }
예제 #5
0
        public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
        {
            int newx     = spawn.X;
            int newy     = spawn.Y;
            var newMapId = spawn.MapId;

            if (move)
            {
                spawn.Distance++;
                newx = spawn.X + GetRangeX(spawn.Dir, 1);
                newy = spawn.Y + GetRangeY(spawn.Dir, 1);
            }

            var killSpawn = false;
            var map       = MapInstance.Get(spawn.MapId);

            if (newx < 0)
            {
                if (MapInstance.Get(map.Left) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Left;
                    newx     = Options.MapWidth - 1;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (newx > Options.MapWidth - 1)
            {
                if (MapInstance.Get(map.Right) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Right;
                    newx     = 0;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (newy < 0)
            {
                if (MapInstance.Get(map.Up) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Up;
                    newy     = Options.MapHeight - 1;
                }
                else
                {
                    killSpawn = true;
                }
            }

            if (newy > Options.MapHeight - 1)
            {
                if (MapInstance.Get(map.Down) != null)
                {
                    newMapId = MapInstance.Get(spawn.MapId).Down;
                    newy     = 0;
                }
                else
                {
                    killSpawn = true;
                }
            }

            spawn.X     = (byte)newx;
            spawn.Y     = (byte)newy;
            spawn.MapId = newMapId;

            return(killSpawn);
        }