public Player(TmxObject e, Scene scene) : base(e, scene) { doesMove = true; _intro = false; if (e.Properties.ContainsKey("Intro")) { _intro = true; doesMove = false; } scene.ClearColor = Color.CornflowerBlue; _me = new GameObject("Player", scene, new Vector2((int)e.X + (int)e.Width / 2, (int)e.Y + (int)e.Height / 2)); _me.AddComponent("Collider", new CapsuleCollider(0, 10, 48, 48, 1f)); var rect = PolygonTools.CreateRectangle(.18f, .2f); rect.Translate(new Vector2(0, .35f)); var fixture = _me.Body.CreateFixture(new PolygonShape(rect, 2f)); fixture.IsSensor = true; fixture.OnSeparation += S; fixture.OnCollision += D; var i = _me.AddComponent("Texture", new Sprite(_me, "Player")); _sprite = (Sprite)_me.Components[i]; _sprite.LocalPosition = new Vector2(-32, -56); _sprite.Width = 64; _sprite.Height = 106; _sprite.Depth += 0.1f; var i2 = _me.AddComponent("animation", new Animator(new Vector2(640, 106), new Vector2(64, 106), 0.12f)); _animator = (Animator)_me.GetComponent(i2); scene.GameObjects.AddGameObject("Player", _me); _me.StaticRotation = true; _me.Body.Friction = 1.0f; _collidedWithBottomJumper = new List <Fixture>(); _collidedWithMainBody = new List <Fixture>(); _scene = (LevelScene)scene; _me.Body.OnCollision += Body_OnCollision; _me.Body.OnSeparation += Body_OnSeparation; scene.Camera.Target = _me.Position; var cameraMode = new SmoothFollowMode(scene.Camera); cameraMode.Delta *= 2; scene.Camera.CameraMode = cameraMode; scene.Camera.CenterOnObject = true; _enteringYSpeed = 0; _me.Tags.Add("Player"); }
public void LoadRowanScene(string map) { foreach (Scene i in this.LoadedScenes.Values) { i.Dispose(); } this.LoadedScenes.Clear(); _scene = (LevelScene)LoadScene("LevelScene"); _scene.Pipeline.LoadContent <Texture2D>("Player", Content, true); _scene.Pipeline.LoadContent <Texture2D>("Rowan", Content, true); _scene.Pipeline.LoadContent <Texture2D>("BadGuy", Content, true); _scene.Pipeline.LoadContent <Texture2D>("car", Content, true); _scene.Pipeline.LoadContent <Texture2D>("LightPole", Content, true); _scene.Pipeline.LoadContent <Texture2D>("RainDrop", Content, true); _scene.Pipeline.LoadContent <SpriteFont>("superfont", Content, true); _scene.Pipeline.LoadContent <Texture2D>("House", Content, true); _scene.Debug = false; SetScene("LevelScene"); System.Threading.Thread.Sleep(10); _scene.LoadRowanMap(map); }