// Start is called before the first frame update void Start() { camReference = Camera.main.GetComponent <WorldMapCamera>(); gcReference = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); transform.position = gcReference.positionToLoad; canMove = true; canInteract = true; }
private void LoadMap(string assetName) { //List of Portals declared for traveling between World map and scrolling levels Statics.Portals = new List <Portal>(); Statics.ClipMap = new Dictionary <Vector2, Rectangle>(); map = content.Load <Map>(assetName); camera = new WorldMapCamera(new Vector2(map.Width, map.Height), new Vector2(map.TileWidth, map.TileHeight), new Vector2(Statics.Game.GraphicsDevice.Viewport.Width, Statics.Game.GraphicsDevice.Viewport.Height)); MapObjectLayer objects = map.GetLayer("Objects") as MapObjectLayer; //Read in information about portals from tmx file foreach (MapObject obj in objects.Objects) { switch (obj.Name) { case "PlayerStart": if (Statics.WorldPlayer == null) { Statics.WorldPlayer = new WorldPlayer(new Vector2(obj.Location.X + (obj.Location.Width / 2), obj.Location.Y), new Vector2(91f, 91f)); Statics.WorldPlayer.LoadContent(content, "Sprites\\Characters\\Warrior1WalkLeft"); Statics.WorldPlayer.Map = map; } else { Statics.WorldPlayer.Position = new Vector2(obj.Location.X + (obj.Location.Width / 2), obj.Location.Y); } break; case "Portal1": case "Portal2": case "Portal3": case "Portal4": Portal portal = new Portal(); portal.Position = new Vector2(obj.Location.X, obj.Location.Y); portal.Size = new Vector2(obj.Location.Width, obj.Location.Height); portal.LevelName = obj.Properties["LevelName"].Value; string[] tileLoc = obj.Properties["DestinationTileLocation"].Value.Split(','); portal.DestinationTileLocation = new Vector2(Convert.ToInt32(tileLoc[0]), Convert.ToInt32(tileLoc[1])); Statics.Portals.Add(portal); break; } } Statics.WorldPlayer.UpdateBounds(map.TileWidth, map.TileHeight); // camera.FocusOn(Statics.WorldPlayer); LoadClipMap(); }
public void Update(GameTime gameTime, WorldMapCamera camera) { if (!IsAnimating) { return; } if (totalFrames == -1) { totalFrames = 1 * 1; } timer += (float)gameTime.ElapsedGameTime.TotalSeconds; }
static int get_m_viewChangeFrame(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; float ret = obj.m_viewChangeFrame; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_viewChangeFrame on a nil value" : e.Message)); } }
static int get_IsCanMoved(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; bool ret = obj.IsCanMoved; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsCanMoved on a nil value" : e.Message)); } }
static int get_m_pWorldMap(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; WorldMap ret = obj.m_pWorldMap; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_pWorldMap on a nil value" : e.Message)); } }
static int set_IsCanMoved(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.IsCanMoved = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsCanMoved on a nil value" : e.Message)); } }
static int set_m_viewChangeFrame(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.m_viewChangeFrame = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_viewChangeFrame on a nil value" : e.Message)); } }
static int set_m_pWorldMap(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WorldMapCamera obj = (WorldMapCamera)o; WorldMap arg0 = (WorldMap)ToLua.CheckUnityObject(L, 2, typeof(WorldMap)); obj.m_pWorldMap = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_pWorldMap on a nil value" : e.Message)); } }
// Use this for initialization void Start() { // 获取脚本函数 object[] param = { this }; object[] ret = LuaFun.worldMapStart.Call(param); m_nMaxWidth = float.Parse(ret[0].ToString()); m_nMaxHeight = float.Parse(ret[1].ToString()); MAP_TILEWIDTH = float.Parse(ret[2].ToString()); MAP_TILEHEIGHT = float.Parse(ret[3].ToString()); // 把自己的赋给摄像机 m_pWorldMapCamera = transform.Find("MapCamera").GetComponent <WorldMapCamera>(); m_pWorldMapCamera.m_pWorldMap = this; // 菱形顶点 _Limit = new Vector4(-m_nMaxWidth * MAP_TILEWIDTH / 200f + 0.5f, m_nMaxWidth * MAP_TILEWIDTH / 200f - 0.5f, -m_nMaxHeight * MAP_TILEHEIGHT / 200f + 0.5f, m_nMaxHeight * MAP_TILEHEIGHT / 200f - 0.5f); m_MapUnitRoot = this.transform.Find("MapUnitRoot"); }