public static Node Create(Vector3 pos) { var cmp = new MyDeadBox (); var spr = new Sprite (128, 128); spr.AddTexture (new Texture ("media/Image128x128(Red).png")); spr.Color = Color.Gray; var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var body = new PhysicsBody (); body.Shape = col; body.IsTrigger = true; var node = new Node ("DeadBox"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.Attach (body); node.Translation = pos; return node; }
public override void OnMouseButtonReleased(MouseButton button, float x, float y) { var pos = Graphics2D.GetInstance ().GetMousePosition (); if (button == MouseButton.Left) { x = Math.Min (start.X, pos.X); y = Math.Min (start.Y, pos.Y); var width = (int)MyMath.Clamp (Math.Abs (pos.X - start.X), 2, 1200); var height = (int)MyMath.Clamp (Math.Abs (pos.Y - start.Y), 2, 1800); var mycol = new BoxCollision (width / 2, height / 2, 0); mycol.SetOffset (x + width / 2, y + height / 2, 0); var mytra = Node.GlobalTransform; var tanks = from node in World.Downwards where node.Name == "MyTank" let tank = node.GetComponent<MyTank> () let col = node.GetComponent<Collision> () let tra = node.GlobalTransform where col != null where Physics2D.Distance (col, tra, mycol, mytra) == 0 select tank; foreach (var tank in tanks) { tank.Selected = true; } this.start = new Vector2 (0, 0); Node.Drawable = false; } }
// Update is called once per frame void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.zero); if (hit.collider != null) { if (hit.collider.tag == "Box") { print("Box"); selectedBox = hit.collider.gameObject; } if (hit.collider.tag == "Tree") { hit.collider.gameObject.SendMessage("OnClick"); } } } if (Input.GetKeyUp(KeyCode.Mouse0)) { selectedBox = null; } if (selectedBox != null) { BoxCollision box = selectedBox.GetComponent <BoxCollision>(); float newX = Mathf.Clamp(mousePos.x, box.startPos.x - box.maxXChange, box.startPos.x + box.maxXChange); selectedBox.transform.position = new Vector3(newX, selectedBox.transform.position.y, selectedBox.transform.position.z); } }
private static void setCollision(Entity obj, BoxCol collider) { BoxCollision col = obj.GetComponent <BoxCollision>(); //col.Position = new Vector(collider.Rectangle.X / (float)tilemap.TileWidth, collider.Rectangle.Y / (float)tilemap.TileHeight); //col.Scale = new Vector(collider.Rectangle.Width / (float)tilemap.TileWidth, collider.Rectangle.Height / (float)tilemap.TileHeight); //col.TriggerOnly = collider.TriggerOnly; }
public override void Initialize() { physics = GetComponent <Physics>(); transform = GetComponent <Transform>(); boxCollision = GetComponent <BoxCollision>(); animation = GetComponent <Animation>(); sprite = GetComponent <Sprite>(); stateMachine = GetComponent <StateMachine>(); particleSystem = GetComponent <ParticleSystem>(); gun = SceneManager.GetCurrentScene().CreateEntity <Gun>(); stateMachine.States.Add("idle", idle); stateMachine.States.Add("walk left", walkLeft); stateMachine.States.Add("walk right", walkRight); stateMachine.States.Add("jump", jump); stateMachine.States.Add("falling", falling); stateMachine.States.Add("next level", nextLevel); stateMachine.CurrentState = "idle"; particleSystem.Color = Color.WhiteSmoke; boxCollision.HandleCollision = handleCollision; isGrounded = false; waitTime = 0; levelnum = 1; Camera.Zoom = 3; }
private static void setCollision(Entity obj, Rectangle collider, Tile tile) { BoxCollision col = obj.GetComponent <BoxCollision>(); col.Position = new Vector(collider.X, collider.Y); col.Scale = new Vector(collider.Width / (float)tilemap.TileWidth, collider.Height / (float)tilemap.TileHeight); col.TriggerOnly = tile.Properties.ContainsKey("Trigger") ? (tile.Properties["Trigger"] == "true") : false; }
void Start() { target = GameObject.Find("RotSheet").transform; redSheet = GameObject.Find("RedSheet").GetComponent <RedSheet>(); boxCollision = GameObject.Find("BoxCollision").GetComponent <BoxCollision>(); audioSource = gameObject.GetComponent <AudioSource>(); }
public override void Initialize() { Transform = GetComponent <Transform>(); boxCollision = GetComponent <BoxCollision>(); boxCollision.HandleCollision = handleCollision; Name = "CharacterPickup"; }
public override void Initialize() { Name = "Key"; Transform = GetComponent <Transform>(); boxCollision = GetComponent <BoxCollision>(); Transform.Scale = Transform.Scale * MapConstants.Scale; boxCollision.HandleCollision = handleCollision; }
private bool checkCollision(BoxCollision collider1, BoxCollision collider2, Transform transform1, Transform transform2) { p1 = collider1.Position + transform1.Position; p2 = collider2.Position + transform2.Position; s1 = collider1.Scale * transform1.Scale; s2 = collider2.Scale * transform2.Scale; return(p1.X < p2.X + s2.X && p1.X + s1.X > p2.X && p1.Y < p2.Y + s2.Y && p1.Y + s1.Y > p2.Y); }
public override void Initialize() { physics = GetComponent <Physics>(); transform = GetComponent <Transform>(); collision = GetComponent <BoxCollision>(); sprite = GetComponent <Sprite>(); sprite.Color = Color.Gray; collision.HandleCollision = handleCollision; }
public static Node Create(int slot, Node charNode, Node tankNode) { var cha = charNode.GetComponent<MyCharacter> (); var tank = tankNode.GetComponent<MyTank> (); var cmp = new MyCard (); cmp.tank = tankNode; cmp.character = charNode; // 背景 var spr1 = new Sprite (256, 128); spr1.Color = Color.Gray; // 顔 var spr2 = new Sprite (128, 128); spr2.AddTexture (cha.FaceTexture); // 戦車 var spr3 = new Sprite (32, 64); spr3.AddTexture (tank.TankTexture); spr3.SetOffset (128 + 6, 6); // 戦車名 var label1 = new Label (); label1.Text = tank.TankName; label1.SetOffset (128 + 6 + 32 + 6, 6); // HP var hp = new Bar (4, 96, BarOrientation.Horizontal); hp.MaxValue = tank.MaxHp; hp.CurrentValue = tank.Hp; hp.SetOffset (128 + 6, 64 + 6); // クリック var col = new BoxCollision (128, 64, 0); col.SetOffset (128, 64, 0); var node = new Node ("Card"); node.Attach (cmp); node.Attach (spr1); node.Attach (spr2); node.Attach (spr3); node.Attach (label1); node.Attach (hp); node.Attach (col); node.DrawPriority = -10; node.Translate (12+(256+4)*slot, 600, 0); // キャラクター -> マイカード cha.MyCard = node; return node; }
void Update() { Box _thisBox = new Box(gameObject); foreach (var obj in _boxesObj) { Box box = new Box(obj); Vector3 result = BoxCollision.Collision(_thisBox, box); if (result.magnitude != 0) { gameObject.transform.position -= result; } } }
public void HandlePhysics() { foreach (Entity entity in Entities) { Componets.Transform transform = entity.GetComponent <Componets.Transform>(); Physics physics = entity.GetComponent <Physics>(); transform.Position += physics.Velocity; // Check Collision if (entity.HasComponent <BoxCollision>()) { BoxCollision boxCollision = entity.GetComponent <BoxCollision>(); IBox collidedBox = null; foreach (IBox box in boxCollision.Boxes) { BoxData data = (BoxData)box.Data; var move = box.Move(transform.Position.X + data.Position.X * transform.Scale.X, transform.Position.Y + data.Position.Y * transform.Scale.Y, (collision) => { if (!collision.Other.HasTag(data.Layer)) { if (!data.TriggerOnly) { collidedBox = box; return(CollisionResponses.Slide); } else { // Trigger Collision return(CollisionResponses.Cross); } } return(CollisionResponses.None); }); } if (collidedBox != null) { BoxData boxData = (BoxData)collidedBox.Data; transform.Position = new Vector(collidedBox.X - transform.Scale.X * boxData.Position.X, collidedBox.Y - transform.Scale.Y * boxData.Position.Y); } } } }
void Start() { normal = Resources.Load("Texture/StageBlock/Materials/W2", typeof(Material)) as Material; red = Resources.Load("Texture/StageBlock/Materials/R1", typeof(Material)) as Material; green = Resources.Load("Texture/StageBlock/Materials/G1", typeof(Material)) as Material; block = gameObject.GetComponent <Renderer>(); player = GameObject.Find("Player").GetComponent <Renderer>(); sheet = GameObject.Find("Sheet").GetComponent <Renderer>(); boxCollision = GameObject.Find("BoxCollision").GetComponent <BoxCollision>(); target = GameObject.Find("Target").GetComponent <Transform>(); audioSource = gameObject.GetComponent <AudioSource>(); swap = hitBox = false; }
public void Draw(SpriteBatch spriteBatch, PenumbraComponent penumbra) { foreach (Entity entity in Entities) { Componets.Transform transform = entity.GetComponent <Componets.Transform>(); // Sprite Draw if (entity.HasComponent <Sprite>() && entity.GetComponent <Sprite>().Enabled) { Sprite sprite = entity.GetComponent <Sprite>(); if (sprite.SpriteLocation == Rectangle.Empty) { sprite.SpriteLocation = new Rectangle(0, 0, textures[sprite.ContentName].Width, textures[sprite.ContentName].Height); } Rectangle spriteLocation = new Rectangle(sprite.SpriteLocation.X, sprite.SpriteLocation.Y, (int)(sprite.SpriteLocation.Width * sprite.Fill), sprite.SpriteLocation.Height); if (textures.ContainsKey(sprite.ContentName)) { spriteBatch.Draw(textures[sprite.ContentName], new Rectangle((int)Math.Floor(transform.Position.X), (int)Math.Floor(transform.Position.Y), (int)Math.Floor(transform.Scale.X * sprite.Fill), (int)Math.Floor(transform.Scale.Y)), spriteLocation, sprite.Color, transform.Rotation, new Vector2(0, 0), sprite.SpriteEffects, sprite.Layer); } else { Debug.WriteLine($"Content '{sprite.ContentName}' does not exist"); } } // Debug if (WindowManager.ShowCollisionsDetails) { if (entity.HasComponent <BoxCollision>()) { BoxCollision boxCollision = entity.GetComponent <BoxCollision>(); foreach (IBox box in boxCollision.Boxes) { Color color = new Color(Color.White, .5f); spriteBatch.Draw(textures["Pixel"], new Rectangle((int)box.X, (int)box.Y, (int)box.Width, (int)box.Height), color); } } } } }
public override void Initialize() { Name = "Projectile"; Sprite = GetComponent <Sprite>(); Transform = GetComponent <Transform>(); Physics = GetComponent <Physics>(); BoxCollision = GetComponent <BoxCollision>(); Animation = GetComponent <Animation>(); BoxCollision.HandleCollisionEnter = handleCollisionEnter; DeleteOnHit = true; Damage = 0; Range = -1; distanceTraveled = 0; }
public static Node Create() { var cmp = new MyBackground (); var spr = new Sprite (1200, 1800); spr.AddTexture (Resource.GetTexture ("media/Background-Glass.png")); var col = new BoxCollision (spr.Width/2, spr.Height/2, 0); col.SetOffset (spr.Width/2, spr.Height/2, 0); var node = new Node ("Ground"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.DrawPriority = 1; return node; }
private void loadFromTileSet(Tileset tileset) { for (int i = 0; i < tileset.Count; i++) { SpriteSheetAnimations spriteSheetAnimation = new SpriteSheetAnimations(); spriteSheetAnimation.Width = tileset[i].Width; spriteSheetAnimation.Height = tileset[i].Height; spriteSheetAnimation.Margin = tileset[i].Margin; spriteSheetAnimation.Spacing = tileset[i].Spacing; AnimationTracker animationTracker = new AnimationTracker(spriteSheetAnimation); string name = tileset[i].Animation.Name; foreach (TilesetFrame frame in tileset[i].Animation.Frames) { Dictionary <string, BoxCollision> colliders = new Dictionary <string, BoxCollision>(); foreach (KeyValuePair <string, List <BoxCol> > collider in tileset[frame.Id].BoxColliders) { BoxCollision collision = new BoxCollision(); collision.World = SceneManager.GetCurrentScene().World; for (int j = 0; j < collider.Value.Count; j++) { BoxData box = new BoxData(); box.Position = new Vector(collider.Value[j].Rectangle.X / (float)tileset[frame.Id].Width, collider.Value[j].Rectangle.Y / (float)tileset[frame.Id].Height); box.Scale = new Vector(collider.Value[j].Rectangle.Width / (float)tileset[frame.Id].Width, collider.Value[j].Rectangle.Height / (float)tileset[frame.Id].Height); box.TriggerOnly = collider.Value[j].TriggerOnly; IBox ibox = collision.World.Create(0, 0, box.Scale.X, box.Scale.Y).AddTags(box.Layer); ibox.Data = box; collision.World.Remove(ibox); collision.Boxes.Add(ibox); } colliders.Add(collider.Key, collision); } animationTracker.AddFrame(frame.Duration, frame.Source.X, frame.Source.Y, colliders); } animationData[name] = animationTracker; } }
public static Node Create(Vector3 pos) { var cmp = new MyGoal (); var spr = new Sprite (128, 128); spr.AddTexture (Resource.GetDefaultTexture ()); spr.Color = Color.Blue; var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var node = new Node ("Goal"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.Translation = pos; return node; }
public static Node Create() { var cmp = new MyMouseSelector (); var spr = new Sprite (1, 1); spr.AddTexture (new Texture ("media/image128x128(Purple).png")); spr.SetColor (255, 255, 255, 64); var col = new BoxCollision (600, 900, 0); col.SetOffset (600, 900, 0); var node = new Node ("MouseSelector"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.DrawPriority = -1; node.Drawable = false; return node; }
private static Node CreateFloor(string name, int x, int y, int width, int height, Quaternion rot) { var spr = new Sprite (width, height); spr.AddTexture (Resource.GetTexture ("media/Rectangle-160x40.png")); var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var body = new PhysicsBody (); var mat = new PhysicsMaterial (); body.Shape = col; body.Material = mat; var node = new Node (name); node.SetTranslation (x, y, 0); node.SetRotation (rot); node.Attach (spr); node.Attach (col); node.Attach (body); return node; }
private void setCurrentCollisions(Animation animation, Entity entity, AnimationTracker current) { animation.CurrentCollisions = new Dictionary <string, BoxCollision>(); foreach (KeyValuePair <string, BoxCollision> pair in current.Frames[current.FrameNumber].Colliders) { if (pair.Key == "Collision") { BoxCollision boxCollision = entity.GetComponent <BoxCollision>(); Componets.Transform transform = entity.GetComponent <Componets.Transform>(); List <IBox> newBoxes = new List <IBox>(); for (int i = 0; i < pair.Value.Boxes.Count; i++) { BoxData boxData = (BoxData)pair.Value.Boxes[i].Data; IBox newIbox = boxCollision.World.Create(transform.Position.X + transform.Scale.X * boxData.Position.X, transform.Position.Y + transform.Scale.Y * boxData.Position.Y, transform.Scale.X * boxData.Scale.X, transform.Scale.Y * boxData.Scale.Y).AddTags(boxData.Layer); newIbox.Data = boxData; if (boxCollision.Boxes.Count > i) { boxCollision.World.Remove(boxCollision.Boxes[i]); boxCollision.Boxes.Remove(boxCollision.Boxes[i]); } newBoxes.Add(newIbox); } boxCollision.Boxes = newBoxes; } else { animation.CurrentCollisions.Add(pair.Key, pair.Value); } } }
// void OnCollisionEnter2D(Collision2D coll) { if (hit) { return; } // if (coll.gameObject.tag == "Ground" || coll.gameObject.tag == "Box") { /*destroyChain(); * //destroy self * } * else if (coll.gameObject.tag == "Box") * {*/ hit = true; BoxCollision box = coll.gameObject.GetComponent <BoxCollision>(); if (box != null) { headBox = box; } linkHinge.connectedBody = coll.gameObject.GetComponent <Rigidbody2D>(); //linkDistance.connectedBody; linkHinge.enabled = true; linkDistance.enabled = false; linkHinge.connectedAnchor = coll.gameObject.transform.InverseTransformPoint(coll.contacts[0].point); rigidbody2D.gravityScale = 1.0f; rigidbody2D.mass = 200.0f; rigidbody2D.isKinematic = false; if (myChain != null) { myChain.playerCatch(chainPieces[chainPieces.Count - 1]); } generateMore = 1; adjustWeight(); clearVelocity(); } }
private void handleCollisions(Entity entity1, Entity entity2) { BoxCollision collider1 = entity1.GetComponent <BoxCollision>(); BoxCollision collider2 = entity2.GetComponent <BoxCollision>(); if (collider1.Enabled && collider2.Enabled) { if (collider1.Layer != collider2.Layer || (collider1.Layer == "All" && collider2.Layer == "All")) { Transform transform1 = entity1.GetComponent <Transform>(); Transform transform2 = entity2.GetComponent <Transform>(); if (checkCollision(collider1, collider2, transform1, transform2)) { string side1 = handlePhysics(entity1, transform1, p2, s2, collider1.TriggerOnly || collider2.TriggerOnly); string side2 = handlePhysics(entity2, transform2, p1, s1, collider1.TriggerOnly || collider2.TriggerOnly); collider1.HandleCollision?.Invoke(entity2, side1); collider2.HandleCollision?.Invoke(entity1, side2); } } } }
public override void Initialize() { Name = "Enemy"; Character = new Charles(); TotalHealth = Character.MaxHealth * Character.AIHealthMod; CurrentHealth = TotalHealth; elapsedTintTime = hitTime; Invonerable = false; Sprite = GetComponent <Sprite>(); Animation = GetComponent <Animation>(); Transform = GetComponent <Transform>(); BoxCollision = GetComponent <BoxCollision>(); Physics = GetComponent <Physics>(); //BoxCollision.Layer = "Enemy|Character"; BoxCollision.HandleCollision = handleCollision; Transform.Scale = Transform.Scale * MapConstants.Scale; Animation.CurrentAnimation = Character.IdleAnimation; }
public override void Initialize() { Name = "Player"; Character = new Charles(); Character.Holder = "Player"; TotalHealth = Character.MaxHealth; CurrentHealth = TotalHealth; elapsedTintTime = hitTime; elapsedRollTime = rollCooldown; KeyCount = 0; KeysUI = new List <Key>(); Rolling = false; rollVelocity = new Vector(0, 0); lastAimDirection = new Vector2(1, 0); Involnerable = false; scene = (DungeonScene)SceneManager.GetCurrentScene(); Character.OnSpawn(); Sprite = GetComponent <Sprite>(); Animation = GetComponent <Animation>(); Transform = GetComponent <Transform>(); boxCollision = GetComponent <BoxCollision>(); Physics = GetComponent <Physics>(); boxCollision.HandleCollision = handleCollision; boxCollision.Layer = CollisionLayers.Player; Animation.CurrentAnimation = Character.IdleAnimation; Sprite.ContentName = Character.SpriteSheet; jumpTrailStart = scene.CreateEntity <Trail>(); jumpTrailEnd = scene.CreateEntity <Trail>(); }
public static bool CreateObjectFromTileSet(string name, string tileset, Vector position, Vector scale, float layer, out MapObject mapObject, out MapObjectCollision mapObjectCol) { Tileset tilesetContent = Content.Load <Tileset>("Tilesets\\" + tileset); mapObject = null; mapObjectCol = null; foreach (Tile tile in tilesetContent.tiles) { if (tile.Properties.ContainsKey("Name") && tile.Properties["Name"] == name) { // Add light if (tile.Properties.ContainsKey("IsLight") && tile.Properties["IsLight"] == "true") { MapLight maplight = SceneManager.GetCurrentScene().CreateEntity <MapLight>(); Light light = maplight.GetComponent <Light>(); light.Position = position + (scale / 2); } // Add collision object if (tile.BoxColliders.Count > 0) { mapObjectCol = SceneManager.GetCurrentScene().CreateEntity <MapObjectCollision>(); mapObjectCol.GetComponent <Componets.Transform>().Position = position; mapObjectCol.GetComponent <Componets.Transform>().Scale = scale; mapObjectCol.GetComponent <Sprite>().ContentName = tileset; mapObjectCol.GetComponent <Sprite>().SpriteLocation = tile.Source; mapObjectCol.GetComponent <Sprite>().Layer = layer; BoxCol collider = tile.BoxColliders.First().Value[0]; BoxCollision col = mapObjectCol.GetComponent <BoxCollision>(); BoxData box = new BoxData(); box.Position = new Vector(collider.Rectangle.X / (float)tile.Width, collider.Rectangle.Y / (float)tile.Height); box.Scale = new Vector(collider.Rectangle.Width / (float)tile.Width, collider.Rectangle.Height / (float)tile.Height); box.TriggerOnly = collider.TriggerOnly; IBox ibox = col.World.Create(position.X + box.Position.X * scale.X, position.Y + box.Position.Y * scale.Y, box.Scale.X * scale.X, box.Scale.Y * scale.Y); ibox.Data = box; col.Boxes.Add(ibox); return(true); } // Add object else { mapObject = SceneManager.GetCurrentScene().CreateEntity <MapObject>(); mapObject.GetComponent <Componets.Transform>().Position = position; mapObject.GetComponent <Componets.Transform>().Scale = scale; mapObject.GetComponent <Sprite>().ContentName = tileset; mapObject.GetComponent <Sprite>().SpriteLocation = tile.Source; mapObject.GetComponent <Sprite>().Layer = layer; return(true); } } } return(false); }
private static Node Create(string nodeName, string tankName, Vector3 pos, Quaternion rot) { // タンク var cmp = new MyTank (tankName); // 車両(Body) var spr = new Sprite (40, 64); spr.SetOffset (-20, -34); spr.AddTexture (cmp.BodyTexture); spr.AddTexture (Resource.GetDefaultTexture ()); // コリジョン他 var col = new BoxCollision (20, 32, 0); var node = new Node (nodeName); node.Attach (cmp); node.Attach (spr); node.Attach (col); // 砲台(Turret) var tullet = MyTullet.Create (); tullet.GetComponent<Sprite> ().AddTexture (cmp.turretTexture); node.AddChild (tullet); node.DrawPriority = -2; node.Translation = pos; node.Rotation = rot; return node; }
public static Node Create(Vector3 pos) { var cmp = new MyCharacter (); var spr1 = new Sprite (new Texture ("media/Character-Gelato.png"), 24, 32); var spr2 = new Sprite (new Texture ("media/Image128x128(Red).png"), 24, 4); spr2.SetOffset (0, spr1.Height); var body = new BoxCollision (spr1.Width / 2, spr1.Height / 2, 0); var foot = new SphereCollision (2); body.SetOffset (spr1.Width / 2, spr1.Height / 2, 0); foot.SetOffset (spr1.Width / 2, spr1.Height + 2, 0); var node = new Node ("MyCharacter"); node.Attach (spr1); node.Attach (spr2); node.Attach (body); node.Attach (foot); node.Attach (cmp); node.DrawPriority = -1; node.Translation = pos; cmp.jumpSound = new SoundClip ("JumpSound"); cmp.jumpSound.AddTrack (new SoundEffectTrack ("media/Jump.ogg")); var track1 = new AnimationTrack ("TextureOffset", InterpolationType.Step); track1.AddKeyframe (0, new Vector2 (0, 64)); track1.AddKeyframe (300, new Vector2 (24, 64)); track1.AddKeyframe (600, new Vector2 (48, 64)); cmp.walkDown = new AnimationClip (900, "MyCharacter.Down"); cmp.walkDown.AddTrack (spr1, track1); var track2 = new AnimationTrack ("TextureOffset", InterpolationType.Step); track2.AddKeyframe (0, new Vector2 (0, 0)); track2.AddKeyframe (300, new Vector2 (24, 0)); track2.AddKeyframe (600, new Vector2 (48, 0)); cmp.walkUp = new AnimationClip (900, "MyCharacter.Up"); cmp.walkUp.AddTrack (spr1, track2); var track3 = new AnimationTrack ("TextureOffset", InterpolationType.Step); track3.AddKeyframe (0, new Vector2 (0, 32)); track3.AddKeyframe (300, new Vector2 (24, 32)); track3.AddKeyframe (600, new Vector2 (48, 32)); cmp.walkRight = new AnimationClip (900, "MyCharacter.Right"); cmp.walkRight.AddTrack (spr1, track3); var track4 = new AnimationTrack ("TextureOffset", InterpolationType.Step); track4.AddKeyframe (0, new Vector2 (0, 96)); track4.AddKeyframe (300, new Vector2 (24, 96)); track4.AddKeyframe (600, new Vector2 (48, 96)); cmp.walkLeft = new AnimationClip (900, "MyCharacter.Left"); cmp.walkLeft.AddTrack (spr1, track4); return node; }
public override void InitializeEntity(Entity entity) { BoxCollision collider = entity.GetComponent <BoxCollision>(); collider.World = SceneManager.GetCurrentScene().World; }