void Awake() { anim = gameObject.GetComponent <Animator>(); phys = gameObject.GetComponent <Collider2D>(); rb = gameObject.GetComponent <Rigidbody2D>(); legs = gameObject.GetComponent <SpriteRenderer>(); blood = transform.Find("Blood").GetComponent <SpriteRenderer>(); body = transform.Find("Body").GetComponent <SpriteRenderer>(); sg = transform.Find("Ground").GetComponent <SimpleGround>(); sw = transform.Find("Wall").GetComponent <SimpleWall>(); groundCollider = transform.Find("Ground").GetComponent <Collider2D>(); wallCollider = transform.Find("Wall").GetComponent <Collider2D>(); }
public override void _Ready() { var size = GetViewportRect().Size; const int floorHeight = 25; const int offset = 50; // Add left floor var leftFloor = new SimpleWall() { BodySize = new Vector2(size.x / 2.5f, floorHeight), Position = new Vector2((size.x / 2.5f / 2) + offset, size.y) }; AddChild(leftFloor); // Add right floor var rightFloor = new SimpleWall() { BodySize = new Vector2(size.x / 2.5f, floorHeight), Position = new Vector2(size.x - (size.x / 2.5f / 2) - offset, size.y - (offset * 2)) }; AddChild(rightFloor); var spawner = new SimpleTouchSpawner() { SpawnFunction = (position) => { return(new DoubleBall() { Distance = 20, Radius = 10, RotationDegrees = MathUtils.RandRangef(0, 360), GlobalPosition = position }); } }; AddChild(spawner); const int bodyCount = 10; for (int i = 0; i < bodyCount; ++i) { spawner.SpawnBody(MathUtils.RandVector2(offset * 2, size.x - (offset * 2), offset * 2, size.y - (offset * 2))); } }
public override void _Ready() { var size = GetViewportRect().Size; var wall = new SimpleWall() { BodySize = new Vector2(size.x, 50), Position = new Vector2(size.x / 2, size.y) }; AddChild(wall); var spawner = new SimpleTouchSpawner() { SpawnFunction = (position) => { var chance = MathUtils.RandRangef(0, 3); SimplePolygon polygon = null; if (chance < 1) { polygon = new Polygon1(); } else if (chance < 2) { polygon = new Polygon2(); } else { polygon = new Polygon3(); } polygon.GlobalPosition = position; return(polygon); } }; AddChild(spawner); const int polygonCount = 10; for (int i = 0; i < polygonCount; ++i) { spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y)); } }
public override void _Ready() { var size = GetViewportRect().Size; const int floorHeight = 25; const int offset = 50; // Add left floor var leftFloor = new SimpleWall() { BodySize = new Vector2(size.x / 2.5f, floorHeight), Position = new Vector2((size.x / 2.5f / 2) + offset, size.y) }; AddChild(leftFloor); // Add right floor var rightFloor = new SimpleWall() { BodySize = new Vector2(size.x / 2.5f, floorHeight), Position = new Vector2(size.x - (size.x / 2.5f / 2) - offset, size.y - (offset * 2)) }; AddChild(rightFloor); var spawner = new SimpleTouchSpawner() { SpawnFunction = (position) => { return(new Polygon() { GlobalPosition = position }); } }; AddChild(spawner); const int polygonCount = 10; for (int i = 0; i < polygonCount; ++i) { spawner.SpawnBody(MathUtils.RandVector2(offset * 2, size.x - (offset * 2), offset * 2, size.y - (offset * 2))); } }
public override void _Ready() { var size = GetViewportRect().Size; var box = new SimpleBox() { Position = size / 2 }; AddChild(box); box.AddChild(new SimpleMouseJoint()); var floor = new SimpleWall() { BodySize = new Vector2(size.x, 100), Position = new Vector2(size.x / 2, size.y) }; AddChild(floor); }
public override void _Ready() { var size = GetViewportRect().Size; var floor = new SimpleWall() { BodySize = new Vector2(size.x, 100), Position = new Vector2(size.x / 2, size.y) }; AddChild(floor); var spawner = new SimpleTouchSpawner() { SpawnFunction = (position) => { return(new CollisionBall() { GlobalPosition = position }); } }; AddChild(spawner); }