Exemple #1
0
 /// <summary>
 ///		Clears base sprite data
 /// </summary>
 virtual protected void SpriteReset()
 {
     this.name  = Sprite.Name.UNINITIALIZED;
     this.color = Colors.White;
     this.x     = 0.0f;
     this.y     = 0.0f;
 }
Exemple #2
0
        public AlienLaser(float initX, float initY, GameObject laserRoot)
            : base()
        {
            this.SetName(Name.LaserAlien);
            this.SetPosition(initX, initY);
            this.SetColor(initialColor);
            this.Collider.Color = Colors.Magenta;

            // Decide randomly which sprite to choose
            int random = Randomizer.RandomInt(3);

            Sprite.Name newSpriteName = Sprite.Name.UNINITIALIZED;
            switch (random)
            {
            case 0:
                newSpriteName = Sprite.Name.LaserAlienZigzag;
                break;

            case 1:
                newSpriteName = Sprite.Name.LaserAlienStraight;
                break;

            case 2:
                newSpriteName = Sprite.Name.LaserAlienDagger;
                break;

            default:
                Debug.Assert(false, "AlienLaser: Randomizer choose a number out of range!");
                break;
            }
            this.SetSprite(SpriteBatch.Name.Aliens, SpriteEntityManager.Self.Find(newSpriteName));

            GameObjectManager.Active.Attach(this);
            laserRoot.AddChild(this);
        }
Exemple #3
0
 public LargeInvader(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
     : base(name, spriteName, boxSpriteName)
 {
     this.x     = posX;
     this.y     = posY;
     this.value = 10;
 }
Exemple #4
0
        //
        // Constructors
        //

        public Sprite() : base()
        {
            this.name  = Sprite.Name.UNINITIALIZED;
            this.color = Colors.White;
            this.x     = 0.0f;
            this.y     = 0.0f;
        }
Exemple #5
0
        public void Set(Sprite.Name name, Image pImage, float x, float y, float width, float height, Azul.Color pColor = null)
        {
            Debug.Assert(pImage != null);

            this.pImage = pImage;
            this.name   = name;

            Debug.Assert(this.poScreenRect != null);
            this.poScreenRect.Set(x, y, width, height);

            if (pColor == null)
            {
                Debug.Assert(this.poColor != null);
                this.poColor.Set(1, 1, 1);
            }
            else
            {
                this.poColor.Set(pColor);
            }


            this.poSprite.Swap(pImage.GetAzulTexture(), pImage.GetAzulRect(), poScreenRect, poColor);
            Debug.Assert(this.poSprite != null);

            this.x      = poSprite.x;
            this.y      = poSprite.y;
            this.sx     = poSprite.sx;
            this.sy     = poSprite.sy;
            this.angle  = poSprite.angle;
            this.speedX = 0;
            this.speedY = 0;
        }
Exemple #6
0
        /// <summary>
        ///		Finds a flyweight sprite and returns it
        /// </summary>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public SpriteCollisionProxy Find(Sprite.Name name, uint id)
        {
            Debug.Assert(name != Sprite.Name.UNINITIALIZED);
            //Debug.Assert(name != Sprite.Name.NULL);

            return(this.BaseFind(name, id, this.activeList) as SpriteCollisionProxy);
        }
Exemple #7
0
 protected Composite(GameObject.Name gameName, Sprite.Name spriteName)
     : base(gameName, spriteName)
 {
     this.numChildren   = 0;
     this.pHead         = null;
     this.containerType = Container.COMPOSITE;
 }
Exemple #8
0
 public Missile(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
     : base(name, spriteName, boxSpriteName)
 {
     this.x      = posX;
     this.y      = posY;
     this.speedY = 10.0f;
 }
Exemple #9
0
        public void Set(SpriteAnimation.Name animationName, Sprite.Name spriteName)
        {
            this.name = animationName;

            // Find the sprite that the animation is attached to
            this.pSprite = SpriteManager.Find(spriteName);
            Debug.Assert(this.pSprite != null);
        }
Exemple #10
0
        public WallRight(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY, float width, float height)
            : base(name, spriteName, boxSpriteName)
        {
            this.poColObj.poColRect.Set(posX, posY, width, height);

            this.x = posX;
            this.y = posY;
        }
 /// <summary>
 ///		Finds a sprite and returns it
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public SpriteEntity Find(Sprite.Name name)
 {
     if (name == Sprite.Name.NULL || name == Sprite.Name.UNINITIALIZED)
     {
         return(nullSprite);
     }
     return(this.BaseFind(name, this.activeList) as SpriteEntity);
 }
Exemple #12
0
        public WallGroup(GameObject.Name name, Sprite.Name spriteName, float posX, float posY)
            : base(name, spriteName)
        {
            this.x = posX;
            this.y = posY;

            this.GetCollisionObject().GetCollisionSpriteBox().SetLineColor(1, 1, 1);
        }
Exemple #13
0
 public UFO(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
     : base(name, spriteName, boxSpriteName)
 {
     this.x      = posX;
     this.y      = posY;
     this.speedX = 2;
     this.value  = 300;
 }
Exemple #14
0
 public Bomb(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
     : base(name, spriteName, boxSpriteName)
 {
     this.x      = posX;
     this.y      = posY;
     this.speedY = -5.0f;
     this.pInvaderWhoDroppedMe = null;
 }
Exemple #15
0
        //----------------------------------------------------------------------
        // Constructors / Destructor
        //----------------------------------------------------------------------

        protected GameObject(GameObject.Name gameName, Sprite.Name spriteName)
        {
            this.name             = gameName;
            this.x                = 0.0f;
            this.y                = 0.0f;
            this.pSpriteProxy     = new SpriteProxy(spriteName);
            this.pCollisionObject = new CollisionObject(this.pSpriteProxy);
        }
Exemple #16
0
 public Missile(GameObject.Name name, Sprite.Name spriteName, float posX, float posY)
     : base(name, spriteName)
 {
     this.x      = posX;
     this.y      = posY;
     this.enable = false;
     this.delta  = 10.0f;
 }
Exemple #17
0
        public SpriteAnimation(SpriteAnimation.Name animationName, Sprite.Name spriteName)
        {
            // list
            this.pFirstImage = null;
            this.pCurrImage  = null;

            Set(animationName, spriteName);
        }
Exemple #18
0
 /// <summary>
 ///		Finds a flyweight sprite and returns it
 /// </summary>
 /// <param name="name"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public SpriteProxy Find(Sprite.Name name, uint id)
 {
     if (name == Sprite.Name.NULL || name == Sprite.Name.UNINITIALIZED)
     {
         return(this.nullSpriteProxy);
     }
     return(this.BaseFind(name, id, this.activeList) as SpriteProxy);
 }
Exemple #19
0
        public ShieldBrick(GameObject.Name name, Sprite.Name spriteName, float posX, float posY)
            : base(name, spriteName, ShieldCategory.Type.Brick)
        {
            this.x = posX;
            this.y = posY;

            this.SetCollisionObjectLineColor(1.0f, 1.0f, 1.0f);
        }
        public AnimationSprite(Sprite.Name name)
        {
            this.pSprite = SpriteManager.Find(name);
            Debug.Assert(this.pSprite != null);

            // initialize references
            this.pCurrentImage = null;
            this.poFirstImage  = null;
        }
Exemple #21
0
 public OneTimeAnimation(Sprite.Name name, float xPos, float yPos)
     : base(name)
 {
     this.pSprite.x = xPos;
     this.pSprite.y = yPos;
     this.pSprite.Update();
     //SpriteBatch pSpriteBatch = SpriteBatchManager.Find(SpriteBatch.Name.Sprites);
     //pSpriteBatch.Attach(this.pSprite);
 }
Exemple #22
0
        public CoreCannon(GameObject.Name name, Sprite.Name spriteName, float posX, float posY)
            : base(name, spriteName)
        {
            this.x = posX;
            this.y = posY;

            this.coreCannonSpeed = 3.0f;
            this.pMissileState   = null;
            this.pMoveState      = null;
        }
Exemple #23
0
        //---------------------------------------------------------------------------------------------------------
        // Methods
        //---------------------------------------------------------------------------------------------------------
        public void Set(SpriteProxy.Name proxyName, Sprite.Name spriteName)
        {
            this.name = proxyName;

            this.x = 0.0f;
            this.y = 0.0f;

            this.pSprite = SpriteManager.Find(spriteName);
            Debug.Assert(this.pSprite != null);
        }
Exemple #24
0
        public void Set(Sprite.Name name)
        {
            this.name = ProxySprite.Name.Proxy;

            this.x = 0.0f;
            this.y = 0.0f;

            this.pSprite = SpriteManager.Find(name);
            Debug.Assert(this.pSprite != null);
        }
Exemple #25
0
        public Ship(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
            : base(name, spriteName, boxSpriteName)
        {
            this.x = posX;
            this.y = posY;

            this.speedX       = 5.0f;
            this.pMotionState = null;
            this.pShootState  = null;
        }
Exemple #26
0
        public LeftWall(GameObject.Name name, Sprite.Name spriteName, float posX, float posY, float width, float height)
            : base(name, spriteName, Wall.Type.Left)
        {
            this.GetCollisionObject().GetCollisionRect().Set(posX, posY, width, height);

            this.x = posX;
            this.y = posY;

            this.SetCollisionObjectLineColor(1, 1, 0);
        }
        public SpriteBaseRef Attach(Sprite.Name name)
        {
            SpriteBaseRef pNode = (SpriteBaseRef)this.BaseAdd();

            Debug.Assert(pNode != null);

            // Initialize SpriteBase Node
            pNode.Set(name);

            return(pNode);
        }
        ///////////////////////////////////////////////////////
        //
        // Methods
        //
        ///////////////////////////////////////////////////////


        /// <summary>
        ///		Creates a new frame animation for a SpriteEntity
        /// </summary>
        /// <param name="targetName">
        ///		The name of the sprite to be animated. A corresponding "animator" will be created for it.
        /// </param>
        /// <param name="intervalTimeInSeconds"></param>
        /// <param name="looping"></param>
        /// <returns></returns>
        public AnimationFrame Create(Sprite.Name targetName, float intervalTimeInSeconds, bool looping)
        {
            AnimationFrame newAnimation = this.BaseCreate() as AnimationFrame;
            SpriteEntity   newTarget    = SpriteEntityManager.Self.Find(targetName) as SpriteEntity;

            newAnimation.SetTarget(newTarget);
            newAnimation.IntervalTime = intervalTimeInSeconds;
            newAnimation.AssignNewIntervalTime(intervalTimeInSeconds);
            newAnimation.ScheduleTimedAnimation(intervalTimeInSeconds, looping);
            return(newAnimation);
        }
        /// <summary>
        ///		Convenience method to add parameters to the animator
        /// </summary>
        /// <param name="targetName"></param>
        /// <param name="shouldXFlip"></param>
        /// <param name="shouldYFlip"></param>
        /// <returns></returns>
        public bool Attach(Sprite.Name targetName, bool shouldXFlip, bool shouldYFlip)
        {
            AnimationFlip animation = this.Find(targetName);

            if (animation == null)
            {
                return(false);
            }
            animation.Attach(shouldXFlip, shouldYFlip);
            return(true);
        }
        /// <summary>
        ///		Recycles sprite's frame animator for object pooling
        /// </summary>
        /// <param name="targetName"></param>
        /// <returns></returns>
        public bool Recycle(Sprite.Name targetName)
        {
            AnimationFrame oldAnimation = this.BaseRecycle(targetName) as AnimationFrame;

            if (oldAnimation == null)
            {
                return(false);
            }
            oldAnimation.Reset();
            return(true);
        }