예제 #1
0
        private void GenerateOutpost(Submarine submarine)
        {
            Submarine outpost = OutpostGenerator.Generate(OutpostParams ?? OutpostGenerationParams.Params.GetRandom(), OutpostType ?? LocationType.List.GetRandom());

            outpost.SetPosition(Vector2.Zero);

            float       closestDistance = 0.0f;
            DockingPort myPort = null, outPostPort = null;

            foreach (DockingPort port in DockingPort.List)
            {
                if (port.IsHorizontal || port.Docked)
                {
                    continue;
                }
                if (port.Item.Submarine == outpost)
                {
                    outPostPort = port;
                    continue;
                }
                if (port.Item.Submarine != submarine)
                {
                    continue;
                }

                //the submarine port has to be at the top of the sub
                if (port.Item.WorldPosition.Y < submarine.WorldPosition.Y)
                {
                    continue;
                }

                float dist = Vector2.DistanceSquared(port.Item.WorldPosition, outpost.WorldPosition);
                if ((myPort == null || dist < closestDistance || port.MainDockingPort) && !(myPort?.MainDockingPort ?? false))
                {
                    myPort          = port;
                    closestDistance = dist;
                }
            }

            if (myPort != null && outPostPort != null)
            {
                Vector2 portDiff = myPort.Item.WorldPosition - submarine.WorldPosition;
                Vector2 spawnPos = (outPostPort.Item.WorldPosition - portDiff) - Vector2.UnitY * outPostPort.DockedDistance;

                submarine.SetPosition(spawnPos);
                myPort.Dock(outPostPort);
                myPort.Lock(true);
            }

            if (Character.Controlled != null)
            {
                Character.Controlled.TeleportTo(outpost.GetWaypoints(false).GetRandom(point => point.SpawnType == SpawnType.Human).WorldPosition);
            }
        }
예제 #2
0
        public void Generate(Level level, LocationType locationType, Point position, bool mirror = false)
        {
            Submarine           = OutpostGenerator.Generate(generationParams, locationType, onlyEntrance: false);
            Submarine.Info.Name = $"Ruin ({level.Seed})";
            Submarine.Info.Type = SubmarineType.Ruin;
            Submarine.TeamID    = CharacterTeamType.None;
            Submarine.SetPosition(position.ToVector2());

            if (mirror)
            {
                Submarine.FlipX();
            }

            Rectangle worldBorders = Submarine.Borders;

            worldBorders.Location += Submarine.WorldPosition.ToPoint();
            Area = new Rectangle(worldBorders.X, worldBorders.Y - worldBorders.Height, worldBorders.Width, worldBorders.Height);

            List <WayPoint> subWaypoints        = WayPoint.WayPointList.FindAll(wp => wp.Submarine == Submarine);
            int             interestingPosCount = 0;

            foreach (WayPoint wp in subWaypoints)
            {
                if (wp.SpawnType != SpawnType.Enemy)
                {
                    continue;
                }
                level.PositionsOfInterest.Add(new Level.InterestingPosition(wp.WorldPosition.ToPoint(), Level.PositionType.Ruin, this));
                interestingPosCount++;
            }

            if (interestingPosCount == 0)
            {
                //make sure there's at least on PositionsOfInterest in the ruins
                level.PositionsOfInterest.Add(new Level.InterestingPosition(subWaypoints.GetRandom(Rand.RandSync.Server).WorldPosition.ToPoint(), Level.PositionType.Ruin, this));
            }
        }