ArcadeRigidbody CreateDrop(Vector2 position) { var rigidbody = new ArcadeRigidbody(); rigidbody.setElasticity(0.7f); var entity = createEntity("DROP: " + Utils.randomString(3)); entity.transform.position = position; entity.addComponent(new Drop(1)); entity.addComponent(rigidbody); entity.tag = 4; var collider = new BoxCollider(-2, -3, 4, 4); collider.collidesWithLayers = 10; collider.physicsLayer = 100; entity.addCollider(collider); var hitboxCollider = new BoxCollider(-10, -10, 20, 20); //hitboxCollider.isTrigger = true; hitboxCollider.collidesWithLayers = 0; hitboxCollider.physicsLayer = 100; entity.addCollider(hitboxCollider); return(rigidbody); }
private ArcadeRigidbody CreateEnemy(Vector2 position, string enemyType) { var rigidbody = new ArcadeRigidbody() .setMass(50000f) .setFriction(1) .setElasticity(0) .setVelocity(new Vector2(0, 0)); var entity = createEntity(enemyType + ": " + Utils.randomString(3)); entity.transform.position = position; entity.addComponent(new Enemy(enemyType)); entity.tag = 5; entity.addComponent(rigidbody); entity.addComponent(new SpotLight()); var collider = new BoxCollider(-6, -6, 13, 16); collider.collidesWithLayers = 10; //collider.physicsLayer = 101; entity.addCollider(collider); var hitboxCollider = new BoxCollider(7, -14, 20, 24); hitboxCollider.collidesWithLayers = 0; hitboxCollider.physicsLayer = 100; entity.addCollider(hitboxCollider); return(rigidbody); }
public override void OnAddedToScene() { this.Name = "Truck"; var dir = AddComponent(new DirectionComponent()); AddComponent(new PlayerInputComponent()); var animator = AddComponent(new SpriteAnimator()); AddComponent(new PlayerAnimationComponent()); animator.RenderLayer = Constants.Layer_Truck; animator.LayerDepth = 1; //var collider = AddComponent(new BoxCollider()); var collider = AddComponent(new PolygonCollider()); collider.PhysicsLayer = (int)Constants.PhysicsLayers.Player; collider.CollidesWithLayers = (int)Constants.PhysicsLayers.Buildings; var colliderManager = AddComponent(new ColliderManager(ContentPaths.Content + "truckcollision.json")); dir.OnDirectionChange += i => colliderManager.SetIndex((int)i); this.rb = AddComponent(new ArcadeRigidbody() { ShouldUseGravity = false, Elasticity = 0 }); AddComponent(new PlayerMovementComponent()); AddComponent(new WeaponComponent(new ScoopGun(), new PopsicleGun(), new BananaBigGun(), new BananaSmallGun())); }
public Ball() : base("Ball") { addComponent <BoxCollider>(); _rigidBody = new ArcadeRigidbody() .setMass(0.0001f) .setFriction(0f) .setElasticity(1f); _rigidBody.shouldUseGravity = false; addComponent(_rigidBody); }
private ArcadeRigidbody CreatePlayer(Vector2 position) { var rigidbody = new ArcadeRigidbody() .setMass(50000f) .setFriction(1) .setElasticity(0) .setVelocity(new Vector2(0, 0)); //var light = new AreaLight(100, 400).setRenderLayer(SCREEN_SPACE_RENDER_LAYER).setEnabled(true); var entity = createEntity("player"); entity.tag = 1; entity.transform.position = position; entity.addComponent(new Player()); entity.addComponent(rigidbody); entity.addComponent(new SpotLight()).setRenderLayer(200); var lightTex = contentManager.Load <Texture2D>("sprite-light"); //addSpriteLight(lightTex, new Vector2(50, 50), 2); //void addSpriteLight(Texture2D texture, Vector2 position, float scale) var sprite = new Sprite(lightTex); sprite.renderLayer = LIGHT_LAYER; entity.addComponent(sprite); var collider = new BoxCollider(-6, -6, 13, 16); collider.collidesWithLayers = 10; //collider.physicsLayer = 101; entity.addCollider(collider); var hitboxCollider = new BoxCollider(7, -14, 20, 24); hitboxCollider.collidesWithLayers = 0; hitboxCollider.physicsLayer = 100; entity.addCollider(hitboxCollider); var climbCollider = new BoxCollider(0, -5, 3, 16); climbCollider.collidesWithLayers = 0; climbCollider.physicsLayer = 100; entity.addCollider(climbCollider); return(rigidbody); }
ArcadeRigidbody createEntity(Vector2 position, float mass, float friction, float elasticity, Vector2 velocity, Texture2D texture) { var rigidbody = new ArcadeRigidbody() .setMass(mass) .setFriction(friction) .setElasticity(elasticity) .setVelocity(velocity); var entity = createEntity(Utils.randomString(3)); entity.position = position; entity.addComponent(new Sprite(texture)); entity.addComponent(rigidbody); entity.addComponent <CircleCollider>(); return(rigidbody); }
ArcadeRigidbody createEntity(Vector2 position, float mass, float friction, float elasticity, Vector2 velocity, Texture2D texture) { var rigidbody = new ArcadeRigidbody(); rigidbody.mass = mass; rigidbody.friction = friction; rigidbody.elasticity = elasticity; rigidbody.velocity = velocity; var entity = createEntity(Utils.randomString(3)); entity.transform.position = position; entity.addComponent(new Sprite(texture)) .addComponent(rigidbody) .colliders.add(new CircleCollider()); return(rigidbody); }
//private void DrawGrid() //{ // spriteBatch.Begin(); // for (int y = 0; y < 10; y ++) // { // for (int x = 0; x < 10; x++) // { // if (roomManager.rooms[y, x] != null) // { // // Draw a rect to represent the room // spriteBatch.Draw(whiteRectangle, new Rectangle(makeGridCoord(x), makeGridCoord(y), 64, 64), Color.White); // // Draw a little rect to show a link for each exit // if (roomManager.rooms[y, x].CheckValidExit(0) != -1) // { // spriteBatch.Draw(whiteRectangle, new Rectangle(makeDoorCoord(x, 32 + 16), makeDoorCoord(y, 32 - 2), 32, 2), Color.White); // } // if (roomManager.rooms[y, x].CheckValidExit(1) != -1) // { // spriteBatch.Draw(whiteRectangle, new Rectangle(makeDoorCoord(x, 32 + 64), makeDoorCoord(y, 32 + 16), 2, 32), Color.White); // } // if (roomManager.rooms[y, x].CheckValidExit(2) != -1) // { // spriteBatch.Draw(whiteRectangle, new Rectangle(makeDoorCoord(x, 32 + 16), makeDoorCoord(y, 32 + 64), 32, 2), Color.White); // } // if (roomManager.rooms[y, x].CheckValidExit(3) != -1) // { // spriteBatch.Draw(whiteRectangle, new Rectangle(makeDoorCoord(x, 32 - 2), makeDoorCoord(y, 32 + 16), 2, 32), Color.White); // } // } // } // } // spriteBatch.End(); //} ArcadeRigidbody createWallEntity(Vector2 position, float width, float height) { var rigidbody = new ArcadeRigidbody() .setMass(0) .setFriction(0) .setElasticity(1.0f); var entity = myScene.createEntity(Utils.randomString(3)); entity.transform.position = position; var spr = new PrototypeSprite(width, height); spr.color = Color.DarkGoldenrod; entity.addComponent(spr); entity.addComponent(rigidbody); entity.addCollider(new BoxCollider()); return(rigidbody); }
public override void Initialize() { base.Initialize(); //SetDesignResolution(504, 432, SceneResolutionPolicy.ShowAllPixelPerfect); Screen.SetSize(504 * 2, 432 * 2); var mapEntity = this.CreateEntity("map", new Vector2(Screen.Width / 2, Screen.Height / 2)); mapEntity.AddComponent(new Forest()); var mapEntity2 = this.CreateEntity("map2", new Vector2(Screen.Width / 2 + Screen.Width, Screen.Height / 2)); mapEntity2.AddComponent(new Forest()); var mapEntity3 = this.CreateEntity("map2", new Vector2(Screen.Width / 2 - Screen.Width, Screen.Height / 2)); mapEntity3.AddComponent(new Forest()); var playerEntity = this.CreateEntity("player", new Vector2(Screen.Width / 2, Screen.Height / 2)); var rigidBody = new ArcadeRigidbody(); playerEntity.AddComponent(new Player()); playerEntity.AddComponent(rigidBody); rigidBody.SetMass(1000); var collider = playerEntity.AddComponent(new CircleCollider(9.0f)); var topLeft = new Vector2(-50000f, -100f); var bottomRight = new Vector2(50000f, 850f); mapEntity.AddComponent(new CameraBounds(topLeft, bottomRight)); // we only want to collide with the tilemap, which is on the default layer 0 Flags.SetFlagExclusive(ref collider.CollidesWithLayers, 0); Debug.DrawHollowRect(Camera.Bounds, Color.Green, 10000); Camera.Entity.AddComponent(new FollowCamera(playerEntity, Camera, FollowCamera.CameraStyle.CameraWindow)); var followCamera = Camera.Entity.GetComponent <FollowCamera>(); followCamera.SetCenteredDeadzone(20, 4); Debug.DrawHollowRect(followCamera.Deadzone, Color.Red, 10000); }
ArcadeRigidbody CreateShroom(Vector2 position) { var rigidBody = new ArcadeRigidbody(); rigidBody.setMass(0); var entity = createEntity("SHROOM: " + Utils.randomString(3)); entity.transform.position = position; entity.addComponent(rigidBody); entity.addComponent(new Shroom()); entity.tag = 30; var collider = new BoxCollider(-8, -8, 16, 16); collider.collidesWithLayers = 10; collider.physicsLayer = 100; entity.addCollider(collider); return(rigidBody); }
public override void onAddedToEntity() { base.onAddedToEntity(); _body = entity.getComponent <ArcadeRigidbody>(); SetupInput(); }
public override void initialize() { //Core.debugRenderEnabled = true; var particlesEntity = createEntity("particles"); particlesEntity.transform.setPosition(new Vector2(128, 72)); particlesEntity.addComponent(new Snow()); //var particleSystemConfig = contentManager.Load<Sprite>("ParticleDesigner/Snow"); //_snowParticleEmitter = particlesEntity.addComponent(new ParticleEmitter(particleSystemConfig)); Core.defaultSamplerState = SamplerState.PointClamp; // setup a pixel perfect screen that fits our map setDesignResolution(256, 144, Scene.SceneResolutionPolicy.ShowAllPixelPerfect); Screen.setSize(256 * 5, 144 * 5); Screen.isFullscreen = false; int[] RENDERABLES_LAYER = { 1, 0, 10, 20, 11 }; LIGHT_LAYER = 200; SCREEN_SPACE_RENDER_LAYER = 999; //var deferredRenderer = addRenderer(new DeferredLightingRenderer(0, LIGHT_LAYER, RENDERABLES_LAYER)).setClearColor(Color.Transparent); //deferredRenderer.enableDebugBufferRender = false; addRenderer(new RenderLayerRenderer(0, RENDERABLES_LAYER)); addRenderer(new ScreenSpaceRenderer(100, SCREEN_SPACE_RENDER_LAYER)); addRenderer(new RenderLayerExcludeRenderer(0, 998, SCREEN_SPACE_RENDER_LAYER, LIGHT_LAYER)); var lightRenderer = addRenderer(new RenderLayerRenderer(-1, LIGHT_LAYER)); lightRenderer.renderTexture = new RenderTexture(); var valueInt = 0; lightRenderer.renderTargetClearColor = new Color(50, 50, 50, 255); //lightRenderer.renderTargetClearColor = new Color(116, 135, 97, 255); CreateUI(); _shroomList = new List <Entity>(); Transform.shouldRoundPosition = false; _world = new World(); playerEntity = CreatePlayer(new Vector2(50, 200)); _player = playerEntity.entity.getComponent <Player>(); DisplayHealthBar(); _spriteLightPostProcessor = addPostProcessor(new SpriteLightPostProcessor(0, lightRenderer.renderTexture)); UpdateTileMap(new Vector2(100, 100), false); //var graph = new WeightedGridGraph(); var cameFrom = new Dictionary <Vector2, Vector2>(); var tiled = contentManager.Load <TiledMap>(_world.activeRoom.tilemap); // add a component to have the Camera follow the player camera.entity.addComponent(new FollowCamera(playerEntity.entity)); }
protected override void Begin() { truck = (Truck)Scene.FindEntity("Truck"); truckrb = truck.GetComponent <ArcadeRigidbody>(); }