public Vector2 AdjacentPosition(Rectangle against, ScreenDirection side, int offset)
        {
            Vector2 position = new Vector2(against.Left, against.Top);

            int roundUp(int inp)
            {
                while (inp % 8 != 0)
                {
                    inp++;
                }
                return(inp);
            }

            switch (side)
            {
            case ScreenDirection.Up:
                return(position + new Vector2(offset * 8, -roundUp(this.Level.Bounds.Height)));

            case ScreenDirection.Down:
                return(position + new Vector2(offset * 8, roundUp(against.Height)));

            case ScreenDirection.Left:
                return(position + new Vector2(-roundUp(this.Level.Bounds.Width), offset * 8));

            case ScreenDirection.Right:
            default:
                return(position + new Vector2(roundUp(against.Width), offset * 8));
            }
        }
Beispiel #2
0
 public Hole(ScreenDirection Side, int LowBound, int HighBound, bool HighOpen)
 {
     this.Side      = Side;
     this.LowBound  = LowBound;
     this.HighBound = HighBound;
     this.HighOpen  = HighOpen;
 }
        public static void YamlSkeleton(MapData map)
        {
            foreach (LevelData lvl in map.Levels)
            {
                List <Hole> holes = RandoLogic.FindHoles(lvl);
                if (holes.Count > 0)
                {
                    Logger.Log("randomizer", $"  - Room: \"{lvl.Name}\"");
                    Logger.Log("randomizer", "    Holes:");
                }
                ScreenDirection lastDirection = ScreenDirection.Up;
                int             holeIdx       = -1;
                foreach (Hole hole in holes)
                {
                    if (hole.Side == lastDirection)
                    {
                        holeIdx++;
                    }
                    else
                    {
                        holeIdx       = 0;
                        lastDirection = hole.Side;
                    }

                    LevelData targetlvl = map.GetAt(hole.LowCoord(lvl.Bounds)) ?? map.GetAt(hole.HighCoord(lvl.Bounds));
                    if (targetlvl != null)
                    {
                        Logger.Log("randomizer", $"    - Side: {hole.Side}");
                        Logger.Log("randomizer", $"      Idx: {holeIdx}");
                        Logger.Log("randomizer", "      Kind: inout");
                    }
                }
            }
        }
    public static void AddSelf(GameObject go, ScreenDirection sd = ScreenDirection.vertical)
    {
        SubPanelPosition spp = go.GetComponent <SubPanelPosition>();

        if (spp == null)
        {
            spp = go.AddComponent <SubPanelPosition>();
        }
        spp.screenDirection = sd;
    }
        public static ScreenDirection Opposite(this ScreenDirection self)
        {
            switch (self)
            {
            case ScreenDirection.Up:
                return(ScreenDirection.Down);

            case ScreenDirection.Down:
                return(ScreenDirection.Up);

            case ScreenDirection.Left:
                return(ScreenDirection.Right);

            case ScreenDirection.Right:
            default:
                return(ScreenDirection.Left);
            }
        }
        public static Vector2 Unit(this ScreenDirection self)
        {
            switch (self)
            {
            case ScreenDirection.Up:
                return(-Vector2.UnitY);

            case ScreenDirection.Down:
                return(Vector2.UnitY);

            case ScreenDirection.Left:
                return(-Vector2.UnitX);

            case ScreenDirection.Right:
                return(Vector2.UnitX);

            default:
                return(Vector2.Zero);
            }
        }
Beispiel #7
0
        public static void YamlSkeleton(MapData map, bool doUnknown = true)
        {
            foreach (LevelData lvl in map.Levels)
            {
                if (lvl.Dummy)
                {
                    continue;
                }
                List <Hole> holes = RandoLogic.FindHoles(lvl);
                if (holes.Count > 0)
                {
                    Logger.Log("randomizer", $"  - Room: \"{lvl.Name}\"");
                    Logger.Log("randomizer", "    Holes:");
                }
                ScreenDirection lastDirection = ScreenDirection.Up;
                int             holeIdx       = -1;
                foreach (Hole hole in holes)
                {
                    if (hole.Side == lastDirection)
                    {
                        holeIdx++;
                    }
                    else
                    {
                        holeIdx       = 0;
                        lastDirection = hole.Side;
                    }

                    LevelData targetLvl = map.GetAt(hole.LowCoord(lvl.Bounds)) ?? map.GetAt(hole.HighCoord(lvl.Bounds));
                    var       unknown   = targetLvl == null || targetLvl.Dummy;
                    if (unknown && !doUnknown)
                    {
                        continue;
                    }

                    Logger.Log("randomizer", $"    - Side: {hole.Side}");
                    Logger.Log("randomizer", $"      Idx: {holeIdx}");
                    Logger.Log("randomizer", "      Kind: " + (unknown ? "unknown" : "inout"));
                }
            }
        }
        public Rectangle AdjacentBounds(Rectangle against, ScreenDirection side, int offset)
        {
            var pos = this.AdjacentPosition(against, side, offset);

            return(new Rectangle((int)pos.X, (int)pos.Y, this.Level.Bounds.Width, this.Level.Bounds.Height));
        }