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


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

        public static int points = 0;


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

        public UFOAlien(Sprite.SpriteName spriteName, float x, float y)
            : base(GameObject.ObjectName.UFO, 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()
        {
            //STN: used only to generate random point result
            Random rand = new Random();

            //randomly return value from 50pts - 300pts
            return points = rand.Next(50, 300);
        }

        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, 0, 0, 0);
            base.Update();

            GameObject pParent = (GameObject)this.pParent;
            pParent.Update();

            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();
        }

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

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

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

       
    } //end class

} //end namespace