Пример #1
0
        public override bool use(Player player)
        {
            if (!base.use(player))
            {
                return(false);
            }
            if (reloadTimer.isActive() ||
                (fireMode == FireMode.SemiAuto && Options.Config.Bindings[GameAction.UseHands].IsControlHeld(Engine.getDeviceState(), Engine.getPrevDeviceState())))
            {
                return(false);
            }
            if (ammo <= 0)
            {
                Resources.Dryfire.Play(Options.Config.SoundVolume, 0f, 0f);
                return(true);
            }
            ammo--;
            muzzleFlashTimer.Start();
            AccuracyAngle angle = GameMain.mainPlayer.getAimAccuracyAngle(true);

            angle.EnforceComparison();
            float   bulletAngle    = (float)(_randomGenerator.Next((int)(angle.right * 1000000f), (int)(angle.left * 1000000f)) / 1000000f);
            Vector2 bulletPos      = player.position + player.getDirectionVector(Direction.Forward, 15);
            float   bulletVelocity = 400f;

            sounds["use"].Play(Options.Config.SoundVolume, 0f, 0f);
            GameMain.projectiles.Add(new Projectile(player.uid, bulletPos, bulletAngle, bulletVelocity, damage));
            ClientSenderV2.SendProjectile(new ProjectileData(player.uid, bulletPos, bulletAngle, bulletVelocity, damage));
            return(true);
        }
Пример #2
0
 public void dropItem(int uid)
 {
     if (hands.id != "hands") //drop
     {
         ClientSenderV2.SendItemPickup(new ItemData(hands.uid, hands.position));
         hands.position = GameMain.map.WorldToGrid(_position);
         hands.drop();
         GameMain.map.items.Add(hands);
         hands = new MeleeWeapon();
         hands.Copy(EntityStore.MeleeWeapons.First((it) => { return(it.id == "hands"); }));
         hands.Init();
         GameMain.hud.initHands(hands);
     }
 }
Пример #3
0
 public void interact()
 {
     if (hands.id == "hands") //Pickup
     {
         Point gridPos = GameMain.map.WorldToGrid(_position);
         var   item    = GameMain.map.items.FirstOrDefault((it) => { return(it.position == gridPos); });
         if (item != null)
         {
             GameMain.map.items.Remove(item);
             item.position = null;
             ClientSenderV2.SendItemPickup(new ItemData(item.uid, item.position));
             hands = item;
             GameMain.hud.initHands(hands);
         }
     }
 }
Пример #4
0
        public override bool use(Player player)
        {
            if (!base.use(player))
            {
                return(false);
            }
            if (Options.Config.Bindings[GameAction.UseHands].IsControlHeld(Engine.getDeviceState(), Engine.getPrevDeviceState()))
            {
                return(false);
            }
            sounds["use"].Play(Options.Config.SoundVolume, 0f, 0f);
            attackEffectTimer.Start();
            Vector2 hitPos = player.position + player.getDirectionVector(Direction.Forward, 15);

            ClientSenderV2.SendMeleeHit(new MeleeHitData(player.uid, hitPos, damage));
            return(true);
        }
Пример #5
0
        public static VerticalStackPanel DeathPanel()
        {
            VerticalStackPanel mainPanel = new VerticalStackPanel();

            mainPanel.VerticalAlignment   = VerticalAlignment.Center;
            mainPanel.HorizontalAlignment = HorizontalAlignment.Center;
            mainPanel.Background          = new TextureRegion(Resources.MenuBackground);

            Label deathLabel = new Label();

            deathLabel.Text = "You are dead";
            mainPanel.Widgets.Add(deathLabel);

            TextButton respawnBtn = new TextButton();

            respawnBtn.Text   = "Respawn";
            respawnBtn.Click += (s, a) => { ClientSenderV2.SendSpawnRequest(); };
            mainPanel.Widgets.Add(respawnBtn);

            return(mainPanel);
        }
Пример #6
0
 public void UpdateNetwork()
 {
     ClientSenderV2.SendPlayerData(new PlayerData(_uid, _position, _orientation));
 }