GAM456-SpaceInvaders / SpaceInvaders / 4_GameObject / Walls / TopWall.cs
TopWall.cs
Raw
using System;
using System.Diagnostics;


namespace SpaceInvaders
{
    public class TopWall : Walls
    {
        //-------------------------------------------------------------------
        //  CONSTRUCTION
        //-------------------------------------------------------------------

        public TopWall(GameObject.ObjectName objName, Sprite.SpriteName spriteName, float x, float y, float width, float height)
            : base(objName, spriteName, x, y, Walls.WallType.Top)
        {
            this.x = x;
            this.y = y;

            this.pColObj.pCollisionRect.Set(x, y, width, height);
            this.pColObj.pCollisionSprite.SetColor(1.0f, 0.0f, 0.0f);
        }


        //-------------------------------------------------------------------
        //  PUBLIC METHODS
        //-------------------------------------------------------------------

        public override void Update()
        {
            base.Update();
        }


        //-------------------------------------------------------------------
        //  VISITOR METHODS
        //-------------------------------------------------------------------

        public override void Accept(Visitor other)
        {
            other.Visit(this);
        }

        public override void Visit(MissileGroup missile)
        {
            //missile group vs top wall
            CollisionPair.CollidePair((GameObject)ForwardIterator.GetChild(missile), this);
        }

        public override void Visit(Missile missile)
        {
            //Debug.WriteLine("\ncollide: {0} with {1}", this, missile);

            //missile vs top wall
            CollisionPair pPair = CollisionPairMan.GetActivePair();
            Debug.Assert(pPair != null);

            pPair.SetCollision(missile, this);
            pPair.NotifyListeners();
        }


    }
}