public OrkForest(Vector2 position, Map map, Vector2 patrolTarget, NewTimer timer) { this.map = map; this.timer = timer; Tag = "OrkForest"; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<ViewRenderer>(); //renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/OrkForest/OrkForest_Front_0")); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), 32, 32); renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 1f); patrol = AddComponent<Patrol>(); patrol.PatrolToTarget(patrolTarget); moveSpeed = 1; collider = AddComponent<BoxCollider>(); collider.OnCollisionEnter += OnCollisionEnter; Animation = new SpriteAnimation( string.Empty, Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), Path.Combine(Managers.Content.RootDirectory, "Sprites", "Sprite_Sheet", "RougyMon.xml")); Animation.FrameDelay = 100; EventManager.OnLateUpdate += OnLateUpdate; EventManager.OnUpdate += OnUpdate; }
public void CheckCollision(BoxCollider other) { if (bounds.Intersects(other.bounds)) { if (!collisions.Contains(other)) { collisions.Add(other); if (OnCollisionEnter != null) OnCollisionEnter(other); } else { if (OnCollisionStay != null) OnCollisionStay(other); } } else { BoxCollider exitCollider = collisions.Find((BoxCollider collider) => collider == other); if (exitCollider != null) { collisions.Remove(exitCollider); if (OnCollisionExit != null) OnCollisionExit(other); } } }
public Player(Vector2 position, Map map, DoorForest doorForest, GateGraveyard gateGraveyard) { this.gateGraveyard = gateGraveyard; this.doorForest = doorForest; this.map = map; Tag = "Player"; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<ViewRenderer>(); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), 32, 32); //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 1f); renderer.Pivot = new Vector2(16, 32); moveWithInput = AddComponent<MoveWithInput>(); moveWithInput.Speed = 5; moveWithInput.MoveWithArrow = OptionsMenuScreen.MoveArrows; collider = AddComponent<BoxCollider>(); collider.OnCollisionEnter += OnCollisionEnter; Animation = new SpriteAnimation( string.Empty, Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), Path.Combine(Managers.Content.RootDirectory, "Sprites", "Sprite_Sheet", "RougyMon.xml")); Animation.FrameDelay = 100; EventManager.OnUpdate += OnUpdate; EventManager.OnLateUpdate += OnLateUpdate; }
private void OnCollisionEnter(BoxCollider other) { if (other.GameObject.Tag == "Player") { timer.Time = timer.Time.Add(new TimeSpan(0, 0, 20)); Destroy(); } }
private void OnCollisionEnter(BoxCollider other) { //if (other.GameObject.Tag == "Player") //{ // if (player.HasKey1) // Destroy(); // else // { // Vector2 oldPlayerPosition = player.transform.Position; // player.transform.Position = new Vector2(oldPlayerPosition.X, oldPlayerPosition.Y + 3); // } //} }
public Jewel(Vector2 position) { Tag = "Jewel"; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<Renderer>(); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Jewel")); renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f); collider = AddComponent<BoxCollider>(); collider.OnCollisionEnter += OnCollisionEnter; }
public GateGraveyard(Vector2 position) { Tag = "GateGraveyard"; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<Renderer>(); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/GateGraveyard")); //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f); collider = AddComponent<BoxCollider>(); EventManager.OnUpdate += OnUpdate; }
public DoorForest(Vector2 position) { Tag = "DoorForest"; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<Renderer>(); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/DoorForest")); //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f); collider = AddComponent<BoxCollider>(); collider.OnCollisionEnter += OnCollisionEnter; EventManager.OnUpdate += OnUpdate; }
public HealPotion(Vector2 position, NewTimer timer) { Tag = "HealPotion"; this.timer = timer; transform = AddComponent<Transform>(); transform.Position = position; renderer = AddComponent<Renderer>(); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Heal_Potion")); renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f); collider = AddComponent<BoxCollider>(); collider.OnCollisionEnter += OnCollisionEnter; EventManager.OnUpdate += OnUpdate; }
private void OnCollisionEnter(BoxCollider other) { if (other.GameObject.Tag == "Player") Destroy(); }
void OnCollisionEnter(BoxCollider other) { if (other.GameObject.Tag == "Player") { if (Tag == "Jewel") { Destroy(); ScreenManager.WinScreen = true; } timer.Time = timer.Time.Subtract(new TimeSpan(0, 0, 30)); renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Jewel"), 22, 32); transform.Position = new Vector2(transform.Position.X + 20, transform.Position.Y - 20); patrol.CanPatrol = false; renderer.Source = renderer.Image.Bounds; Tag = "Jewel"; } }
void OnCollisionEnter(BoxCollider other) { if (other.GameObject.Tag == "Key_1") HasKey1 = true; if (other.GameObject.Tag == "Key_2") HasKey2 = true; if (other.GameObject.Tag == "Jewel") HasJewel = true; if (other.GameObject.Tag == "Gold") GoldCounter++; if (other.GameObject.Tag == "DoorForest") if (HasKey1) other.GameObject.Destroy(); //else // transform.Position = new Vector2(transform.Position.X, transform.Position.Y + 10); if (other.GameObject.Tag == "GateGraveyard") if (HasKey2) other.GameObject.Destroy(); //else // transform.Position = new Vector2(transform.Position.X, transform.Position.Y + 10); }
public static void RemoveCollider(BoxCollider collider) { if (!removedColliders.Contains(collider)) removedColliders.Add(collider); }
public static void AddCollider(BoxCollider collider) { if (!colliders.Contains(collider)) colliders.Add(collider); }