public ISprite CreateSprite(IMovementState movement, IConditionState condition) { ISprite sprite = new DeadMarioSprite(marioSpriteSheet); Type spriteType; string code = ""; if (movement != null && condition != null) { code = movement.GetType().ToString() + condition.GetType().ToString(); } if (Mario.Instance != null && Mario.Instance.RowId != -1) { marioCostumeDictionary.TryGetValue(code, out spriteType); if (spriteType != null) { ConstructorInfo[] constr = new ConstructorInfo[1]; constr = spriteType.GetConstructors(); sprite = (ISprite)constr[0].Invoke(new object[] { marioCostumeSpriteSheet }); CostumeSprite costSprite = (CostumeSprite)sprite; costSprite.RowId = Mario.Instance.RowId; sprite = costSprite; } } else { marioDictionary.TryGetValue(code, out spriteType); if (spriteType != null) { ConstructorInfo[] constr = new ConstructorInfo[1]; constr = spriteType.GetConstructors(); sprite = (ISprite)constr[0].Invoke(new object[] { marioSpriteSheet }); } } return(sprite); }
public void UpdateSprite() { sprite = SpriteMachine.Instance.CreateSprite(HealthState.GetType().Name + MovementState.GetType().Name); }
private void UpdateSprite() { //needs to also update the player position so the bottom of the player stays in the same place ISprite currentSprite = sprite; sprite = SpriteMachine.Instance.CreateSprite(HealthState.GetType().Name + MovementState.GetType().Name); Physics.yPosition += currentSprite.GetHeight() - sprite.GetHeight(); }