Example #1
0
        public void fill_a_flask(int volume, int expected)
        {
            Flask sut = new Flask(2);

            sut.Fill(volume);
            Assert.AreEqual(expected, sut.Volume);
        }
Example #2
0
        private void PotionManagement()
        {
            if (!Player.InFountain() && !Player.HasBuff("Recall"))
            {
                if (ManaPotion.IsReady() && !Player.HasBuff("FlaskOfCrystalWater"))
                {
                    if (Player.CountEnemiesInRange(1200) > 0 && Player.Mana < 200)
                    {
                        ManaPotion.Cast();
                    }
                }
                if (Player.HasBuff("RegenerationPotion") || Player.HasBuff("ItemMiniRegenPotion") || Player.HasBuff("ItemCrystalFlask"))
                {
                    return;
                }

                if (Flask.IsReady())
                {
                    if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth)
                    {
                        Flask.Cast();
                    }
                    else if (Player.Health < Player.MaxHealth * 0.6)
                    {
                        Flask.Cast();
                    }
                    else if (Player.CountEnemiesInRange(1200) > 0 && Player.Mana < 200 && !Player.HasBuff("FlaskOfCrystalWater"))
                    {
                        Flask.Cast();
                    }
                    return;
                }

                if (Potion.IsReady())
                {
                    if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth)
                    {
                        Potion.Cast();
                    }
                    else if (Player.Health < Player.MaxHealth * 0.6)
                    {
                        Potion.Cast();
                    }
                    return;
                }

                if (Biscuit.IsReady())
                {
                    if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth)
                    {
                        Biscuit.Cast();
                    }
                    else if (Player.Health < Player.MaxHealth * 0.6)
                    {
                        Biscuit.Cast();
                    }
                    return;
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Flask flask = new Flask(4);

            DisplayFlask(flask);

            Console.WriteLine("Calls flask.Fill( 3 )");
            flask.Fill(3);
            DisplayFlask(flask);

            Console.WriteLine("Calls flask.Fill( 2 )");
            flask.Fill(2);
            DisplayFlask(flask);

            Console.WriteLine("Calls flask.Empty( 1 )");
            flask.Empty(1);
            DisplayFlask(flask);

            Console.WriteLine("Calls flask.Empty()");
            flask.Empty();
            DisplayFlask(flask);

            Console.WriteLine("Calls flask.Fill()");
            flask.Fill();

            DisplayFlask(flask);

            new Flask(2);
            new Flask(3);
            Console.WriteLine("Flasks created: {0}", Flask.TotalCount);

            new Flask(1);
            new Flask(4);
            Console.WriteLine("Flasks created: {0}", Flask.TotalCount);
        }
Example #4
0
 static void DisplayFlask(Flask @this)
 {
     Console.WriteLine("==================================");
     Console.WriteLine("Volume: {0}", @this.Volume);
     Console.WriteLine("Max capacity: {0}", @this.MaxCapacity);
     Console.WriteLine("Is full: {0}", @this.IsFull);
     Console.WriteLine("Is empty: {0}", @this.IsEmpty);
     Console.WriteLine("==================================");
 }
Example #5
0
        public void empty_flask()
        {
            Flask sut = new Flask(3);

            sut.Fill(2);

            sut.Empty(1);

            Assert.That(sut.Volume, Is.EqualTo(1));
        }
Example #6
0
        public void total_empty()
        {
            Flask sut = new Flask(3);

            sut.Fill(2);

            sut.Empty();

            Assert.That(sut.Volume, Is.EqualTo(0));
        }
Example #7
0
    private void OnTriggerExit2D(Collider2D other)
    {
        var flask = other.GetComponent <Flask>();

        if (flask == null)
        {
            return;
        }
        temperatureSprite.enabled = false;
        curFlask = null;
    }
Example #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!running)
            {
                //saving settings
                Properties.Settings.Default["cb1"]         = comboBox1.SelectedIndex;
                Properties.Settings.Default["cb2"]         = comboBox2.SelectedIndex;
                Properties.Settings.Default["cb3"]         = comboBox3.SelectedIndex;
                Properties.Settings.Default["cb4"]         = comboBox4.SelectedIndex;
                Properties.Settings.Default["cb5"]         = comboBox5.SelectedIndex;
                Properties.Settings.Default["cb6"]         = comboBox6.SelectedIndex;
                Properties.Settings.Default["cb7"]         = comboBox7.SelectedIndex;
                Properties.Settings.Default["cb8"]         = comboBox8.SelectedIndex;
                Properties.Settings.Default["cb9"]         = comboBox9.SelectedIndex;
                Properties.Settings.Default["cb10"]        = comboBox10.SelectedIndex;
                Properties.Settings.Default["check1"]      = checkBox1.Checked;
                Properties.Settings.Default["check2"]      = checkBox2.Checked;
                Properties.Settings.Default["check3"]      = checkBox3.Checked;
                Properties.Settings.Default["check4"]      = checkBox4.Checked;
                Properties.Settings.Default["check5"]      = checkBox5.Checked;
                Properties.Settings.Default["showWC"]      = checkBox6.Checked;
                Properties.Settings.Default["qual1"]       = (int)numericUpDown1.Value;
                Properties.Settings.Default["qual2"]       = (int)numericUpDown2.Value;
                Properties.Settings.Default["qual3"]       = (int)numericUpDown3.Value;
                Properties.Settings.Default["qual4"]       = (int)numericUpDown4.Value;
                Properties.Settings.Default["qual5"]       = (int)numericUpDown5.Value;
                Properties.Settings.Default["globalqual"]  = (int)numericUpDown6.Value;
                Properties.Settings.Default["Alpha"]       = (decimal)numericUpDown7.Value;
                Properties.Settings.Default["Xmovement"]   = (int)numericUpDown8.Value;
                Properties.Settings.Default["XResolution"] = (int)numericUpDown9.Value;
                Properties.Settings.Default["YResolution"] = (int)numericUpDown10.Value;
                Properties.Settings.Default.Save();
                Flask f1 = new Flask(checkBox1.Checked, (Flask.Name)comboBox6.SelectedValue, (Keys2)comboBox1.SelectedItem, (int)numericUpDown1.Value);
                Flask f2 = new Flask(checkBox2.Checked, (Flask.Name)comboBox7.SelectedValue, (Keys2)comboBox2.SelectedItem, (int)numericUpDown2.Value);
                Flask f3 = new Flask(checkBox3.Checked, (Flask.Name)comboBox8.SelectedValue, (Keys2)comboBox3.SelectedItem, (int)numericUpDown3.Value);
                Flask f4 = new Flask(checkBox4.Checked, (Flask.Name)comboBox9.SelectedValue, (Keys2)comboBox4.SelectedItem, (int)numericUpDown4.Value);
                Flask f5 = new Flask(checkBox5.Checked, (Flask.Name)comboBox10.SelectedValue, (Keys2)comboBox5.SelectedItem, (int)numericUpDown5.Value);

                Flasks.Add(f1);
                Flasks.Add(f2);
                Flasks.Add(f3);
                Flasks.Add(f4);
                Flasks.Add(f5);
                f = new Form1(Flasks, (int)numericUpDown6.Value, (float)numericUpDown7.Value, (int)numericUpDown8.Value, (float)numericUpDown9.Value, (float)numericUpDown10.Value, checkBox6.Checked);
                f.Show();
                running = true;
            }
        }
 private void ProcessFlaskUse(Flask flask)
 {
     if (_player.Health <= 100)
     {
         _player.Health += flask.HealthChange;
         _player.RemoveGameItemFromInventory(_currentGameItem);
         if (_player.Health > 100)
         {
             _player.Health = 100;
         }
     }
     else
     {
         CurrentLocationInformation = "Your health is already full!";
     }
 }
Example #10
0
    private void OnTriggerStay2D(Collider2D other)
    {
        var dragAndDrop = other.GetComponent <DragAndDrop>();

        if (dragAndDrop == null)
        {
            return;
        }
        else if (dragAndDrop.drag)
        {
            return;
        }
        var alchemicalComponent = other.GetComponent <AlchemicalComponent>();
        var flask = other.GetComponent <Flask>();

        if (flask == null)
        {
            var bag = other.GetComponent <Bag>();
            if (bag == null)
            {
                return;
            }
            if (curFlask != null)
            {
                ToMixture(alchemicalComponent, other.gameObject);
            }
        }
        else
        {
            if ((curFlask != null) && (curFlask != flask))
            {
                ToMixture(alchemicalComponent, other.gameObject);
            }

            curFlask = flask;
            flask.SetOnStand();
            other.transform.position  = emptyFlask.transform.position;
            temperatureSprite.enabled = true;
            if (alchemicalComponent != null)
            {
                temperatureSprite.sprite =
                    temperatureStatusSprites[(int)alchemicalComponent.alchemicalComponentParams.temperature.state];
            }
        }
    }
    private void SpawnFlasks(int flaskCount)
    {
        Vector3 flaskSize  = flaskPrefab.transform.localScale;
        float   ballRadius = ballPrefab.Radius;
        Vector3 cell       = new Vector3(flaskSize.x * flaskPaddingX, flaskSize.y + ballRadius * flaskPaddingY, 0);

        Flasks = new Flask[flaskCount];

        int rows    = flaskCount % absoluteMaxFlaskInARow > 0 ? flaskCount / absoluteMaxFlaskInARow + 1 : flaskCount / absoluteMaxFlaskInARow;
        int columns = flaskCount % rows > 0 ? flaskCount / rows + 1 : flaskCount / rows;

        for (int i = 0; i < flaskCount; i++)
        {
            Vector3 position = new Vector3(cell.x * (i % columns), cell.y * (i / columns));
            Flasks[i] = Instantiate(flaskPrefab, position, Quaternion.identity);
            Flasks[i].CalculateBallPositions(flaskCapacity, ballRadius, distanceBetweenBalls);
        }

        AdjustCameraPosition(rows, columns, cell);
    }
Example #12
0
 private void OnFlaskTouch(Flask flask)
 {
     if (takenBall == null)
     {
         if (flask.TryTake(out takenBall))
         {
             ActiveCollider();
             takenBall.Arrived.AddListener(ActiveCollider);
         }
     }
     else if (flask.TryPut(takenBall))
     {
         ActiveCollider();
         takenBall.Arrived.AddListener(() =>
         {
             takenBall.Arrived.RemoveAllListeners();
             takenBall = null;
             CheckWin();
         });
     }
 }
    private bool FillFlasks(Color[] colors, int ballsToSpawn)
    {
        Ball[] balls = new Ball[ballsToSpawn];

        for (int i = 0; i < balls.Length; i++)
        {
            var ball = Instantiate(ballPrefab);
            ball.Color = colors[i % colors.Length];
            balls[i]   = ball;
        }

        for (int i = 0; i < balls.Length; i++)
        {
            int toSwap = Random.Range(0, balls.Length);
            var buf    = balls[toSwap];
            balls[toSwap] = balls[i];
            balls[i]      = buf;
        }

        Flask flask = Flasks[0];

        for (int i = 0, next = 1; i < balls.Length; i++)
        {
            if (flask.IsFull)
            {
                if (flask.AreSameColors())
                {
                    return(false);
                }
                else
                {
                    flask = Flasks[next++];
                }
            }
            flask.PutImmediate(balls[i]);
        }
        return(true);
    }
Example #14
0
 static void MakeUsable(Flask f)
 {
     f.usable = true;
 }
Example #15
0
        protected override void Update(GameTime gameTime)
        {
            cursorPos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

            // Updating the game while in Start Menu
            // When game is at start menu it adds music and checks if we press
            // the buttons. If we do press the buttons it changes the game state
            // and changes other variables.
            if (gameState == GameState.StartMenu)
            {
                // Music Properties
                if (MediaPlayer.State != MediaState.Playing)
                {
                    MediaPlayer.Play(menuSong);
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Volume      = 0.1f;
                }

                // When pressing the Play Button
                if (playButton.clicked)
                {
                    clickSound.Play();
                    levelMenu1         = true;
                    gameState          = GameState.LevelMenu;
                    playButton.clicked = false;
                }

                // When pressing the Quit Button
                if (quitButton.clicked)
                {
                    this.Exit();
                }

                // When pressing name check button
                if (checkButton.clicked)
                {
                    clickSound.Play();
                    checkedPlayerName   = playerName;
                    checkButton.clicked = false;
                }

                playButton.Update();
                quitButton.Update();
                checkButton.Update();

                // Player name input
                foreach (Keys k in Keyboard.GetState().GetPressedKeys())
                {
                    if ((k >= Keys.A && k <= Keys.Z) && Input.IsKeyReleased(k))
                    {
                        playerName += k.ToString();
                    }
                    if ((k == Keys.Enter) && Input.IsKeyReleased(k))
                    {
                        checkedPlayerName = playerName;
                    }

                    if ((k == Keys.Back) && Input.IsKeyReleased(k))
                    {
                        if (playerName.Length < 0)
                        {
                            playerName += "";
                        }
                        else
                        {
                            playerName = playerName.Remove(playerName.Length - 1);
                        }
                    }
                }
            }

            // Updating the game while in LEVEL MENU and so it means that it is testing
            // if the buttons are clicked and if so it changes the game state and the level.
            if (gameState == GameState.LevelMenu)
            {
                if (levelMenu1 == true)
                {
                    if (nivel1Button.clicked)
                    {
                        InitializeLevel(0);
                        nivel1Button.clicked = false;
                    }

                    if (nivel2Button.clicked)
                    {
                        InitializeLevel(1);
                        nivel2Button.clicked = false;
                    }

                    if (nivel3Button.clicked)
                    {
                        InitializeLevel(2);
                        nivel3Button.clicked = false;
                    }

                    if (nivel4Button.clicked)
                    {
                        InitializeLevel(3);
                        nivel4Button.clicked = false;
                    }

                    if (nivel5Button.clicked)
                    {
                        InitializeLevel(4);
                        nivel5Button.clicked = false;
                    }

                    if (nivel6Button.clicked)
                    {
                        InitializeLevel(5);
                        nivel6Button.clicked = false;
                    }

                    if (previousMenuButton.clicked)
                    {
                        clickSound.Play();
                        levelMenu1 = false;
                        levelMenu2 = false;
                        gameState  = GameState.StartMenu;
                        previousMenuButton.clicked = false;
                    }

                    if (nextMenuButton.clicked)
                    {
                        clickSound.Play();
                        levelMenu1             = false;
                        levelMenu2             = true;
                        nextMenuButton.clicked = false;
                    }
                    nivel1Button.Update();
                    nivel2Button.Update();
                    nivel3Button.Update();
                    nivel4Button.Update();
                    nivel5Button.Update();
                    nivel6Button.Update();
                    previousMenuButton.Update();
                    nextMenuButton.Update();
                }
                if (levelMenu2 == true)
                {
                    if (nivel7Button.clicked)
                    {
                        InitializeLevel(6);
                        nivel7Button.clicked = false;
                    }
                    if (nivel8Button.clicked)
                    {
                        InitializeLevel(7);
                        nivel8Button.clicked = false;
                    }
                    if (nivel9Button.clicked)
                    {
                        InitializeLevel(8);
                        nivel9Button.clicked = false;
                    }
                    if (nivel10Button.clicked)
                    {
                        InitializeLevel(9);
                        nivel10Button.clicked = false;
                    }
                    if (nivel11Button.clicked)
                    {
                        InitializeLevel(10);
                        nivel11Button.clicked = false;
                    }
                    if (nivel12Button.clicked)
                    {
                        InitializeLevel(11);
                        nivel12Button.clicked = false;
                    }
                    if (previousMenuButton.clicked)
                    {
                        clickSound.Play();
                        levelMenu1 = true;
                        levelMenu2 = false;
                        previousMenuButton.clicked = false;
                    }
                    nivel7Button.Update();
                    nivel8Button.Update();
                    nivel9Button.Update();
                    nivel10Button.Update();
                    nivel11Button.Update();
                    nivel12Button.Update();
                    previousMenuButton.Update();
                }
            }

            // Updating the game while in Playing, Pause and GameOver
            if (gameState == GameState.Playing)
            {
                // In Playing Mode.
                if (isPlaying == true)
                {
                    // It checks if the pause is clicked to go to the pause menu.
                    if (pauseButton.clicked)
                    {
                        isPaused            = true;
                        pauseButton.clicked = false;
                    }

                    // Shooting
                    // Pressing mouse left click and verifing if some variables are true
                    // shoots the flask by calculating direction vector between mouse position and
                    // flask position and gives him a velocity by multiplying the position w/ the speed.
                    if (Input.IsMousePressed())
                    {
                        if ((gun.canShoot) && (Mouse.GetState().X > 200))
                        {
                            flaskSound.Play(0.3f, 0.6f, 0);
                            flask          = currentLevel.flaskList[currentFlask];
                            flask.position = new Vector2(70, 375);
                            Vector2 direction = new Vector2(Mouse.GetState().X - flask.position.X, Mouse.GetState().Y - flask.position.Y);
                            direction.Normalize();
                            flask.velocity = direction * flask.speed;
                            currentFlask++;
                            gun.canShoot               = false;
                            flask.visible              = true;
                            flask.idleRotation         = 2;
                            currentLevel.attemptScore -= 10000;
                        }
                    }

                    // Collisions and Gravity Fields
                    if ((gun.canShoot == false) && (flask != null))
                    {
                        //Shoot enabled when flask reaches screen bounds
                        if (GraphicsDevice.Viewport.Bounds.Contains(flask.myspace) == false)
                        {
                            flaskLostSound.Play(0.8f, 0.3f, 0);
                            currentLevel.orbitingScore = 0;
                            gun.canShoot  = true;
                            flask.visible = false;
                            if (currentFlask >= 4)
                            {
                                if (currentLevel.IsFinished == false)
                                {
                                    gameState = GameState.GameOver;
                                }
                                currentFlask = 0;
                            }
                        }

                        // For each flask in the list it calculates its update
                        foreach (Flask f in currentLevel.flaskList)
                        {
                            f.Update(gameTime.ElapsedGameTime);
                        }
                        // For each planet in the list
                        foreach (Planet p in currentLevel.planetList)
                        {
                            // Calculates flask gravity when entering planet atmosphere
                            if (flask.calculateGravity(p))
                            {
                                currentLevel.orbitingScore += 105;
                            }

                            // When flask colide with any planet
                            if (Vector2.Distance(new Vector2(flask.myspace.Center.X, flask.myspace.Center.Y),
                                                 new Vector2(p.myspace.Center.X, p.myspace.Center.Y)) < p.radius + 15)
                            {
                                if (p.isTarget == true)
                                {
                                    currentLevel.IsFinished = true;
                                }
                                else
                                {
                                    currentLevel.orbitingScore = 0;
                                    flask.visible = false;
                                    gun.canShoot  = true;
                                    crashingSound.Play();
                                }
                                // If the fourth flask colides with any planet, despite the target, its GameOver
                                if (currentFlask >= 4)
                                {
                                    if (currentLevel.IsFinished == false)
                                    {
                                        gameState = GameState.GameOver;
                                    }
                                    currentFlask = 0;
                                }
                            }
                        }
                    }

                    foreach (Planet p in currentLevel.planetList)
                    {
                        p.Update(gameTime.ElapsedGameTime);
                    }
                    gun.Update(gameTime.ElapsedGameTime);
                    pauseButton.Update();
                }
                // In Pause Menu
                if (isPaused == true)
                {
                    isPlaying = false;
                    // Click Resume Button to go back to the playing state
                    if (pauseResumeButton.clicked)
                    {
                        isPaused  = false;
                        isPlaying = true;
                        pauseResumeButton.clicked = false;
                    }

                    // Click Menu Button to go back to level menu
                    if ((pauseMenuButton.clicked))
                    {
                        isPaused  = false;
                        isPlaying = false;
                        gameState = GameState.LevelMenu;
                        pauseMenuButton.clicked = false;
                    }

                    // It checks if the retry button is clicked to reset the level.
                    if (pauseRestartButton.clicked)
                    {
                        isPaused = false;
                        pauseRestartButton.clicked = false;
                        InitializeLevel(Level.n_level);
                    }
                    pauseResumeButton.Update();
                    pauseMenuButton.Update();
                    pauseRestartButton.Update();
                }
                // In Finish Mode
                if (currentLevel.IsFinished == true)
                {
                    isPlaying = false;
                    finalRetryButton.Update();
                    currentLevel.UpdateFinish();
                    if ((Level.n_level < 0) || (Level.n_level > levelList.Count - 1))
                    {
                        gameState = GameState.LevelMenu;
                        MediaPlayer.Play(menuSong);
                    }
                    else if (currentLevel.IsFinished == false)
                    {
                        InitializeLevel(Level.n_level);
                    }

                    // It checks if the retry button is clicked to reset the level.
                    if (finalRetryButton.clicked)
                    {
                        isPaused = false;
                        finalRetryButton.clicked = false;
                        InitializeLevel(Level.n_level);
                    }
                }
            }

            if (gameState == GameState.GameOver)
            {
                if (gameoverMenuButton.clicked)
                {
                    gameState = GameState.LevelMenu;
                    gameoverMenuButton.clicked = false;
                }
                if (gameoverRetryButton.clicked)
                {
                    gameState = GameState.Playing;
                    InitializeLevel(Level.n_level);
                    gameoverRetryButton.clicked = false;
                }
                gameoverMenuButton.Update();
                gameoverRetryButton.Update();
            }
            base.Update(gameTime);
        }
    static void Main()
    {
        Flask newFlask = new Flask();
        int numberOfPassengers = int.Parse(Console.ReadLine());
        int[] passengers = new int[numberOfPassengers - 1];

        int numberOfCoffie = int.Parse(Console.ReadLine());

        for (int i = 0; i < numberOfCoffie; i++)
        {
            int coffie = int.Parse(Console.ReadLine());
            passengers[coffie - 1] = 1;
        }

        int totalTime = 0;
        if (passengers[0] == 1)
        {
            newFlask.typeOfDrink = 1;
            newFlask.amountOfDrink = 7;
            totalTime += 47;
        }
        else
        {
            newFlask.typeOfDrink = 0;
            newFlask.amountOfDrink = 7;
            totalTime += 47;
        }

        for (int tea = 0; tea < 2; tea++)
        {
            for (int i = 0; i < passengers.Length; i++)
            {
                if (newFlask.amountOfDrink == 0)
                {
                    totalTime += (i + 1) * 2;
                    totalTime += 47;
                }

                totalTime++;

                if (newFlask.typeOfDrink == passengers[i])
                {
                    totalTime += 4;
                    newFlask.amountOfDrink--;
                }
            }
        }
        //for (int i = 0; i < passengers.Length; i++)
        //{
        //    if (newFlask.amountOfDrink == 0)
        //    {
        //        totalTime += (i + 1) * 2;
        //        totalTime += 47;
        //    }
        //    totalTime++;
        //    if (passengers[i] == newFlask.typeOfDrink)
        //    {
        //        newFlask.amountOfDrink--;
        //        totalTime += 4;
        //    }
        //    else
        //    {
        //        totalTime += (i + 1) * 2;
        //        totalTime += 47;
        //        newFlask.typeOfDrink = passengers[i];
        //        newFlask.amountOfDrink = 7;
        //        totalTime += 4;
        //        newFlask.amountOfDrink--;
        //    }
        //}

        Console.WriteLine(totalTime);
    }
Example #17
0
        public void fill_with_negative_volume_should_throws_an_exception()
        {
            Flask sut = new Flask(3);

            Assert.Throws <ArgumentException>(() => sut.Fill(-1));
        }