GAM456-SpaceInvaders / SpaceInvaders / 4_GameObject / Aliens / CrabAlien.cs
CrabAlien.cs
Raw
using System;
using System.Diagnostics;


namespace SpaceInvaders
{
    public class CrabAlien : Aliens
    {
        //-------------------------------------------------------------------
        //  FIELDS
        //-------------------------------------------------------------------

        public static int points = 20;


        //-------------------------------------------------------------------
        //  CONSTRUCTION
        //-------------------------------------------------------------------

        public CrabAlien(Sprite.SpriteName spriteName, float x, float y)
            : base(GameObject.ObjectName.Crab, spriteName, x, y)
        { }


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

        public void Resurrect(float x, float y)
        {
            this.x = x;
            this.y = y;

            base.Ressurect();
            this.SetCollisionColor(1.0f, 0.0f, 0.0f);
        }

        public override int GetPoints()
        {
            return points;
        }

        public override void Move(float x, float y)
        {
            this.x += x;
            this.y += y;
        }

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

        public override void Remove()
        {
            Debug.WriteLine("Removing: {0}", this.name);

            this.pColObj.pCollisionRect.Set(0.0f, 0.0f, 0.0f, 0.0f);
            base.Update();

            //update parent (root)
            GameObject pParent = (GameObject)this.pParent;
            pParent.Update();

            //remove it
            base.Remove();
        }


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

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

        public override void Visit(MissileGroup missile)
        {
            CollisionPair.CollidePair((GameObject)ForwardIterator.GetChild(missile), this);
        }

        public override void Visit(Missile missile)
        {
            CollisionPair pPair = CollisionPairMan.GetActivePair();
            Debug.Assert(pPair != null);

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


    } // end class

} // end namespace