示例#1
0
 public SpawnCharacter(ActiveChar character, int charIndex)
 {
     this.charIndex = charIndex;
     this.charLoc = character.CharLoc;
     this.charDir = character.CharDir;
     this.form = character.CharData;
 }
示例#2
0
 public AddItem(ActiveMap map, int itemSlot)
 {
     this.itemSlot = itemSlot;
     Item item = map.Items[itemSlot];
     sprite = Data.GameData.ItemDex[item.ItemIndex].Sprite;
     itemLoc = item.ItemLoc;
 }
 public NormalMoveAnimation(Loc2D tileLoc, int animIndex, RenderTime animTime, int loops)
 {
     AnimationIndex = animIndex;
     FrameLength = animTime;
     TotalLoops = loops;
     StartLoc = new Loc2D(tileLoc.X, tileLoc.Y);
 }
示例#4
0
 public TextSprite(Loc2D loc, string text, Color4 color)
 {
     EffectLoc = loc;
     Text = text;
     ActionDone = false;
     Color = color;
 }
示例#5
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[1];

            rand = new Random(seed);

            MapArray = new Tile[10, 10];

            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                    GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                }
            }

            BorderPoints[0] = new Loc2D(0, 0);
        }
示例#6
0
 public Item()
 {
     ItemIndex = -1;
     Amount = 0;
     Tag = "";
     Disabled = false;
     ItemLoc = new Loc2D();
 }
示例#7
0
 public Item(int itemIndex, int amount, string tag, bool disabled, Loc2D loc)
 {
     ItemIndex = itemIndex;
     Amount = amount;
     Tag = tag;
     Disabled = disabled;
     ItemLoc = loc;
 }
示例#8
0
 public Player(Loc2D newLoc, Direction8 charDir)
 {
     CharLoc = newLoc;
     CharDir = charDir;
     dead = false;
     Name = "Hero";
     Initialize();
 }
示例#9
0
 public ItemAnim(Loc2D startLoc, Loc2D endLoc, int sprite, ItemAnimType action)
 {
     StartLoc = startLoc;
     EndLoc = endLoc;
     Sprite = sprite;
     Action = action;
     Loc2D diffLoc = startLoc - endLoc;
     TotalDistance = (int)(TextureManager.TILE_SIZE * Math.Sqrt(Math.Pow(diffLoc.X, 2) + Math.Pow(diffLoc.Y, 2)));
 }
示例#10
0
 public PathTile(Loc2D location, bool seen, bool traversed, int cost, int heuristic, PathTile backReference)
 {
     Location = location;
     Seen = seen;
     Traversed = traversed;
     Cost = cost;
     Heuristic = heuristic;
     BackReference = backReference;
 }
示例#11
0
 public Character(Loc2D newLoc, Direction8 charDir)
 {
     //clean variables
     BaseMoves = new Move[Processor.MAX_MOVE_SLOTS];
     for (int i = 0; i < Processor.MAX_MOVE_SLOTS; i++)
     {
         BaseMoves[i] = new Move();
     }
 }
示例#12
0
 //draw offset, height offset, and frame are determined on runtime based on
 //-CurrentAction
 //-ActionTime
 //-CharDir
 public CharSprite(Loc2D charLoc, Direction8 charDir)
 {
     this.charLoc = charLoc;
     this.CharDir = charDir;
     this.ActionDone = true;
     //everything else at default values
     //CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender is 0 for now
     CharData = new Gameplay.FormData();
 }
示例#13
0
 public BeamMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, RenderTime lastingTime)
 {
     StartLoc = startLoc;
     AnimationIndex = animIndex;
     FrameLength = animTime;
     Direction = dir;
     TotalDistance = distance;
     LastingTime = lastingTime;
 }
示例#14
0
 public ArrowMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, int speed)
 {
     StartLoc = startLoc;
     AnimationIndex = animIndex;
     FrameLength = animTime;
     Direction = dir;
     TotalWaves = distance;
     TotalDistance = distance*TextureManager.TILE_SIZE;
     TravelSpeed = speed;
 }
 public ItemThrowMoveAnimation(Loc2D startLoc, Loc2D endLoc, int animIndex, RenderTime animTime, int speed, bool dropDown)
 {
     StartLoc = startLoc;
     EndLoc = endLoc;
     AnimationIndex = animIndex;
     FrameLength = animTime;
     Loc2D diffLoc = startLoc-endLoc;
     TotalDistance = (int)(TextureManager.TILE_SIZE*Math.Sqrt(Math.Pow(diffLoc.X,2) + Math.Pow(diffLoc.Y,2)));
     TravelSpeed = speed;
     DropDown = dropDown;
 }
示例#16
0
 public FountainEmitter(Loc2D startLoc, int animIndex, int grainsPerBurst, RenderTime burstTime, int bursts, RenderTime animTime, int startDistance, int speed, RenderTime totalTime)
 {
     StartLoc = startLoc;
     AnimationIndex = animIndex;
     FrameLength = animTime;
     TotalTime = totalTime;
     GrainsPerBurst = grainsPerBurst;
     BurstTime = burstTime;
     TotalBursts = bursts;
     StartDistance = startDistance;
     Speed = speed;
 }
示例#17
0
 //float scale;
 //float scaleSpeed;
 //float rotation;
 //float rotationSpeed;
 public ParticleAnimation(int animationIndex, RenderTime frameLength, Loc2D newPosition, Loc2D newSpeed, Loc2D newAcceleration, Color4 newAlpha, Color4 newAlphaSpeed, RenderTime newMaxTime)
 {
     AnimationIndex = animationIndex;
     FrameLength = frameLength;
     MapLoc = newPosition;
     StartLoc = MapLoc;
     Speed = newSpeed;
     StartSpeed = Speed;
     Acceleration = newAcceleration;
     Color = newAlpha;
     ColorChange = newAlphaSpeed;
     TotalTime = newMaxTime;
 }
示例#18
0
        public Input(KeyboardDevice keyboard, MouseDevice mouse)
        {
            Loc2D dirLoc = new Loc2D();

            if (keyboard[Key.Down]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Down, 1);
            }
            if (keyboard[Key.Left]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Left, 1);
            }
            if (keyboard[Key.Up]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Up, 1);
            }
            if (keyboard[Key.Right]) {
                Operations.MoveInDirection8(ref dirLoc, Direction8.Right, 1);
            }

            dir = Operations.GetDirection8(new Loc2D(), dirLoc);

            inputStates[(int)InputType.X] = keyboard[Key.X];
            inputStates[(int)InputType.Z] = keyboard[Key.Z];
            inputStates[(int)InputType.C] = keyboard[Key.C];
            inputStates[(int)InputType.A] = keyboard[Key.A];
            inputStates[(int)InputType.S] = keyboard[Key.S];
            inputStates[(int)InputType.D] = keyboard[Key.D];

            inputStates[(int)InputType.Q] = keyboard[Key.Q];
            inputStates[(int)InputType.W] = keyboard[Key.W];

            inputStates[(int)InputType.Enter] = (keyboard[Key.Enter]);

            LeftMouse = mouse[MouseButton.Left];
            RightMouse = mouse[MouseButton.Right];

            MouseWheel = mouse.Wheel;

            MouseLoc = new Loc2D(mouse.X, mouse.Y);

            Shift = keyboard[Key.ShiftLeft] || keyboard[Key.ShiftRight];

            ShowDebug = keyboard[Key.F1];
            SpeedDown = keyboard[Key.F2];
            SpeedUp = keyboard[Key.F3];
            #if GAME_MODE
            Intangible = keyboard[Key.F4];
            Print = keyboard[Key.F5];
            Restart = keyboard[Key.F12];
            #endif
        }
示例#19
0
        public ActiveChar(Loc2D newLoc, Direction8 charDir)
        {
            //clean variables
            CharLoc = newLoc;
            CharDir = charDir;
            HP = MaxHP;
            Status = Enums.StatusAilment.OK;
            StatusCounter = 0;
            Moves = new MoveState[Processor.MAX_MOVE_SLOTS];
            for (int i = 0; i < Processor.MAX_MOVE_SLOTS; i++)
            {
                Moves[i] = new MoveState();
            }

            VolatileStatus = new Dictionary<string, ExtraStatus>();
        }
示例#20
0
        public MapEditor()
        {
            drawLock = new object();
            inAnimMode = false;
            chosenTile = new Loc2D();
            chosenTileset = 0;
            chosenAnim = new TileAnim();
            SetupLayerVisibility();

            InitializeComponent();

            if (tiles == null)
            {
                tiles = new List<Image>();
                for (int i = 0; i < 10; i++)
                {
                    tiles.Add(new Bitmap(Paths.TilesPath+"Tiles" + i + ".png"));
                }
            }

            RefreshTitle();

            if (!Directory.Exists(Paths.MapPath))
                Directory.CreateDirectory(Paths.MapPath);
            openFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath;
            saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath;

            tbTileset.Value = 0;

            nudTimeLimit.Maximum = Int32.MaxValue;

            for (int i = 0; i < 12; i++)
            {
                cbWeather.Items.Add(((Enums.Weather)i).ToString());
            }

            nudDarkness.Maximum = Int32.MaxValue;

            nudFrameLength.Maximum = Int32.MaxValue;

            RefreshTileset();
            RefreshAnimControls();

            ReloadMusic();

            LoadMapProperties();
        }
示例#21
0
 public Npc(Loc2D newLoc, Direction8 charDir, int npcIndex)
 {
     CharLoc = newLoc;
     CharDir = charDir;
     CharData.Species = npcIndex;
     if (npcIndex == 1) {
         Name = "Bandaid Mouse";
         Atk = 0;
         MaxHP = 8;
     } else if (npcIndex == 2) {
         Name = "Slime";
         Ability1 = "Slow Body";
         Atk = -2;
         MaxHP = 4;
     }
     Tactic = new AI(this);
     Initialize();
 }
示例#22
0
 public Loc2D(Loc2D loc)
 {
     X = loc.X;
     Y = loc.Y;
 }
示例#23
0
 public TileTarget(Loc2D tileLoc, int distance)
 {
     TileLoc = tileLoc;
     Distance = distance;
 }
示例#24
0
 public Loc(int charIndex, Loc2D newLoc)
 {
     this.charIndex = charIndex;
     this.newLoc = newLoc;
 }
示例#25
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[floorBorders.Count];

            rand = new Random(seed);

            MapArray = new Tile[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];
            GridArray = new GridType[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];

            Rooms = new DungeonArrayRoom[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"]]; //array of all rooms
            VHalls = new DungeonArrayHall[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"] - 1]; //vertical halls
            HHalls = new DungeonArrayHall[entry.FloorSettings["CellX"] - 1, entry.FloorSettings["CellY"]]; //horizontal halls
            StartRoom = new Loc2D(-1, -1);     //marks spawn point

            bool isDone;   // bool used for various purposes

            //initialize map array to empty
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    GridArray[x, y] = GridType.Blocked;
                }
            }

            //initialize all rooms+halls to closed by default
            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    Rooms[x, y] = new DungeonArrayRoom();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"] - 1; y++) {
                    VHalls[x, y] = new DungeonArrayHall();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"] - 1; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    HHalls[x, y] = new DungeonArrayHall();
                }
            }

            // path generation algorithm
            StartRoom = new Loc2D(rand.Next(0, entry.FloorSettings["CellX"]), rand.Next(0, entry.FloorSettings["CellY"])); // randomly determine start room
            Loc2D wanderer = StartRoom;

            int pathsMade = 0;
            int pathsNeeded = rand.Next(0, 6) + 5; // magic numbers, determine what the dungeon looks like (in general, paths)
            Direction4 prevDir = Direction4.None; // direction of movement
            do {
                if (rand.Next(0, (2 + pathsMade)) == 0) {//will end the current path and start a new one from the start
                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                    pathsMade++;
                    wanderer = StartRoom;
                    prevDir = Direction4.None;
                } else {
                    bool working = true;
                    do {
                        Loc2D sample = wanderer;
                        Direction4 nextDir = (Direction4)rand.Next(0, 4);
                        if (nextDir != prevDir) {//makes sure there is no backtracking
                            Operations.MoveInDirection4(ref sample, nextDir, 1);
                            prevDir = Operations.ReverseDir(nextDir);
                            if (sample.X >= 0 && sample.X < entry.FloorSettings["CellX"] && sample.Y >= 0 && sample.Y < entry.FloorSettings["CellY"]) {// a is the room to be checked after making a move between rooms
                                openHallBetween(wanderer, sample);
                                wanderer = sample;
                                working = false;
                            }
                        } else {
                            prevDir = Direction4.None;
                        }
                    } while (working);

                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                }
            } while (pathsMade < pathsNeeded);

            Rooms[StartRoom.X, StartRoom.Y].Opened = DungeonArrayRoom.RoomState.Open;

            //Determine key rooms
            isDone = false;
            do { //determine ending room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    EndRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            StartRoom = new Loc2D(-1, -1);

            isDone = false;
            do { //determine starting room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    StartRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            // begin part 2, creating ASCII map
            //create rooms

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        createRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        drawRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        padSingleRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        createVHall(i, j);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        createHHall(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        DrawHalls(VHalls[i, j]);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        DrawHalls(HHalls[i, j]);
                    }
                }
            }

            addSEpos(StartRoom, true);
            addSEpos(EndRoom, false);

            //texturing
            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    if (GridArray[x, y] == GridType.End) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.ChangeFloor, 1, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    } else if (GridArray[x, y] == GridType.Blocked) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Blocked, 0, 0, 0);

                        bool[] blockedDirs = new bool[8];
                        for (int n = 0; n < 8; n++) {
                            blockedDirs[n] = IsBlocked(x, y, (Direction8)n);
                        }
                        if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 0;
                            if (!blockedDirs[(int)Direction8.DownLeft])
                                layer += 8 * 2;

                            if (!blockedDirs[(int)Direction8.UpLeft])
                                layer += 1;

                            if (!blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            if (!blockedDirs[(int)Direction8.DownRight])
                                layer += 2;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 6;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 7;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 4;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 5;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 34;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 35;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 32;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 33;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(36, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(37, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(38, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(39, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(44, 0), 0);
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(45, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(46, 0), 0);

                    } else {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                }
            }

            GenItems();
            SpawnNpcs();
        }
示例#26
0
        void openHallBetween(Loc2D room1, Loc2D room2)
        {
            if (room1.X == room2.X) {
                int d = room2.Y - room1.Y;
                if (d == 1) {
                    VHalls[room1.X, room1.Y].Open = true;
                } else if (d == -1) {
                    VHalls[room2.X, room2.Y].Open = true;
                }
            } else if (room1.Y == room2.Y) {
                int d = room2.X - room1.X;
                if (d == 1) {
                    HHalls[room1.X, room1.Y].Open = true;
                } else if (d == -1) {
                    HHalls[room2.X, room2.Y].Open = true;
                }
            }

            //if (room2 < room1) {
            //    int temp = room1;
            //    room1 = room2;
            //    room2 = temp;
            //}
            //if (room2 - room1 == 1) { //horizontal
            //    x = room2 / 4;
            //    hhall[room1 - x] = DungeonArrayRoom.RoomState.Open;
            //} else { //vertical
            //    vhall[room1] = DungeonArrayRoom.RoomState.Open;
            //}
        }
示例#27
0
        public static void FillArray(int arrayWidth, int arrayHeight, TileCheck checkOp, TileOperation fillOp, Loc2D loc)
        {
            var stack = new Stack <StackItem>();

            stack.Push(new StackItem(loc.X, loc.X, loc.Y, Direction4.None, true, true));
            fillOp(loc.X, loc.Y);

            while (stack.Count > 0)
            {
                var        item    = stack.Pop();
                int        minX    = item.MinX;
                int        maxX    = item.MaxX;
                int        y       = item.Y;
                Direction4 dir     = item.Direction;
                bool       goLeft  = item.GoLeft;
                bool       goRight = item.GoRight;

                int newMinX = minX;
                if (goLeft)
                {
                    while (newMinX - 1 >= 0 && checkOp(newMinX - 1, y))
                    {
                        newMinX--;
                        fillOp(newMinX, y);
                    }
                }

                int newMaxX = maxX;
                if (goRight)
                {
                    while (newMaxX + 1 < arrayWidth && checkOp(newMaxX + 1, y))
                    {
                        newMaxX++;
                        fillOp(newMaxX, y);
                    }
                }

                minX--;
                maxX++;

                if (y < arrayHeight - 1)
                {
                    AddNextScanLine(checkOp, fillOp, minX, maxX, newMinX, newMaxX, y + 1, dir != Direction4.Up, Direction4.Down, stack);
                }

                if (y > 0)
                {
                    AddNextScanLine(checkOp, fillOp, minX, maxX, newMinX, newMaxX, y - 1, dir != Direction4.Down, Direction4.Up, stack);
                }
            }
        }
示例#28
0
        public static void Draw(int fps)
        {
            //draw menus on top
            //if (ShowTitle) {
            //    Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
            //    Graphics.TextureManager.TextureProgram.LeftMultModelView(
            //        Matrix4.CreateTranslation(TextureManager.SCREEN_WIDTH / 2 - TextureManager.Title.ImageWidth / 2,
            //        TextureManager.SCREEN_HEIGHT / 2 - TextureManager.Title.ImageHeight / 2, 1));
            //    Graphics.TextureManager.TextureProgram.UpdateModelView();
            //    Graphics.TextureManager.Title.Render(null);

            //    Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
            //    Gameplay.MenuManager.DrawMenus();

            //}
            float scale = GetZoomScale(Zoom);
            Loc2D camCenter = new Loc2D(FocusedCharacter.CharLoc.X * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2,
                FocusedCharacter.CharLoc.Y * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2);
            camCenter = camCenter + CamOffset;

            Loc2D camStart = new Loc2D((int)(camCenter.X - TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y - TextureManager.SCREEN_HEIGHT / scale / 2));
            Loc2D camEnd = new Loc2D((int)(camCenter.X + TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y + TextureManager.SCREEN_HEIGHT / scale / 2));
            Loc2D camStartTile = new Loc2D(camStart.X / TextureManager.TILE_SIZE - 1, camStart.Y / TextureManager.TILE_SIZE - 1);
            Loc2D camEndTile = new Loc2D(camEnd.X / TextureManager.TILE_SIZE + 1, camEnd.Y / TextureManager.TILE_SIZE + 1);

            //TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(TextureManager.SCREEN_WIDTH / 2, TextureManager.SCREEN_HEIGHT / 2, 0));
            //TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(-camCenter.X * scale, -camCenter.Y * scale, 0));
            TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(-camCenter.X * scale + TextureManager.SCREEN_WIDTH / 2, -camCenter.Y * scale + TextureManager.SCREEN_HEIGHT / 2, 0));
            TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(scale));
            //draw the background

            TextureManager.TextureProgram.PushModelView();
            TextureManager.TextureProgram.SetTextureColor(new Color4(128, 128, 128, 255));
            TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(Math.Min(Map.Width, camEndTile.X) * TextureManager.TILE_SIZE, Math.Min(Map.Height, camEndTile.Y) * TextureManager.TILE_SIZE, 1));
            TextureManager.TextureProgram.UpdateModelView();
            TextureManager.BlankTexture.Render(null);
            TextureManager.TextureProgram.SetTextureColor(Color4.White);
            TextureManager.TextureProgram.PopModelView();

            for (int j = camStartTile.Y; j <= camEndTile.Y; j++) {
                for (int i = camStartTile.X; i <= camEndTile.X; i++) {
                    //set tile sprite position
                    if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) {

                    } else {
                        Map.DrawGround(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i,j));
                        if (Turn) Graphics.TextureManager.GetTile(1, new Loc2D(1, 0)).Render(null);
                    }
                }
            }
            //draw items
            foreach (ItemAnim item in Items)
            {
                if (!item.ActionDone && IsSpriteInView(camStart, camEnd, item))
                {
                    item.Draw();
                }
            }

            //draw effects laid on ground
            List<ISprite> sortedSprites = new List<ISprite>();
            foreach (ISprite effect in Effects[EffectPriority.Ground]) {
                if (IsSpriteInView(camStart, camEnd, effect)) {
                    AddInOrder(sortedSprites, effect);
                }
            }
            int charIndex = 0;
            while (charIndex < sortedSprites.Count) {
                sortedSprites[charIndex].Draw();
                charIndex++;
            }

            //draw effects in object space
            sortedSprites = new List<ISprite>();

            //get all back effects, see if they're in the screen, and put them in the list, sorted
            foreach (ISprite effect in Effects[EffectPriority.Back]) {
                if (IsSpriteInView(camStart, camEnd, effect)) {
                    AddInOrder(sortedSprites, effect);
                }
            }
            if (ShowSprites)
            {
                //check if player is in the screen, put in list
                foreach (PlayerSprite player in Players)
                {
                    if (!player.Dead && IsSpriteInView(camStart, camEnd, player))
                    {
                        AddInOrder(sortedSprites, player);
                    }
                }
                //get all enemies, see if they're in the screen, and put them in the list, sorted
                foreach (NpcSprite npc in Npcs)
                {
                    if (!npc.Dead && IsSpriteInView(camStart, camEnd, npc))
                    {
                        AddInOrder(sortedSprites, npc);
                    }
                }
            }
            //get all effects, see if they're in the screen, and put them in the list, sorted
            foreach (ISprite effect in Effects[EffectPriority.None]) {
                if (IsSpriteInView(camStart, camEnd, effect)) {
                    AddInOrder(sortedSprites, effect);
                }
            }

            //draw object
            charIndex = 0;
            for (int j = camStartTile.Y; j <= camEndTile.Y; j++) {
                //before drawing objects, draw all active effects behind objects

                for (int i = camStartTile.X; i <= camEndTile.X; i++) {
                    //set tile sprite position
                    if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) {

                    }
                    else
                    {
                        Map.DrawPropBack(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i,j));
                    }
                }

                //after drawing objects of the row, draw characters whose locations are of between that row(inc) to the next(exc)
                while (charIndex < sortedSprites.Count)
                {
                    int charY = sortedSprites[charIndex].MapLoc.Y;
                    if (charY == j * TextureManager.TILE_SIZE)
                    {
                        sortedSprites[charIndex].Draw();
                        charIndex++;
                    }
                    else
                    {
                        break;
                    }
                }

                for (int i = camStartTile.X; i <= camEndTile.X; i++)
                {
                    //set tile sprite position
                    if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height)
                    {

                    }
                    else
                    {
                        Map.DrawPropFront(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j));
                    }
                }

                //after drawing objects of the row, draw characters whose locations are of between that row(inc) to the next(exc)
                while (charIndex < sortedSprites.Count)
                {
                    int charY = sortedSprites[charIndex].MapLoc.Y;
                    if (charY < (j + 1) * TextureManager.TILE_SIZE)
                    {
                        sortedSprites[charIndex].Draw();
                        charIndex++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //draw remaining sprites
            while (charIndex < sortedSprites.Count) {
                sortedSprites[charIndex].Draw();
                charIndex++;
            }

            //draw effects in top
            sortedSprites = new List<ISprite>();
            foreach (ISprite effect in Effects[EffectPriority.Top]) {
                if (IsSpriteInView(camStart, camEnd, effect)) {
                    AddInOrder(sortedSprites, effect);
                }
            }
            charIndex = 0;
            while (charIndex < sortedSprites.Count) {
                sortedSprites[charIndex].Draw();
                charIndex++;
            }

            //draw foreground
            for (int j = camStartTile.Y; j <= camEndTile.Y; j++) {
                for (int i = camStartTile.X; i <= camEndTile.X; i++) {
                    //set tile sprite position
                    if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) {

                    }
                    else
                    {
                        Map.DrawFringe(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j));

                        if (ShowGrid)
                        {
                            TextureManager.TextureProgram.PushModelView();
                            TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, 0));
                            TextureManager.TextureProgram.UpdateModelView();
                            Graphics.TextureManager.GetTile(10, new Loc2D()).Render(null);
                            TextureManager.TextureProgram.PopModelView();
                        }
                    }
                }
            }

            //draw effects in foreground
            sortedSprites = new List<ISprite>();
            foreach (ISprite effect in Effects[EffectPriority.Overlay]) {
                if (IsSpriteInView(camStart, camEnd, effect)) {
                    AddInOrder(sortedSprites, effect);
                }
            }
            charIndex = 0;
            while (charIndex < sortedSprites.Count) {
                sortedSprites[charIndex].Draw();
                charIndex++;
            }

            Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
            Gameplay.MenuManager.DrawMenus();

            //Moves
            Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
            if (Spell) {
                string[] keys = new string[4] { "S", "D", "X", "C" };
                TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(-240, 32, 0));
                for (int i = 0; i < Gameplay.Processor.MAX_MOVE_SLOTS; i++) {
                    TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(0, 64, 0));
                    Graphics.TextureManager.TextureProgram.UpdateModelView();

                    if (CurrentCharMoves[i] >= 0) {
                        Data.MoveEntry moveEntry = Data.GameData.MoveDex[CurrentCharMoves[i]];
                        TextureManager.SingleFont.RenderText(244, 20, keys[i] + ": (" + moveEntry.PP + "PP) " + moveEntry.Name, null, AtlasSheet.SpriteVOrigin.Top, AtlasSheet.SpriteHOrigin.Left, 0, Color4.White);
                    } else {
                        TextureManager.SingleFont.RenderText(244, 20, keys[i] + ": Empty", null, AtlasSheet.SpriteVOrigin.Top, AtlasSheet.SpriteHOrigin.Left, 0, Color4.White);
                    }
                }
            }

            //draw transitions
            if (CurrentFade == FadeType.FadeIn) {
                Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
                Graphics.TextureManager.TextureProgram.SetTextureColor(new Color4(0, 0, 0, (byte)(FadeTime.Ticks * 255 / TOTAL_FADE_TIME.Ticks)));
                Graphics.TextureManager.TextureProgram.LeftMultModelView(Matrix4.Scale(TextureManager.SCREEN_WIDTH, TextureManager.SCREEN_HEIGHT, 1));
                Graphics.TextureManager.TextureProgram.UpdateModelView();
                Graphics.TextureManager.BlankTexture.Render(null);
                Graphics.TextureManager.TextureProgram.SetTextureColor(Color4.White);
            } else if (CurrentFade == FadeType.FadeOut) {
                Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity);
                Graphics.TextureManager.TextureProgram.SetTextureColor(new Color4(0, 0, 0, (byte)(255 - FadeTime.Ticks * 255 / TOTAL_FADE_TIME.Ticks)));
                Graphics.TextureManager.TextureProgram.LeftMultModelView(Matrix4.Scale(TextureManager.SCREEN_WIDTH, TextureManager.SCREEN_HEIGHT, 1));
                Graphics.TextureManager.TextureProgram.UpdateModelView();
                Graphics.TextureManager.BlankTexture.Render(null);
                Graphics.TextureManager.TextureProgram.SetTextureColor(Color4.White);
            }

            if (ShowDebug)
            {
                DrawDebug(fps);
            }
        }
示例#29
0
 public static int Dot(Loc2D param1, Loc2D param2)
 {
     return(param1.X * param2.X + param1.Y * param2.Y);
 }
示例#30
0
 public static bool IsPointBetween(Loc2D loc1, Loc2D loc2, Loc2D p, bool x1Excl, bool x2Excl)
 {
     return(IsPointBetween(loc1.X, loc2.X, p.X, x1Excl, x2Excl) && IsPointBetween(loc1.Y, loc2.Y, p.Y, x1Excl, x2Excl));
 }
示例#31
0
 public static Direction8 GetDirection8(Loc2D loc1, Loc2D loc2)
 {
     return(GetDirection8(loc1.X, loc1.Y, loc2.X, loc2.Y));
 }
示例#32
0
 public static void MoveInDirection8(ref Loc2D loc, Direction8 dir, int length)
 {
     MoveInDirection8(ref loc.X, ref loc.Y, dir, length);
 }
示例#33
0
        public static void FillArray(int arrayWidth, int arrayHeight, TileCheck checkOp, TileOperation fillOp, Loc2D loc)
        {
            Stack <Tuple <int, int, int, Direction4, bool, bool> > stack = new Stack <Tuple <int, int, int, Direction4, bool, bool> >();

            stack.Push(new Tuple <int, int, int, Direction4, bool, bool>(loc.X, loc.X, loc.Y, Direction4.None, true, true));
            fillOp(loc.X, loc.Y);

            while (stack.Count > 0)
            {
                Tuple <int, int, int, Direction4, bool, bool> this_should_really_be_a_class = stack.Pop();
                Direction4 dir     = this_should_really_be_a_class.Item4;
                int        minX    = this_should_really_be_a_class.Item1;
                int        maxX    = this_should_really_be_a_class.Item2;
                int        y       = this_should_really_be_a_class.Item3;
                bool       goLeft  = this_should_really_be_a_class.Item5;
                bool       goRight = this_should_really_be_a_class.Item6;

                int newMinX = minX;
                if (goLeft)
                {
                    while (newMinX - 1 >= 0 && checkOp(newMinX - 1, y))
                    {
                        newMinX--;
                        fillOp(newMinX, y);
                    }
                }

                int newMaxX = maxX;
                if (goRight)
                {
                    while (newMaxX + 1 < arrayWidth && checkOp(newMaxX + 1, y))
                    {
                        newMaxX++;
                        fillOp(newMaxX, y);
                    }
                }

                minX--;
                maxX++;

                if (y < arrayHeight - 1)
                {
                    AddNextScanLine(checkOp, fillOp, minX, maxX, newMinX, newMaxX, y + 1, dir != Direction4.Up, Direction4.Down, stack);
                }

                if (y > 0)
                {
                    AddNextScanLine(checkOp, fillOp, minX, maxX, newMinX, newMaxX, y - 1, dir != Direction4.Down, Direction4.Up, stack);
                }
            }
        }
示例#34
0
        public static Loc2D ScreenCoordsToMapCoords(Loc2D loc)
        {
            float scale = GetZoomScale(Zoom);
            Loc2D camCenter = new Loc2D(FocusedCharacter.CharLoc.X * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2,
                FocusedCharacter.CharLoc.Y * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2);
            camCenter = camCenter + CamOffset;

            Loc2D camStart = new Loc2D((int)(camCenter.X - TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y - TextureManager.SCREEN_HEIGHT / scale / 2));
            Loc2D camEnd = new Loc2D((int)(camCenter.X + TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y + TextureManager.SCREEN_HEIGHT / scale / 2));

            loc.X = (int)(loc.X / scale);
            loc.Y = (int)(loc.Y / scale);
            loc += camStart;
            loc = loc - (camStart / TextureManager.TILE_SIZE * TextureManager.TILE_SIZE) + new Loc2D(TextureManager.TILE_SIZE);
            loc /= TextureManager.TILE_SIZE;
            loc = loc + (camStart / TextureManager.TILE_SIZE) - new Loc2D(1);

            return loc;
        }
示例#35
0
        void addSEpos(Loc2D point, bool isStart)
        {
            int x = 0, y = 0, u = 0, v = 0;
            bool end = !isStart;

            x = Rooms[point.X, point.Y].StartX;
            y = Rooms[point.X, point.Y].StartY;
            u = Rooms[point.X, point.Y].EndX;
            v = Rooms[point.X, point.Y].EndY;

            int randx = 0, randy = 0;
            for (int i = 0; i < 200; i++) {
                randx = rand.Next(x, u + 1);
                randy = rand.Next(y, v + 1);

                if (GridArray[randx, randy] == GridType.Walkable) {
                    if (end) {
                        BorderPoints[1] = new Loc2D(randx, randy);
                        GridArray[randx, randy] = GridType.End;
                    } else {
                        BorderPoints[0] = new Loc2D(randx, randy);
                    }
                    return;
                }
            }
            while (true) {//backup plan in case rooms are so small that all there's left is ","
                randx = rand.Next(x, u + 1);
                randy = rand.Next(y, v + 1);

                if (GridArray[randx, randy] == GridType.Hall || GridArray[randx, randy] == GridType.Walkable) {
                    if (end) {
                        BorderPoints[1] = new Loc2D(randx, randy);
                        GridArray[randx, randy] = GridType.End;
                    } else {
                        BorderPoints[0] = new Loc2D(randx, randy);
                    }
                    return;
                }
            }
        }
示例#36
0
 public TileAnim(Loc2D texture, int sheet)
 {
     Frames = new List <TileTexture>();
     Frames.Add(new TileTexture(texture, sheet));
     FrameLength = RenderTime.FromMillisecs(1);
 }
示例#37
0
        public static bool IsSpriteInView(Loc2D camStart, Loc2D camEnd, ISprite sprite)
        {
            if (sprite == null) return false;
            Loc2D spriteStart = sprite.GetStart();
            Loc2D spriteEnd = sprite.GetEnd();

            if (spriteStart == spriteEnd)
                return true;

            //check to see if the sprite's left is to the right of the screen's right side
            if (spriteStart.X > camEnd.X)
                return false;

            //check to see if the sprite's right is to the left of the screen's left side
            if (spriteEnd.X < camStart.X)
                return false;

            //check to see if the sprite's top is to the bottom of the screen's bottom side
            if (spriteStart.Y > camEnd.Y)
                return false;

            //check to see if the sprite's bottom is to the top of the screen's top side
            if (spriteEnd.Y < camStart.Y)
                return false;

            return true;
        }
示例#38
0
 void DrawHall(Loc2D point1, Loc2D point2, ref bool addedEntrance)
 {
     if (point1.X == point2.X) {
         if (point2.Y > point1.Y) {
             for (int i = point1.Y; i <= point2.Y; i++) {
                 DrawHallTile(point1.X, i, ref addedEntrance);
             }
         } else if (point2.Y < point1.Y) {
             for (int i = point1.Y; i >= point2.Y; i--) {
                 DrawHallTile(point1.X, i, ref addedEntrance);
             }
         }
     } else if (point1.Y == point2.Y) {
         if (point2.X > point1.X) {
             for (int i = point1.X; i <= point2.X; i++) {
                 DrawHallTile(i, point1.Y, ref addedEntrance);
             }
         } else if (point2.X < point1.X) {
             for (int i = point1.X; i >= point2.X; i--) {
                 DrawHallTile(i, point1.Y, ref addedEntrance);
             }
         }
     }
 }
示例#39
0
 public static int DistanceInFront(Loc2D loc1, Loc2D loc2, Direction4 dir)
 {
     return(DistanceInFront(loc1.X, loc1.Y, loc2.X, loc2.Y, dir));
 }
示例#40
0
 public TileTexture(Loc2D texture, int sheet)
 {
     Texture = texture;
     Sheet   = sheet;
 }