Example #1
0
 public new void Move(Tile.Direction dir)
 {
     //DIRECT CLONE OF CHARACTER MOVE -- KEEP UPDATED
     if (travel.X == 0 && travel.Y == 0){
         this.dir = dir;
         animation = animations[dir.ToString()];
         if (GetTileCollision() && GetBuildingCollision() && GetEventCollision()){
             if (!animation.running) animation.Start();
             else animation.running = true;
             if (dir == Tile.Direction.NORTH){
                 travel.Y = +0.01f;
                 Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] + 1 });
             }
             if (dir == Tile.Direction.SOUTH){
                 travel.Y = -0.01f;
                 Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] - 1 });
             }
             if (dir == Tile.Direction.EAST){
                 travel.X = +0.01f;
                 Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] + 1, GetMapPos()[1] });
             }
             if (dir == Tile.Direction.WEST){
                 travel.X = -0.01f;
                 Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] - 1, GetMapPos()[1] });
             }
         }
     }
 }
Example #2
0
 public OWPlayer(string texturePath, int[] mapPos, Tile.Direction dir)
     : base(texturePath, mapPos, dir, "Player")
 {
     this.texturePath = texturePath;
     mapX = mapPos[0];
     mapY = mapPos[1];
     mapZ = mapPos[2];
     SetDir(dir);
 }
 public Character(string texturePath, int[] mapPos, Tile.Direction dir, string name)
 {
     this.texturePath = texturePath;
     mapX = mapPos[0];
     mapY = mapPos[1];
     mapZ = mapPos[2];
     this.dir = dir;
     this.name = name;
 }
Example #4
0
 public TileMap(string name, Tile[,,] tiles, IEvent[,,] events, Building[] buildings, int numNonNull, int eventNonNull)
 {
     this.name = name;
     this.tiles = tiles;
     this.events = events;
     this.buildings = buildings;
     this.numNonNull = numNonNull;
     this.eventNonNull = eventNonNull;
 }
 public SlidingDoor(string texturePath, int[] mapPos, int[] destPos, Tile.Direction dir, Tile.Direction playerDir, string mapDestKey)
 {
     this.texturePath = texturePath;
     mapX = mapPos[0];
     mapY = mapPos[1];
     mapZ = mapPos[2];
     this.destPos = destPos;
     this.dir = dir;
     this.playerDir = playerDir;
     this.mapDestKey = mapDestKey;
     passage = true;
 }
Example #6
0
 public void Move(Tile.Direction dir)
 {
     if (dir == Tile.Direction.NORTH){
         //jump
     }else if (dir == Tile.Direction.SOUTH){
         //crouch
     }else if (dir == Tile.Direction.EAST){
         velocity.X = speed;
         animation = animations["Walking"];
         flipped = false;
     }else if (dir == Tile.Direction.WEST){
         velocity.X = -speed;
         animation = animations["Walking"];
         flipped = true;
     }
 }
 public SlidingDoor(string texturePath, int[] mapPos, int[] destPos, Tile.Direction dir, Tile.Direction playerDir, Rectangle section, string mapDestKey)
     : this(texturePath, mapPos, destPos, dir, playerDir, mapDestKey)
 {
     this.section = section;
 }
 public EventPage(string texturePath, int[] mapPos, Tile.Direction dir, Movement movement, EventCommands script, string name)
     : base(texturePath, mapPos, dir, name)
 {
     this.movement = movement;
         this.script = script;
 }
 public void SetDir(Tile.Direction dir)
 {
     this.dir = dir;
     if (animations != null){
         animation = animations[dir.ToString()];
         animation.PauseSet(0);
     }
     travel = new Vector2(0f);
 }
        private TileMap ParseFile(HashSet<string> input)
        {
            Tile[, ,] tiles;
            IEvent[,,] events;
            Building[] buildings;
            ScriptedEvent[, ,] se;
            string mapName, line;
            int mapL, mapW, mapH, numNonNull, numEvents, numBuildings, buildingNum = 0;

            line = input.ElementAt(0);
            line = line.Substring(line.IndexOf('(') + 1).Trim();
            mapName = line.Substring(0, line.IndexOf(','));
            line = line.Substring(line.IndexOf('[') + 1).Trim();
            mapL = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            mapW = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            mapH = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numNonNull = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numEvents = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numBuildings = System.Convert.ToInt32(line.Substring(0, line.IndexOf(')')));

            tiles = new Tile[mapL, mapW, mapH];
            events = new IEvent[mapL, mapW, mapH];
            buildings = new Building[numBuildings];
            se = ScriptInvoke.GetScriptedEvents(mapName, new int[3] { events.GetLength(0), events.GetLength(1), events.GetLength(2) });
            numEvents += ScriptInvoke.GetNumEvents(mapName);

            //Basic Data down!

            for (int i = 1; i < input.Count; i++){
                line = input.ElementAt(i).Trim();

                if (line[0] == 'T'){
                    int[] arrayPos = new int[3];
                    int[] mapPos = new int[3];
                    Tile.TileStyle style = Tile.TileStyle.FLAT;
                    Tile.Direction dir, secondDir;
                    line = line.Substring(line.IndexOf('[') + 1).Trim();

                    arrayPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    arrayPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    arrayPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']')).Trim());
                    line = line.Substring(line.IndexOf('(') + 1).Trim();

                    style = (Tile.TileStyle)Enum.Parse(typeof(Tile.TileStyle),
                        line.Substring(0, line.IndexOf(',')).Trim(), true);
                    line = line.Substring(line.IndexOf('{') + 1).Trim();
                    mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());

                    if (line.IndexOf(',') == -1){
                        tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                            style,
                            mapPos,
                            null,
                            null);
                    }else{
                        line = line.Substring(line.IndexOf(',') + 1).Trim();
                        if (line.IndexOf(',') == -1){
                            dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true);
                            tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                            style,
                            mapPos,
                            dir,
                            null);
                        }else{
                            dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                            line = line.Substring(line.IndexOf(',') + 1).Trim();
                            if (line.IndexOf(',') == -1){
                                secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true);
                                tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                                style,
                                mapPos,
                                dir,
                                secondDir);
                            }else{
                                secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                                line = line.Substring(line.IndexOf('{') + 1).Trim();
                                bool[] passage = new bool[4];
                                passage[0] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[1] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[2] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[3] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf('}')).Trim());
                                if(line.IndexOf(',') == -1){
                                    tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                                        style,
                                        mapPos,
                                        dir,
                                        secondDir
                                        );
                                        tiles[arrayPos[0], arrayPos[1], arrayPos[2]].passage = passage;
                                    }else{
                                        line = line.Substring(line.IndexOf('\'')).Trim();
                                        string tPath = line.Substring(0, line.IndexOf('\'')).Trim();
                                        tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                                            style,
                                            tPath,
                                            mapPos,
                                            passage,
                                            dir,
                                            secondDir
                                            );
                                    }
                                }
                            }
                        }

                }else if (line[0] == 'C'){
                    //make me a character!
                    string texturePath = "";
                    int[] mapPos = new int[3];
                    Tile.Direction dir;

                    line = line.Substring(line.IndexOf('\'') + 1).Trim();
                    texturePath = line.Substring(0, line.IndexOf('\'')).Trim();
                    line = line.Substring(line.IndexOf('{') + 1).Trim();

                    mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();

                    dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true);
                    events[mapPos[0], mapPos[1], mapPos[2]] = new OWPlayer(texturePath, mapPos, dir);
                }else if (line[0] == 'S' && line[1] == 'D'){
                    //make me a sliding door!
                    //SD('Images/Events/slidingDoor',{3,2,0},SOUTH,[],'stairMap');
                    string texturePath = "";
                    int[] mapPos = new int[3];
                    int[] destPos = new int[3];
                    Tile.Direction dir, playerDir;
                    bool givenSect;
                    Rectangle section = new Rectangle(0, 0, 0, 0);
                    string mapDestKey = "";

                    line = line.Substring(line.IndexOf('\'') + 1).Trim();
                    texturePath = line.Substring(0, line.IndexOf('\'')).Trim();
                    line = line.Substring(line.IndexOf('{') + 1).Trim();

                    mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());
                    line = line.Substring(line.IndexOf('{') + 1).Trim();

                    destPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    destPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    destPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();

                    dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    playerDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                    line = line.Substring(line.IndexOf('[') + 1).Trim();

                    givenSect = (line[0] != ']');

                    if (givenSect){
                        float x = System.Convert.ToSingle(line.Substring(0,line.IndexOf(',')).Trim());
                        line = line.Substring(line.IndexOf(',') + 1).Trim();
                        float y = System.Convert.ToSingle(line.Substring(0, line.IndexOf(',')).Trim());
                        line = line.Substring(line.IndexOf(',') + 1).Trim();
                        float w = System.Convert.ToSingle(line.Substring(0, line.IndexOf(',')).Trim());
                        line = line.Substring(line.IndexOf(',') + 1).Trim();
                        float h = System.Convert.ToSingle(line.Substring(0, line.IndexOf(']')).Trim());
                        section = new Rectangle((int)x, (int)y, (int)w, (int)h);
                    }
                    line = line.Substring(line.IndexOf('\'') + 1).Trim();
                    mapDestKey = line.Substring(0, line.IndexOf('\'')).Trim();

                    if (givenSect)
                        events[mapPos[0], mapPos[1], mapPos[2]] = new SlidingDoor(texturePath, mapPos, destPos, dir, playerDir, section, mapDestKey);
                    else
                        events[mapPos[0], mapPos[1], mapPos[2]] = new SlidingDoor(texturePath, mapPos, destPos, dir, playerDir, mapDestKey);
                }else if (line[0] == 'B'){
                    //make me a building
                    //"B(Block264Tex,{5,6,0});"+
                    Name name;
                    int[] mapPos = new int[3];
                    line = line.Substring(line.IndexOf('(') + 1).Trim();
                    string str = line.Substring(0, line.IndexOf(',')).Trim();
                    name = (Name)Enum.Parse(typeof(Name), str, true);
                    line = line.Substring(line.IndexOf('{') + 1).Trim();
                    mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());

                    buildings[buildingNum] = new Building(name, mapPos);
                    buildingNum++;
                }
            }

            for (int i = 0; i < se.GetLength(0); i++){
                for (int j = 0; j < se.GetLength(1); j++){
                    for (int k = 0; k < se.GetLength(2); k++){
                        if (se[i, j, k] != null)
                            events[i, j, k] = se[i, j, k];
                    }
                }
            }
            return new TileMap(mapName, tiles, events, buildings, numNonNull, numEvents);
        }
 public void SetTileMap(string mapName, int[] destPos, Tile.Direction dir)
 {
     TileMap nextMap = tileMaps[mapName];
     nextMap.player = tileMap.player;
     nextMap.player.SetMapPos(destPos);
     nextMap.Initialize();
     nextMap.player.SetDir(dir);
     tileMap = nextMap;
 }