Update() 개인적인 메소드

private Update ( ) : void
리턴 void
예제 #1
0
    private void Update()
    {
        UpdateCurrentTurn();

        switch (mode)
        {
        case GameMode.AVA:
        {
            jonnyBot.Update();
            if (jonnyBot.IsReady())
            {
                jonnyBot.InvertSide();
                jonnyBot.Turn(buttons);
            }
        }
        break;

        case GameMode.AVP:
        {
            if (!isPlayerTurn)
            {
                jonnyBot.Update();
                if (jonnyBot.IsReady())
                {
                    jonnyBot.Turn(buttons);
                    isPlayerTurn = !isPlayerTurn;
                }
            }
        }
        break;
        }
    }
예제 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // For Mobile devices, this logic will close the Game when the Back button is pressed
            // Exit() is obsolete on iOS
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            ////////////////////////////

            // tiles
            foreach (Tile tile in tiles)
            {
                tile.Update();
            }

            // players
            p1.Update();
            p2.Update();

            //if(rnd.Next(50) == 0) {
            //    int x = rnd.Next(NUM_TILES);
            //    int y = rnd.Next(NUM_TILES);
            //    //while(tiles[x, y].isOccupied()) {
            //    //    x = rnd.Next(NUM_TILES);
            //    //    y = rnd.Next(NUM_TILES);
            //    //}
            //    tiles[x, y].PlaceSprite(new Wall(tiles[x, y].pos, this));
            //}

            ////////////////////////////

            base.Update(gameTime);
        }
예제 #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            int wDist      = bot.getWidth() * 8;
            int hDist      = bot.getHeight() * 8;
            int widthDist  = (Window.ClientBounds.Width - (bot.getWidth())) - wDist;
            int heightDist = (Window.ClientBounds.Height - (bot.getHeight())) - hDist;
            int zoneWDist  = ((currZone.x + currZone.width) - Window.ClientBounds.Width);
            int zoneHDist  = ((currZone.y + currZone.height) - Window.ClientBounds.Height);

            // Updates
            bot.Update(gameTime, Window);
            // Camera logic
            // X
            if (bot.getX() > (camera.Position.X + widthDist))
            {
                camera.Position = new Vector2((bot.getX() - widthDist), camera.Position.Y);
            }
            if (bot.getX() < (camera.Position.X + wDist))
            {
                camera.Position = new Vector2((bot.getX() - wDist), camera.Position.Y);
            }
            // Y
            if (bot.getY() > (camera.Position.Y + heightDist))
            {
                camera.Position = new Vector2(camera.Position.X, (bot.getY() - heightDist));
            }
            if (bot.getY() < (camera.Position.Y + hDist))
            {
                camera.Position = new Vector2(camera.Position.X, (bot.getY() - hDist));
            }
            // Catch to make sure position doesn't move outside Zone bounds
            if (camera.Position.X < currZone.x)
            {
                camera.Position = new Vector2(currZone.x, camera.Position.Y);
            }
            else if (camera.Position.X > zoneWDist)
            {
                camera.Position = new Vector2(zoneWDist, camera.Position.Y);
            }
            if (camera.Position.Y < currZone.y)
            {
                camera.Position = new Vector2(camera.Position.X, currZone.y);
            }
            else if (camera.Position.Y > zoneHDist)
            {
                camera.Position = new Vector2(camera.Position.X, zoneHDist);
            }

            base.Update(gameTime);
        }
예제 #4
0
 private void UpdateClients()
 {
     lock (Bot)
     {
         if (Bot.Game != null)
         {
             Bot.Game.Update();
         }
         Bot.Update();
     }
     Task.Delay(1).ContinueWith((previous) => UpdateClients());
 }
예제 #5
0
 public override void Update()
 {
     if (gameStarted && !Global.isGamePaused)
     {
         Bot.Update();
         if (Global.tick % StatisticWatcher.updatePeriod == 0)
         {
             StatisticWatcher.trackPoints(Global.tick);
         }
         if (Global.tick++ % 500 == 0)
         {
             StatisticWatcher.trackCoins(1);
             Teams.playerBlue.AddCoin();
             Teams.playerRed.AddCoin();
         }
     }
 }
예제 #6
0
        public void Update(GameTime gt, InputManager input)
        {
            Bot.Update(gt, input);

            if (HasWon)
            {
                _spamFadeTime += (float)gt.Elapsed.TotalSeconds;

                if (_spamFadeTime >= SPAM_FADE_TIME)
                {
                    Main.UI.SetState(UIState.SixAM);
                }
                return;
            }

            Office.Update(gt, input);
            Laptop.Update(gt, input);

            Monsters.Update(gt, input);

            // Cheats
            if (input.IsKeyPressed(Keys.D6))
            {
                Time = VICTORY_TIME;
            }

            if (input.IsKeyPressed(Keys.F7))
            {
                CHEAT_InfiniteExposure = !CHEAT_InfiniteExposure;
            }

            if (input.IsKeyPressed(Keys.F8))
            {
                CHEAT_InfiniteBattery = !CHEAT_InfiniteBattery;
            }

            if (input.IsKeyPressed(Keys.F9))
            {
                CHEAT_MapDebug = !CHEAT_MapDebug;
            }

            if (input.IsKeyPressed(Keys.F10))
            {
                CHEAT_MonstersStayPut = !CHEAT_MonstersStayPut;
            }

            if (input.IsKeyPressed(Keys.F11))
            {
                CHEAT_OwlInvincibility = !CHEAT_OwlInvincibility;
            }

            // ESC returns to main menu
            if (input.IsKeyPressed(Keys.Escape))
            {
                UI.SetState(UIState.MainMenu);
            }

            // Bot switch
            if (input.IsKeyPressed(Keys.F1))
            {
                Bot = new PlayerMouseInput(this);
                Bot.Reset();
            }
            else if (input.IsKeyPressed(Keys.F2))
            {
                Bot = new PsychicAI(this);
                Bot.Reset();
            }
            else if (input.IsKeyPressed(Keys.F3))
            {
                Bot = new SmartAI(this);
                Bot.Reset();
            }

            if (_flipUpEnabled && Bot.MousePos.Y >= FLIPUP_THRESHOLD && !_isMouseLingering && !IsJumpscaring)
            {
                Laptop.ToggleLaptop();
                _isMouseLingering = true;
            }

            if (Bot.MousePos.Y < FLIPUP_THRESHOLD && _isMouseLingering && !IsJumpscaring)
            {
                _isMouseLingering = false;
            }

            if (!IsJumpscaring)
            {
                Time += (float)gt.Elapsed.TotalSeconds;
            }
            else
            {
                if (gt.FrameCount % 2 == 0)
                {
                    jumpscareShakeOffset = new Vector2((float)(Rand.NextDouble() * JUMPSCARE_SHAKE_RANGE + JUMPSCARE_SHAKE_MIN),
                                                       (float)(Rand.NextDouble() * JUMPSCARE_SHAKE_RANGE + JUMPSCARE_SHAKE_MIN));
                }

                if (Main.UI.State == UIState.Laptop)
                {
                    Laptop.ToggleLaptop();
                }
            }

            if (Monsters.IsExposed)
            {
                _exposureShakeOffset = (int)(Math.Sin(gt.Total.TotalSeconds * SHAKE_SPEED) * EXPOSURE_SHAKE_MAX);
            }

            if (Exposure >= 0.95f && CHEAT_InfiniteExposure)
            {
                Exposure = 0;                 // Reset exposure at 95%
            }

            if (Monsters.IsExposed && Exposure >= 1.0f && !CHEAT_InfiniteExposure)
            {
                IsJumpscaring = true;
                Monsters.StartJumpscareFromExposure();
                exposureUpSound.Stop();
            }

            if (Time >= VICTORY_TIME && !IsJumpscaring)
            {
                HasWon = true;
                spamMusic.Play();

                Main.HasWon = true;

                if (IsHardBoiled)
                {
                    Main.HasWonHardboiled = true;
                }
            }

            _flipUpEnabled = false;
            if (!Laptop.IsLaptopSwitching)
            {
                if (Main.UI.State == UIState.Laptop || Office.IsLightOn)
                {
                    _flipUpEnabled = true;
                }
            }

            if (Main.UI.State == UIState.Office && Office.IsLightOn)
            {
                const float CHARGE_SPEED = 1.0f / LAPTOP_BATTERY_TIME;
                LaptopBattery = Math.Min(LaptopBattery + CHARGE_SPEED * (float)gt.Elapsed.TotalSeconds, 1.0f);
            }
        }
예제 #7
0
    static void Run(string[] args)
    {
        string[]       inputs;
        string         line;
        int            projectCount = int.Parse(Console.ReadLine());
        List <Project> projects     = new List <Project>();

        for (int i = 0; i < projectCount; i++)
        {
            line = Console.ReadLine();
            Console.Error.WriteLine(line);
            inputs = line.Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            int c = int.Parse(inputs[2]);
            int d = int.Parse(inputs[3]);
            int e = int.Parse(inputs[4]);
            Project.Projects.Add(new Project(a, b, c, d, e));
        }

        Bot bot = new Bot(Project.GetEasiestProject());

        // game loop
        while (true)
        {
            List <Sample> samples   = new List <Sample>();
            int[]         available = new int[5];

            line = Console.ReadLine();
            Console.Error.WriteLine(line);
            inputs = line.Split(' ');
            bot.Update(inputs[0], int.Parse(inputs[1]), int.Parse(inputs[2]), int.Parse(inputs[3]), int.Parse(inputs[4]), int.Parse(inputs[5]), int.Parse(inputs[6]), int.Parse(inputs[7]), int.Parse(inputs[8]), int.Parse(inputs[9]), int.Parse(inputs[10]), int.Parse(inputs[11]), int.Parse(inputs[12]));

            Console.ReadLine();
            line = Console.ReadLine();
            Console.Error.WriteLine(line);
            inputs = line.Split(' ');
            int availableA = int.Parse(inputs[0]);
            int availableB = int.Parse(inputs[1]);
            int availableC = int.Parse(inputs[2]);
            int availableD = int.Parse(inputs[3]);
            int availableE = int.Parse(inputs[4]);
            Molecule.Available = new int[] { availableA, availableB, availableC, availableD, availableE };
            int sampleCount = int.Parse(Console.ReadLine());
            for (int i = 0; i < sampleCount; i++)
            {
                line = Console.ReadLine();
                Console.Error.WriteLine(line);
                inputs = line.Split(' ');
                int    sampleId      = int.Parse(inputs[0]);
                int    carriedBy     = int.Parse(inputs[1]);
                int    rank          = int.Parse(inputs[2]);
                string expertiseGain = inputs[3];
                int    health        = int.Parse(inputs[4]);
                int    costA         = int.Parse(inputs[5]);
                int    costB         = int.Parse(inputs[6]);
                int    costC         = int.Parse(inputs[7]);
                int    costD         = int.Parse(inputs[8]);
                int    costE         = int.Parse(inputs[9]);
                samples.Add(new Sample(sampleId, carriedBy, rank, expertiseGain, health, costA, costB, costC, costD, costE));
            }
            bot.Update(samples);

            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine("Debug messages...");

            Console.WriteLine(bot.Request(samples));
        }
    }
예제 #8
0
 public void StartPosTargetZeroEtaIsAtStartState()
 {
     Assert.NotNull(b);
     b.Update("START_POS", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     Assert.IsInstanceOf(typeof(AtStart), b.State);
 }