public MapScriptHandler(String mapFilename, Map map, RpgController rpgController) { basename = FindBaseName(mapFilename); mapScript = null; mapScriptType = null; // Attempt to instanciate class try { //string classname = String.Format("Cabedge.Cabedge+Map_{0}", basename); Type t = GameEngine.Game.FindMeAFuckingType(basename); if (t != null) { mapScriptType = t; if (t.IsSubclassOf(typeof(MapScript))) { mapScript = (MapScript)Activator.CreateInstance(t); mapScript.init(map, this, rpgController); } else { Console.WriteLine("WARNING: Found class 'Map_{0}' but it does not extend MapScript!!", basename); } } else { Console.WriteLine("WARNING: Did not find Map_{0}.", basename); } } catch (TypeLoadException ex) { Console.WriteLine("WARNING: Did not find Map_{0}.", basename, ex); } catch (AmbiguousMatchException ex) { Console.WriteLine("WARNING: Found multiple matching classes.", ex); } }
static void Main(string[] args) { System.Diagnostics.Debug.WriteLine("hello world"); mgame = new MGame(); //dont want to deal with resourcemanager for now ResourceManager.OverrideEnableBegin(false); rpgController = new RpgController(mgame.player1); mgame.run(); }
public RpgController(PlayerInput playerInput) { this.playerInput = playerInput; if (RpgController.rpg == null) RpgController.rpg = this; }
public Map(string fname, RpgController rpgController) { scriptHandler = new MapScriptHandler(fname, this, rpgController); Stream s = ResourceManager.Open(fname); BinaryReader br = new BinaryReader(s); //signature string str = StringBufferReader.read(s,6); if(str != "V3MAP") throw new NotAMapFileException(fname); //version int version = br.ReadInt32(); if(version != 2) throw new MapFileBrokenException("Wrong version; expected 2; received " + version.ToString(),fname); try { //vc offset (skipped) br.ReadInt32(); //mapname,vspname,musicname,renderstring,startupscript name = StringBufferReader.read(s,256); vspfile = StringBufferReader.read(s,256); musicfile = StringBufferReader.read(s,256); rstring = StringBufferReader.read(s,256); initscript = StringBufferReader.read(s,256); //startloc start.X = br.ReadInt16(); start.Y = br.ReadInt16(); //layers int numLayers = br.ReadInt32(); layers = new TileLayer[numLayers]; for(int i=0;i<numLayers;i++) { TileLayer tl = layers[i] = new TileLayer(); tl.loadFromv32stream(br); } width = layers[0].width; height = layers[0].height; //special layers logicalLayer = new LogicalLayer(width,height); logicalLayer.obs = new Layer(); logicalLayer.obs.loadSpecialFromv32stream(8,width,height,br); logicalLayer.zone = new Layer(); logicalLayer.zone.loadSpecialFromv32stream(16,width,height,br); //zones int numZonedefs = br.ReadInt32(); zonedefs = new Zonedef[numZonedefs]; for(int i=0;i<numZonedefs;i++) { zonedefs[i] = new Zonedef(); zonedefs[i].name = StringBufferReader.read(s,256); zonedefs[i].script = StringBufferReader.read(s,256); zonedefs[i].percent = br.ReadByte(); zonedefs[i].delay = br.ReadByte(); zonedefs[i].method = br.ReadByte(); } //entities int numEntdefs = br.ReadInt32(); entdefs = new Entdef[numEntdefs]; for(int i=0;i<numEntdefs;i++) { entdefs[i] = new Entdef(); entdefs[i].index = i; entdefs[i].x = br.ReadInt16(); entdefs[i].y = br.ReadInt16(); entdefs[i].facing = (Directions)br.ReadByte(); if(entdefs[i].facing == Directions.None) entdefs[i].facing = Directions.s; entdefs[i].obstructable = br.ReadByte()==1; entdefs[i].obstruction = br.ReadByte()==1; entdefs[i].autoface = br.ReadByte()==1; entdefs[i].speed = br.ReadInt16(); //convert this to carot ticks? br.ReadByte();//activation mode entdefs[i].mode = br.ReadByte(); entdefs[i].x1 = br.ReadInt16(); entdefs[i].y1 = br.ReadInt16(); entdefs[i].x2 = br.ReadInt16(); entdefs[i].y2 = br.ReadInt16(); entdefs[i].wanderDelay = br.ReadInt16();//convert this to carot ticks? br.ReadInt32();//wtf? entdefs[i].moveScript = StringBufferReader.read(s,256); entdefs[i].chrname = StringBufferReader.read(s,256); entdefs[i].descr = StringBufferReader.read(s,256); entdefs[i].script = StringBufferReader.read(s,256); } } catch(Exception e) { throw new MapFileBrokenException("Something is wrong with the mapfile. Here's what happened:\n" + e.Message,fname); } //load up the vsp try { vsp = new VSP(Lib.GetAccompanyingFilePath(fname,vspfile)); } catch(FileNotFoundException e) {throw new VspFileNotFoundException(e.Message); } br.Close(); }
public void tick() { switch(state) { case GameController.State.Loading: rpgBackbuffer = cabedge.NewImage(320, 240); uiController = new UiController(); rpgController = new RpgController(cabedge.player1); //rpgController.SwitchMap("raw/dock.map"); rpgController.SwitchMap("raw/city01.map"); rpgController.CreatePlayer("raw/man4.chr", 7, 15); man = rpgController.CreateEntity("raw/man3.chr", 8, 11); man.bCanHurry = false; man.activationScript = "Test1"; cabedge.loading(); state = State.InGame; goto case GameController.State.InGame; case State.MainMenu: goto case State.InGame; case State.InGame: rpgController.tick(); uiController.tick(); /*if(player1.Confirm) { player1.Confirm.unpress(); uiController.textOpen(); }*/ break; } }