public DestructibleComponent(Transform transform, Collider destructibleCollider, float maxHP)
 {
     m_transform = transform;
     m_collider = destructibleCollider;
     _hpMax = _hpCurrent = maxHP;
 }
Пример #2
0
 public bool CircleCircle(Collider circle1, Collider circle2)
 {
     Circle c1 = ((CircleCollider)circle1).Circle;
     Circle c2 = ((CircleCollider)circle2).Circle;
     return m_helper.GetDistance(c1.Transform.PosX, c1.Transform.PosY, c2.Transform.PosX, c2.Transform.PosY) < c1.Radius + c2.Radius;
 }
Пример #3
0
 public bool PointLine(Collider point, Collider line)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public bool PointPoint(Collider point1, Collider point2)
 {
     Vector2 p1 = ((PointCollider)point1).Transform.PositionGlobal;
     Vector2 p2 = ((PointCollider)point2).Transform.PositionGlobal;
     return p1.X == p2.X && p1.Y == p2.Y;
 }
Пример #5
0
 public bool LineMask(Collider line, Collider mask)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public bool PointAABB(Collider point, Collider aabb)
 {
     Vector2 p = ((PointCollider)point).Transform.PositionGlobal;
     Rectangle r = ((AABBCollider)aabb).Bounds;
     return (p.X > r.Left &&
         p.Y > r.Top &&
         p.X < r.Right &&
         p.Y < r.Bottom);
 }
Пример #7
0
 /// <summary>
 /// Test collisions with a single other collider.
 /// </summary>
 /// <param name="objectToTest">Collider to test</param>
 /// <param name="action">Action to perform when collision occurs. May be null.</param>
 public void DoCollision(Collider objectToTest, OnCollision action)
 {
     for (int i = 0; i < m_entries.Count; ++i)
         if (m_methods.TestCollision(objectToTest, m_entries[i].collider))
         {
             if (m_entries[i].onCollision != null)
                 m_entries[i].onCollision(objectToTest);
             if (action != null)
                 action(m_entries[i].collider);
         }
 }
Пример #8
0
        public bool LineAABB(Collider line, Collider aabb)
        {
            LineSegment ls = ((LineCollider)line).Line;
            LineSegment ls2 = new LineSegment(Vector2.Zero, Vector2.Zero);
            Rectangle r = ((AABBCollider)aabb).Bounds;

            if (r.Contains(new Point((int)ls.A_Global.X, (int)ls.A_Global.Y))
                || r.Contains(new Point((int)ls.B_Global.X, (int)ls.B_Global.Y))
                || m_helper.IntersectsLines(ls.A_Global, ls.B_Global, new Vector2(r.Left, r.Top), new Vector2(r.Right, r.Top))
                || m_helper.IntersectsLines(ls.A_Global, ls.B_Global, new Vector2(r.Right, r.Top), new Vector2(r.Right, r.Bottom))
                || m_helper.IntersectsLines(ls.A_Global, ls.B_Global, new Vector2(r.Right, r.Bottom), new Vector2(r.Left, r.Bottom))
                || m_helper.IntersectsLines(ls.A_Global, ls.B_Global, new Vector2(r.Left, r.Bottom), new Vector2(r.Left, r.Top)))
                return true;
            return false;
        }
 private void OnSliceHit(Collider other)
 {
     m_destructible.BaseHit(other);
     m_physics.Throw(75, -75, 0);
     m_hitAnimation.Hit();
 }
Пример #10
0
        /// <summary>
        /// Add a member to the group
        /// </summary>
        /// <param name="collider">Collider used to test the collision</param>
        /// <param name="action">Action to perform when collision occurs. May be null.</param>
        public void Add(Collider collider, OnCollision action)
        {
            CollisionEntry entry = new CollisionEntry();
            entry.collider = collider;
            entry.onCollision = action;

            m_entries.Add(entry);
            collider.m_groups.Add(this);
        }
 private void OnShurikenHit(Collider other)
 {
     m_destructible.BaseHit(other);
     m_shurikenReceiver.OnHit();
     m_hitAnimation.Hit();
 }
Пример #12
0
        private void PickUp(Collider player)
        {
            _isPickedUp = true;
            int value = 0;

            if(_type == COIN_TYPE.COPPER)
                value = CopperWorth;
            else if (_type == COIN_TYPE.SILVER)
                value = SilverWorth;
            else if(_type == COIN_TYPE.GOLD)
                value = GoldWorth;

            //ADDTHISLATER
            //Globals.GameScore.AddToScore(value);
            //Globals.GameCoinBar.AddCoin(_type);
        }
        public void CollisionResponse(Collider other)
        {
            //if (other.Owner is Bat)
            //    {
            //        Bat temp = (Bat)other.Owner;
            //        temp.Hit(AttackManager.Finisher);
            //    }

            //if (other.Owner is Enemy)
            //{

            //    else
            //    {
            //        GameObject temp = (Enemy)other.Owner;
            //        temp(30, -12, 0);
            //    }
                Die();
                return;
            //}
            //else if (otherActor is TombStone)
            //{
            //    TombStone tombStone = (TombStone)otherActor;
            //    tombStone.UpdateSpawning(gameTime);
            //}
        }
Пример #14
0
 public bool CircleLine(Collider circle, Collider line)
 {
     throw new NotImplementedException();
 }
Пример #15
0
 public void Remove(Collider collider, OnCollision action)
 {
     for (int i = 0; i < m_entries.Count; ++i)
         if (m_entries[i].collider == collider && m_entries[i].onCollision == action)
         {
             m_entries.RemoveAt(i);
             return;
         }
 }
Пример #16
0
 public bool CircleMask(Collider circle, Collider mask)
 {
     throw new NotImplementedException();
 }
Пример #17
0
 public void Remove(Collider collider)
 {
     for(int i = 0; i < m_entries.Count; ++i)
         if (m_entries[i].collider == collider)
         {
             m_entries.RemoveAt(i);
             return;
         }
 }
Пример #18
0
 public bool LineLine(Collider line1, Collider line2)
 {
     LineSegment ls1 = ((LineCollider)line1).Line;
     LineSegment ls2 = ((LineCollider)line2).Line;
     return m_helper.IntersectsLines(ls1, ls2);
 }
Пример #19
0
 public void ReplaceAction(Collider collider, OnCollision action)
 {
     for (int i = 0; i < m_entries.Count; ++i)
         if (m_entries[i].collider == collider)
         {
             m_entries[i].onCollision = action;
             return;
         }
 }
Пример #20
0
        public bool MaskMask(Collider mask1, Collider mask2)
        {
            throw new NotImplementedException();

            //// Stolen from http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel
            //int top = Math.Max(rectangleA.Top, rectangleB.Top);
            //int bottom = Math.Min(rectangleA.Bottom, rectangleB.Bottom);
            //int left = Math.Max(rectangleA.Left, rectangleB.Left);
            //int right = Math.Min(rectangleA.Right, rectangleB.Right);
            //for (int y = top; y < bottom; y++)
            //{
            //    for (int x = left; x < right; x++)
            //    {
            //        Color colorA = dataA[(x - rectangleA.Left) + (y - rectangleA.Top) * rectangleA.Width];
            //        Color colorB = dataB[(x - rectangleB.Left) + (y - rectangleB.Top) * rectangleB.Width];
            //        if (colorA.A > 0 && colorB.A > 0)
            //            return true;
            //    }
            //}
            //return false;
        }
Пример #21
0
 public bool AABBAABB(Collider aabb1, Collider aabb2)
 {
     Rectangle r1 = ((AABBCollider)aabb1).Bounds;
     Rectangle r2 = ((AABBCollider)aabb2).Bounds;
     return r1.Intersects(r2);
 }
Пример #22
0
 public bool PointCircle(Collider point, Collider circle)
 {
     Vector2 p = ((PointCollider)point).Transform.PositionGlobal;
     Circle c = ((CircleCollider)circle).Circle;
     return m_helper.Contains(c, p);
 }
Пример #23
0
 public bool AABBMask(Collider aabb, Collider mask)
 {
     throw new NotImplementedException();
 }
Пример #24
0
 public bool PointMask(Collider point, Collider mask)
 {
     throw new NotImplementedException();
 }
Пример #25
0
 public bool CircleAABB(Collider circle, Collider aabb)
 {
     throw new NotImplementedException();
 }
Пример #26
0
 public bool TestCollision(Collider a, Collider b)
 {
     int ia = (int)a.Type;
     int ib = (int)b.Type;
     return m_collisionMethods[ia, ib](a, b);
 }
 public void BaseHit(Collider other)
 {
     AttackComponent attack = (AttackComponent)other.Owner;
     DealDamage(attack);
 }