Example #1
0
        public TileEngine(Map m)
        {
            this.m = m;

            ee = new EntityEngine(new EntityEngineInterface(this));
            camera = new TileEngineCamera(m.width,m.height);

            foreach(Map.Entdef entdef in m.entdefs)
            {
                //todo
                //Entity e = ee.SpawnMapEntity(entdef);
                //mapEnts.add(e, entdef.descr, entdef.index);
            }

            foreach (Map.Zonedef zd in m.zonedefs)
            {
                Zone z = new Zone();
                z.bAdjacent = (zd.method == 1);
                z.chance = zd.percent / 255.0f;
                z.name = zd.name;
                z.script = zd.script;

                zones.Add(z);
            }

            ee.EntityActivated += new EntityEngine.EntityActivationHandler(ee_EntityActivated);
            ee.ZoneActivated += new EntityEngine.ZoneActivationHandler(ee_ZoneActivated);
        }
Example #2
0
        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);
            }
        }
Example #3
0
        private void renderLayer(bool bBottom, int xo, int yo, Map.TileLayer l, Blitter b)
        {
            int oxw = (int)((float)xo * l.parallax.X);
            int oyw = (int)((float)yo * l.parallax.Y);
            int xofs = -(oxw & 15);
            int yofs = -(oyw & 15);
            int xtc = oxw >> 4;
            int ytc = oyw >> 4;

            int tw = (b.width >> 4) + 2;
            int th = (b.height >> 4) + 2;

            b.BeginBatch();
            b.PushAlpha((float)((100 - (float)l.lucent) / 100.0));

            if(bBottom)
                for(int y = 0; y < th; y++)
                    for(int x = 0; x < tw; x++) {
                        int t = l.getTile(x + xtc, y + ytc);
                        if(t == 0) continue;
                        if(t == -1) {
                            if(fillLayer != null) {
                                t = fillLayer[(fillLayer.height + ((y + ytc) % fillLayer.height)) % fillLayer.height,
                                            (fillLayer.width + ((x + xtc) % fillLayer.width)) % fillLayer.width];
                            } else continue;
                        }

                        // Overkill: Takes animations into account.
                        t = m.vsp.tileIndex[t];

                        b.BlitSubrectBatched(m.vsp.tiles, (t & 127) << 4, ((t >> 7) << 4), 16, 16, xofs + x * 16, yofs + y * 16);
                    } else
                for(int y = 0; y < th; y++)
                    for(int x = 0; x < tw; x++) {
                        int t = l.getTile(x + xtc, y + ytc);
                        if(t < 1) continue;

                        // Overkill: Takes animations into account.
                        t = m.vsp.tileIndex[t];

                        b.BlitSubrectBatched(m.vsp.tiles, (t & 127) << 4, ((t >> 7) << 4), 16, 16, xofs + x * 16, yofs + y * 16);
                    }

            b.ExecuteSubrectBatch(m.vsp.tiles);
            b.PopAlpha();
        }
Example #4
0
        public void renderLayerFast(bool isBottom, int xo, int yo, Map.TileLayer l, Image dest)
        {
            //SimpleVertex[] v = new SimpleVertex[4];
            //v[0].x = v[0].y = 0;
            //v[1].x = dest.Width; v[0].y = 0;
            //v[2].x = dest.Width; v[2].y = dest.Height;
            //v[3].x = 0; v[3].y = dest.Height;

            //v[0].tu = xo / 16.0f;
            //v[0].tv = yo / 16.0f;
            //v[1].tu = v[0].tu + dest.Width / 16.0f;
            //v[1].tv = v[0].tv;
            //v[2].tu = v[1].tu;
            //v[2].tv = v[0].tv + dest.Height / 16.0f;
            //v[3].tu = v[0].tu;
            //v[3].tv = v[2].tv;

            //game.CustomRender();
            //game.Techniques.map.setTextures(l.tex, m.vsp.tiles.getTex());
            //game.Techniques.map.setParams(m.vsp.tilesW, m.vsp.tilesH, l.width, l.height);
            //game.Techniques.map.Activate();

            //game.SetPointFiltering(0); //tilemap HAS to be point filtering. make sure here
            ////game.setLinearFiltering(1); //in case we want linear filtering

            //if (isBottom)
            //    game.DisableAlphaBlend();

            //game.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, v, 0, 2);

            //if (isBottom)
            //    game.EnableAlphaBlend();
        }
Example #5
0
 public void UnloadMap()
 {
     CurrentMap = null;
     CurrentTileEngine = null;
 }
Example #6
0
        public void SwitchMap(String mapname, String startLoc)
        {
            UnloadMap();

            CurrentMap = new Map(mapname,this);
            CurrentMap.initTextures();
            CurrentTileEngine = new TileEngine(CurrentMap);
            CurrentMap.scriptHandler.InvokeOnload(startLoc);
            playerInput.UnpressAll();
        }