Exemplo n.º 1
0
 static void Main(string[] args)
 {
     GameEngine testEngine = new GameEngine(10, 10);
     testEngine.Start(10);
 }
Exemplo n.º 2
0
        public MainPage()
        {
            this.InitializeComponent();

            // Render Menu
            RenderMenu();
            ShowMenu();

            // Start Audio
            this.canvas.Children.Add(audio);
            audio.Source = new Uri(this.BaseUri, @"Assets/Audio/BackgroundMusic.mp3");
            audio.IsLooping = true;
            audio.Play();

            // Swap Sound Effect
            this.canvas.Children.Add(swapSoundEffect);
            swapSoundEffect.AutoPlay = false;
            swapSoundEffect.Source = new Uri(this.BaseUri, @"Assets/Audio/Button_Push-Mike_Koenig-1659525069.wav");
            swapSoundEffect.IsLooping = false;

            // Leak Sound Effect
            this.canvas.Children.Add(leakSoundEffect);
            leakSoundEffect.AutoPlay = false;
            leakSoundEffect.Source = new Uri(this.BaseUri, @"Assets/Audio/bullet_whizzing_by-Mike_Koenig-2005433595.wav");
            leakSoundEffect.IsLooping = false;

            // Purge sound effect
            this.canvas.Children.Add(purgeSoundEffect);
            purgeSoundEffect.AutoPlay = false;
            purgeSoundEffect.Source = new Uri(this.BaseUri, @"Assets/Audio/Button_Push-Mike_Koenig-1659525069.wav");
            purgeSoundEffect.IsLooping = false;

            // Game Over Sound Effect
            this.canvas.Children.Add(gameOverSoundEffect);
            gameOverSoundEffect.AutoPlay = false;
            gameOverSoundEffect.Source = new Uri(this.BaseUri, @"Assets/Audio/Evil_Laugh_2-Sound_Explorer-1081271267.wav");
            gameOverSoundEffect.IsLooping = false;

            // Create Game Engine
            Game = new GameEngine(15, 10);

            // Create UI
            Grid = new HexagonGrid(Game.Width, Game.Height, canvas, HexTapped);
        }
Exemplo n.º 3
0
        public void Update(GameEngine engine, List<Coordinate> newElements = null, List<Coordinate> explodedElements = null, bool isFromSwap = false)
        {
            // If not specified, render the whole grid
            if (newElements == null && explodedElements == null)
            {
                for (int i = 0; i < engine.Width; i++)
                {
                    for (int j = 0; j < engine.Height; j++)
                    {
                        UpdateHex(Grid[i, j], engine.Grid[i, j]);
                    }
                }
            }
            else
            {
                // Render new elements
                if (newElements != null)
                {
                    foreach (Coordinate c in newElements)
                    {
                        Hexagon hUI = Grid[c.X, c.Y];
                        UpdateHex(hUI, engine.Grid[c.X, c.Y]);
                        AnimateNewHex(hUI);
                    }
                }

                // Remove old elements
                int scorePerElement = explodedElements.Count();
                if (explodedElements != null)
                {
                    foreach (Coordinate c in explodedElements)
                    {
                        Hexagon hUI = Grid[c.X, c.Y];
                        UpdateHex(hUI, engine.Grid[c.X, c.Y]);

                        // Show animation
                        AnimateDestroyHex(hUI);

                        // Show Score
                        if (isFromSwap)
                        {
                            DisplayScore(hUI, scorePerElement);
                        }
                    }
                }
            }
        }