/// <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; }
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); }
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; }
// // Constructors // public Sprite() : base() { this.name = Sprite.Name.UNINITIALIZED; this.color = Colors.White; this.x = 0.0f; this.y = 0.0f; }
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; }
/// <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); }
protected Composite(GameObject.Name gameName, Sprite.Name spriteName) : base(gameName, spriteName) { this.numChildren = 0; this.pHead = null; this.containerType = Container.COMPOSITE; }
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; }
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); }
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); }
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); }
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; }
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; }
//---------------------------------------------------------------------- // 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); }
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; }
public SpriteAnimation(SpriteAnimation.Name animationName, Sprite.Name spriteName) { // list this.pFirstImage = null; this.pCurrImage = null; Set(animationName, spriteName); }
/// <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); }
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; }
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); }
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; }
//--------------------------------------------------------------------------------------------------------- // 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); }
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); }
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; }
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); }