Exemplo n.º 1
0
        public override void Update()
        {
            base.Update();
            shittyTimerDontUse++;
            roundStarted = true;

            //Console.WriteLine(roundTimeLeft);

            if (roundTimeLeft % 60 == 0 && !tunnel)
            {
                tunnel       = true;
                tunnelsTimer = 3;
            }

            if (roundTimeLeft < 15 && !resetMatch)
            {
                resetMatch     = true;
                player.gold    = 100;
                player.weapons = new List <Weapon>()
                {
                    new Revolver(player),
                    null,
                    null,
                    null,
                };
                player.weapon = player.weapons[0];
                MainGame.dm.Mailman.sendWeaponSwitch(0);
                for (int i = 0; i < GameObjects.Count; i++)
                {
                    if (GameObjects[i] is Coin)
                    {
                        GameObjects.RemoveAt(i);
                    }
                }
            }

            if (roundTimeLeft > 15)
            {
                firstPlacePlayer = MainGame.dm.Players.OrderByDescending(x => x.gold).ThenBy(x => (int)x.UID).ToList()[0];
                resetMatch       = false;
            }

            if (Input.isKeyDown(Keyboard.Key.F1))
            {
                player.gold     = 10000;
                player.MaxJumps = 10000000;
                player.Health   = 1000000;
            }

            if (Input.isKeyOverride(Keyboard.Key.F12))
            {
                devMode          = true;
                player.MaxJumps  = 10000;
                player.JumpsLeft = 10000;
            }

            if (tunnelsTimer > 0)
            {
                if (shittyTimerDontUse % (60 * 2) == 0)
                {
                    if (!tunnel)
                    {
                        MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("TrainWhistle.wav"), 1, 0, 8));
                    }
                    //if (Input.isKeyTap(Keyboard.Key.C))
                    //{
                    tunnelsTimer--;
                    CliffFace c = new CliffFace();
                    BackgroundGameObjects.Add(c);
                }
            }
            //if (Input.isKeyTap(Keyboard.Key.C))
            //{
            //    tunnelsTimer = 5;
            //}

            if (Input.isKeyTap(Keyboard.Key.T))
            {
                MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("fart.wav"), 0, 1));
            }

            tunnel = false;

            Mailman.HandleMessages();
            Players.ForEach(p => { p.Update(); });
            Projectiles.ForEach(p => { p.Update(); });
            GameObjects.ForEach(p => { p.Update(); });
            BackgroundGameObjects.ForEach(p => { p.Update(); });
            CheckProjectileCollisions();
            ApplyShake();

            if (MainGame.rand.Next(4) == 0)
            {
                for (int i = 0; i < 5; i++)
                {
                    GameObjects.Add(new TrainDust(new Vector2f(60 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90));
                    GameObjects.Add(new TrainDust(new Vector2f(304 + (i * 440) + MainGame.rand.Next(70), 215), (float)MainGame.rand.NextDouble() * 90));
                }
            }
            TrainDust td = new TrainDust(new Vector2f(2190 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 2);

            GameObjects.Add(td);
            GameObjects.Add(new TrainDust(new Vector2f(1978 + MainGame.rand.Next(10), 75), (float)MainGame.rand.NextDouble() * 90, 1));

            if (Input.isKeyTap(Keyboard.Key.LShift) && !player.Alive)
            {
                if (player.respawnTimer <= 0)
                {
                    //Players.Remove(player);
                    //player = new ClientPlayer(this);
                    //Players.Add(player);
                    player.deathTimer   = 0;
                    player.respawnTimer = player.respawnLength * 60;
                    player.Pos          = new Vector2f(42 + MainGame.rand.Next(1000), 142);
                    player.Health       = 100;
                    player.Alive        = true;
                }
                //player.Pos = new Vector2f(MainGame.rand.Next(42,1800), 142);
                //Mailman.SendRespawn(player.UID);
            }

            if (Input.isKeyDown(Keyboard.Key.P))
            {
                Console.WriteLine(player.Pos);
            }

            if (Input.isKeyDown(Keyboard.Key.R))
            {
                MainGame.Camera.Center += new Vector2f(MainGame.rand.Next(-4, 5) * shakeFactor / 5, MainGame.rand.Next(-4, 5) * shakeFactor / 5);
            }
            trainSound.Update();
            Gui.Update();
        }