Пример #1
0
        public void CheckCollision(BoxCollider other)
        {
            bool collision = false;

            if (X + Width <= other.X || other.X + other.Width <= X || Y + Height <= other.Y || other.Y + other.Height <= Y)
                collision = true;
            else
                collision = false;

            if(!collision)
            {
                if(!collidingColliders.Contains(other))
                {
                    collidingColliders.Add(other);

                    if (OnCollisionEnter != null)
                        OnCollisionEnter(other);
                }
                else
                {
                    if (OnCollisionStay != null)
                        OnCollisionStay(other);
                }
            }
            else
            {
                if(collidingColliders.Contains(other))
                {
                    collidingColliders.Remove(other);

                    if (OnCollisionExit != null)
                        OnCollisionExit(other);
                }
            }
        }
Пример #2
0
        public Player(Vector2 position)
        {
            Name = "Player";

            LoadSprite(GameManager.LoadTexture2D("Peter"));

            this.Position = position;

            map = (Map)GameManager.FindGameObject("Map");

            collider = new BoxCollider(this, (int)Position.X, (int)Position.Y, 1, 1);

            InputManager.OnKeyDown += OnKeyDown;
            InputManager.OnKeyPressed += OnKeyPressed;
        }
Пример #3
0
        private void OnCollisionEnter(BoxCollider other)
        {
            if(other.Type is Player)
            {
                Player.Health += 20;

                GameManager.Destroy(this);
                CollisionManager.Destroy(collider);

                if(Game1.DebugMode)
                {
                    Debug.WriteLine("HP: " + Player.Health);
                }
            }
        }
Пример #4
0
        private void OnCollisionEnter(BoxCollider other)
        {
            if(other.Type is Player)
            {
                Player.Defense += 1;

                GameManager.Destroy(this);
                CollisionManager.Destroy(collider);

                if(Game1.DebugMode == true)
                {
                    Debug.Write("Deine Rüstung hat sich um 1 erhöht");
                }
            }
        }
Пример #5
0
        public Item(Vector2 position, string atlasPath, string name)
        {
            Position = position;
            Name = name;

            ItemAtlas = GameManager.LoadTexture2D("Items");

            GameManager.AddGameObject(this);

            collider = new BoxCollider(this, (int)Position.X, (int)Position.Y, 1, 1);

            LoadFrame(atlasPath);

            SetFrame(Name);
        }
Пример #6
0
        public Pokemon(Vector2 position, string texture, string name, int health, int defense, int attackPower, int xp, int init, string element, bool movement)
        {
            this.Position = position;
            this.Sprite = GameManager.Content.Load<Texture2D>(texture);
            this.Name = name;
            this.Health = health;
            this.Defense = defense;
            this.AttackPower = attackPower;
            this.Element = element;
            this.Init = init;
            this.Movement = movement;

            GameManager.AddGameObject(this);

            collider = new BoxCollider(this, (int)position.X, (int)position.Y, 1, 1);

            collider.OnCollisionEnter += OnCollisionEnter;
        }
Пример #7
0
 public static void Destroy(BoxCollider boxCollider)
 {
     deletedColliders.Add(boxCollider);
 }
Пример #8
0
 public static void AddCollider(BoxCollider collider)
 {
     colliders.Add(collider);
 }
Пример #9
0
 private void OnCollisionEnter(BoxCollider other)
 {
     if (GameManager.GameState == "move" && other.Type is Player) // To prevent pokemon from fighting each other
         FightManager.Fight(this);
 }