public UITextBlockVisual(UITextBlockActor actor, SpriteBatch spriteBatch, IResourceDictionary resourceDictionary) { _actor = actor; _spriteBatch = spriteBatch; _currentAnimations = new List<Animation>(); this._resourceDictionary = resourceDictionary; }
protected override void OnInitialize(Object initializationData) { random = new Random(); _mode = ZazumoActionMode.Normal; Subscribe<PlayerDiedEvent>(OnPlayerDied); Subscribe<ZazumoShapeChangedEvent>(OnShapeChanged); Subscribe<WormholeClosedEvent>(OnWormholeClosed); Subscribe<MiniBossDestroyedEvent>(OnMiniBossDestroyed); Subscribe<EnemyDestoryedEvent>(OnEnemyDestroyed); Subscribe<EnemyFlockDestroyedEvent>(OnEnemyFlockDestroyed); Subscribe<AmmoDepletedEvent>(OnAmmoDepleted); Subscribe<ZazumoSizeChangedEvent>(OnSizeChanged); Subscribe<PointsAwardedEvent>(OnPointsAwarded); Subscribe<BigPointsAwardedEvent>(OnBigPointsAwarded); Subscribe<BombAwardedEvent>(OnBombAwarded); Subscribe<BombDeployedEvent>(OnBombDeployed); this._currentShape = ZazumoShape.None; ResourceDictionary.LoadPackage("Packages/Zazumo"); ResourceDictionary.LoadPackage("Packages/Level1"); this._lives = 5; _bounds = new Rectangle(0, 0, 10, 6); this._scoreTextBlock = ActorFactory.Create<UITextBlockActor>(new Object(), new Vector2(25f, 25f)); this._scoreTextBlock.FontKey = "ScoreFont"; this._scoreTextBlock.Text = "0"; this._scoreTextBlock.TextAlignment = UITextBlockActor.Alignment.Right; this._livesTextBlock = ActorFactory.Create<UITextBlockActor>(new Object(), new Vector2(60f, 425f)); this._livesTextBlock.FontKey = "MainFont"; this._livesTextBlock.Text = "X" + (_lives - 1).ToString(); this._livesTextBlock.Color = Color.Black; this._livesTextBlock.TextAlignment = UITextBlockActor.Alignment.Left; this._background = ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height, Width = _bounds.Width, SpriteKey = "Level1.Sprites.Level1Background" }, new Vector2(_bounds.Left, _bounds.Top)); this._backgroundR = ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height, Width = _bounds.Width, SpriteKey = "Level1.Sprites.Level1BackgroundR" }, new Vector2(_bounds.Right, _bounds.Top)); this._backgroundCloud = ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height, Width = _bounds.Width, SpriteKey = "Level1.Sprites.Level1Cloud" }, new Vector2(_bounds.Left, _bounds.Top)); this._backgroundCloudR = ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height, Width = _bounds.Width, SpriteKey = "Level1.Sprites.Level1CloudR" }, new Vector2(_bounds.Right, _bounds.Top)); this._background.Opacity = 0.75f; this._backgroundR.Opacity = 0.75f; this._backgroundCloud.Opacity = 0.75f; this._backgroundCloudR.Opacity = 0.75f; ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.75f, Width = 0.375f, SpriteKey = "Zazumo.Sprites.RemainingLives" }, new Vector2(0.4f, _bounds.Bottom - 1.05f)).Opacity = 0.75f; WormholeActor wormhole; wormhole = ActorFactory.Create<WormholeActor>(new WormholeData { Width = 1.0f, Height = 1.0f, SpriteKey = "Zazumo.Sprites.StarWormhole", Size = 1, CollisionHullKey = "WormholeCollisionHull", CollisionGroup = 1, Shape = ZazumoShape.Star, MiniBossData = new LevelSpawnData { SpawnType = SpawnType.Eye, Data = new EyeData { HitPoints = 3 } } }, new Vector2(0.5f, 0.5f)); wormhole.SetProperty("Center", new Vector2(0.5f, 0.5f)); wormhole = ActorFactory.Create<WormholeActor>(new WormholeData { Width = 2.5f, Height = 2.5f, SpriteKey = "Zazumo.Sprites.StarWormhole", Size = 4, CollisionHullKey = "WormholeCollisionHull", CollisionGroup = 1, Shape = ZazumoShape.Star, MiniBossData = new LevelSpawnData { SpawnType = SpawnType.Boulder, Data = new BoulderData { HitPoints = 3, EnemyCount = 4 } } }, new Vector2(3f, 1f)); wormhole.SetProperty("Center", new Vector2(0.5f, 0.5f)); wormhole = ActorFactory.Create<WormholeActor>(new WormholeData { Width = 3f, Height = 3f, SpriteKey = "Zazumo.Sprites.StarWormhole", Size = 5, CollisionHullKey = "WormholeCollisionHull", CollisionGroup = 1, Shape = ZazumoShape.Star, MiniBossData = new LevelSpawnData { SpawnType = SpawnType.Eye, Data = new EyeData { HitPoints = 3 } } }, new Vector2(6f, 3f)); wormhole.SetProperty("Center", new Vector2(0.5f, 0.5f)); ActorFactory.Create<WallVolume>(new VolumeWorldObject { Width = _bounds.Width, Height = 0.1f }, new Vector2(_bounds.Left + 0.2f, _bounds.Top + 0.2f)); ActorFactory.Create<WallVolume>(new VolumeWorldObject { Width = 0.1f, Height = _bounds.Height }, new Vector2(_bounds.Left + 0.2f, _bounds.Top + 0.2f)); ActorFactory.Create<WallVolume>(new VolumeWorldObject { Width = _bounds.Width, Height = 0.1f }, new Vector2(_bounds.Left + 0.2f, _bounds.Bottom - 0.2f)); ActorFactory.Create<WallVolume>(new VolumeWorldObject { Width = 0.1f, Height = _bounds.Height }, new Vector2(_bounds.Right - 0.2f, _bounds.Top + 0.2f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.25f, Width = 0.25f, SpriteKey = "Zazumo.Sprites.TopLeftCornerBorder" }, new Vector2(_bounds.Left + 0.19f, _bounds.Top + 0.2f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.05f, Width = _bounds.Width - 0.8f, SpriteKey = "Zazumo.Sprites.HorizontalBorder" }, new Vector2(_bounds.Left + 0.4f, _bounds.Top + 0.2f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.25f, Width = 0.25f, SpriteKey = "Zazumo.Sprites.TopRightBorder" }, new Vector2(_bounds.Right - 0.415f, _bounds.Top + 0.2f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height - 0.8f, Width = 0.05f, SpriteKey = "Zazumo.Sprites.VerticalBorder" }, new Vector2(_bounds.Right - 0.25f, _bounds.Top + 0.4f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.25f, Width = 0.25f, SpriteKey = "Zazumo.Sprites.BottomRightBorder" }, new Vector2(_bounds.Right - 0.415f, _bounds.Bottom - 0.425f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.05f, Width = _bounds.Width - 0.8f, SpriteKey = "Zazumo.Sprites.HorizontalBorder" }, new Vector2(_bounds.Left + 0.4f, _bounds.Bottom - 0.25f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = 0.25f, Width = 0.25f, SpriteKey = "Zazumo.Sprites.BottomLeftBorder" }, new Vector2(_bounds.Left + 0.19f, _bounds.Bottom - 0.425f)); ActorFactory.Create<DecoratorActor>(new Drawable { Height = _bounds.Height - 0.8f, Width = 0.05f, SpriteKey = "Zazumo.Sprites.VerticalBorder" }, new Vector2(_bounds.Left + 0.2f, _bounds.Top + 0.4f)); _normalSpawnData = (LevelSpawnData[])ResourceDictionary.GetResource("Level1NormalSpawnData"); CreateZazumo(); CreateClam(); }