void Start() { // if (startingGun != null) { // EquipGun(startingGun); // } equippedGun = GetComponentInChildren <Machinegun>(); }
public override void OnInspectorGUI() { if (script == null) { script = (Machinegun)target; } base.OnInspectorGUI(); float dmg = script.damage; float rpm = script.fireRate; float dps = (dmg * rpm) / 60f; float ttk = 100f / dps; EditorGUILayout.Space(); GUILayout.Label("Base stats:"); GUILayout.Label( $"DMG = {dmg:0.00}\n" + $"RPM = {rpm:0.00}\n" + $"DPS = {dps:0.00}\n" + $"TTK = {ttk:0.00}" ); dmg = script.lvld_damage; rpm = script.lvld_fireRate; dps = (dmg * rpm) / 60f; ttk = 100f / dps; GUILayout.Label("Leveled stats:"); GUILayout.Label( $"DMG = {dmg:0.00}\n" + $"RPM = {rpm:0.00}\n" + $"DPS = {dps:0.00}\n" + $"TTK = {ttk:0.00}" ); }
public void Init(Player player, PlayerStats playerStats, Handgun handgun, Shotgun shotgun, Machinegun machinegun, ControlsController controls, SignalBus bus) { _player = player; _playerStats = playerStats; _handgun = handgun; _shotgun = shotgun; _machinegun = machinegun; _controls = controls; _bus = bus; }
public void BuildTurret(int x, int y) { Machinegun g = new Machinegun(x, y); if (g.Cost > ScoreBoard.gold) { Destroy(g.Turret); return; } ScoreBoard.gold -= g.Cost; }
public WeaponController(WeaponInventory inventory, Handgun handgun, Shotgun shotgun, Machinegun machinegun, SignalBus bus, PlayerStatsController playerStatsController) { _bus = bus; Handgun = handgun; Shotgun = shotgun; Machinegun = machinegun; Inventory = inventory; CurrentGun = Handgun; _playerStatsController = playerStatsController; InitialAmmoSurvivalMode(); }
private void Awake() { _car = GetComponent <Car>(); _input = new WeaponInput(); _input.FireOn += FireOn; _input.FireOff += FireOff; _input.SwitchWeapon += SwitchWeapon; _input.Init(); _weapon = new BaseWeapon[_car.WeaponMounts.Length]; for (int i = 0; i < _car.WeaponMounts.Length; i++) { _weapon[i] = new Machinegun(); _weapon[i].SetOrigin(transform, _car.WeaponMounts[i]); } }
public Hero(AbstractScene scene, Vector2 position) : base(scene.LayerManager.EntityLayer, null, position) { //DEBUG_SHOW_PIVOT = true; AddTag("Hero"); AddCollisionAgainst("Enemy"); AddCollisionAgainst("Spikes"); AddCollisionAgainst("Trap"); CanFireTriggers = true; DrawPriority = 10; AddCollisionAgainst("Pickup"); AddCollisionAgainst("Door", false); AddCollisionAgainst("Key"); AddCollisionAgainst("MountedGunBullet"); SetupController(); CollisionOffsetBottom = 1; CollisionOffsetLeft = 0.5f; CollisionOffsetRight = 0.5f; CollisionOffsetTop = 1; CurrentFaceDirection = Direction.EAST; collisionComponent = new BoxCollisionComponent(this, 18, 30, new Vector2(-8, -30)); AddComponent(collisionComponent); //DEBUG_SHOW_COLLIDER = true; AnimationStateMachine animations = new AnimationStateMachine(); animations.Offset = offset; AddComponent(animations); SpriteSheetAnimation idleLeft = new SpriteSheetAnimation(this, Assets.GetTexture("HeroIdle"), 24); /*idleLeft.AnimationSwitchCallback = () => { if (CurrentWeapon != null) CurrentWeapon.SetAnimationBreathingOffset(Vector2.Zero); }; * idleLeft.EveryFrameAction = (frame) => * { * if (CurrentWeapon == null) return; * float unit = 0.5f; * float offsetY = 0; * if (frame == 2 || frame == 3 || frame == 4) * { * offsetY += unit; * } * else if (frame == 6 || frame == 7) * { * offsetY -= unit; * } * CurrentWeapon.SetAnimationBreathingOffset(new Vector2(0, offsetY)); * };*/ idleLeft.StartedCallback = () => { if (CurrentWeapon == null) { return; } if (CurrentWeapon is Shotgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Machinegun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Handgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } }; animations.RegisterAnimation("IdleLeft", idleLeft, () => previousPosition == Transform.Position && CurrentFaceDirection == Direction.WEST); SpriteSheetAnimation idleRight = idleLeft.CopyFlipped(); animations.RegisterAnimation("IdleRight", idleRight, () => previousPosition == Transform.Position && CurrentFaceDirection == Direction.EAST); SpriteSheetAnimation runLeft = new SpriteSheetAnimation(this, Assets.GetTexture("HeroRun"), 40); runLeft.StartedCallback = () => { if (CurrentWeapon == null) { return; } if (CurrentWeapon is Shotgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Machinegun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Handgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(1, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(-1, -17)); } }; animations.RegisterAnimation("RunLeft", runLeft, () => Velocity.X < 0 && CurrentFaceDirection == Direction.WEST); SpriteSheetAnimation runRight = runLeft.CopyFlipped(); animations.RegisterAnimation("RunRight", runRight, () => Velocity.X > 0 && CurrentFaceDirection == Direction.EAST); SpriteSheetAnimation runBackwardsLeft = new SpriteSheetAnimation(this, Assets.GetTexture("HeroRunBackwards"), 40); runBackwardsLeft.StartedCallback = () => { if (CurrentWeapon == null) { return; } if (CurrentWeapon is Shotgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Machinegun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Handgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(1, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(-1, -17)); } }; animations.RegisterAnimation("RunBackwardsLeft", runBackwardsLeft, () => Velocity.X > 0 && CurrentFaceDirection == Direction.WEST); SpriteSheetAnimation runRighrunBackwardsRight = runBackwardsLeft.CopyFlipped(); animations.RegisterAnimation("RunBackwardsRight", runRighrunBackwardsRight, () => Velocity.X < 0 && CurrentFaceDirection == Direction.EAST); SpriteSheetAnimation jumpLeft = new SpriteSheetAnimation(this, Assets.GetTexture("HeroRun"), 1); jumpLeft.StartFrame = 6; jumpLeft.EndFrame = 7; animations.RegisterAnimation("JumpLeft", jumpLeft, () => !IsOnGround && CurrentFaceDirection == Direction.WEST, 1); SpriteSheetAnimation jumpRight = jumpLeft.CopyFlipped(); animations.RegisterAnimation("JumpRight", jumpRight, () => !IsOnGround && CurrentFaceDirection == Direction.EAST, 1); SpriteSheetAnimation jetpackLeft = new SpriteSheetAnimation(this, Assets.GetTexture("Jetpacking"), 40); animations.RegisterAnimation("JetpackLeft", jetpackLeft, () => flying && CurrentFaceDirection == Direction.WEST, 2); SpriteSheetAnimation jetpackRight = jetpackLeft.CopyFlipped(); animations.RegisterAnimation("JetpackRight", jetpackRight, () => flying && CurrentFaceDirection == Direction.EAST, 2); SpriteSheetAnimation kickLeft = new SpriteSheetAnimation(this, Assets.GetTexture("Kick"), 40); kickLeft.Looping = false; kickLeft.AddFrameAction(5, (frame) => { AudioEngine.Play("Kick"); IsKicking = true; if (THIS_IS_SPARTAAAAA && collidingWith.Count > 0) { THIS_IS_SPARTAAAAA = false; Vector2 canSpawnPos = collidingWith[0].Transform.Position; FuelCan can = new FuelCan(scene, canSpawnPos + new Vector2(0, -20), TankCapacity); can.Velocity += new Vector2(-3, -1); can.CollisionsEnabled = false; Ammo ammo = new Ammo(scene, canSpawnPos + new Vector2(0, -20), 20, typeof(Handgun)); ammo.Velocity += new Vector2(-4f, -1.5f); ammo.CollisionsEnabled = false; Timer.TriggerAfter(2000, () => { can.CollisionsEnabled = true; ammo.CollisionsEnabled = true; new TextPopup(Scene, Assets.GetTexture("FuelAmmoText"), Transform.Position + new Vector2(-20, -80), 0.3f, 3000); }); } }); kickLeft.AddFrameAction(6, (frame) => { IsKicking = false; }); kickLeft.StartedCallback = () => { if (THIS_IS_SPARTAAAAA && collidingWith.Count > 0) { THIS_IS_SPARTA(); Globals.FixedUpdateMultiplier = 0.1f; Timer.TriggerAfter(3000, () => { Globals.FixedUpdateMultiplier = 0.5f; Timer.Repeat(1000, (elapsedTime) => { Scene.Camera.Zoom -= 0.002f * elapsedTime; }); }); } //IsKicking = true; if (IsOnGround) { MovementSpeed = 0; } if (CurrentWeapon == null) { return; } if (CurrentWeapon is Shotgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Machinegun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Handgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(1, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(-1, -17)); } }; kickLeft.AnimationSwitchCallback = () => { IsKicking = false; MovementSpeed = Config.CHARACTER_SPEED; foreach (AbstractEnemy enemy in collidingWith) { enemy.IsKicked = false; } }; animations.RegisterAnimation("KickLeft", kickLeft, () => false); SpriteSheetAnimation kickRight = kickLeft.CopyFlipped(); animations.RegisterAnimation("KickRight", kickRight, () => false); SpriteSheetAnimation kickJetpackLeft = new SpriteSheetAnimation(this, Assets.GetTexture("KickJetpacking"), 40); kickJetpackLeft.Looping = false; kickJetpackLeft.AddFrameAction(5, (frame) => { AudioEngine.Play("Kick"); IsKicking = true; }); kickJetpackLeft.AddFrameAction(6, (frame) => { IsKicking = false; }); kickJetpackLeft.StartedCallback = () => { //IsKicking = true; if (CurrentWeapon == null) { return; } if (CurrentWeapon is Shotgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Machinegun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(-3, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(3, -17)); } else if (CurrentWeapon is Handgun) { (CurrentWeapon as Handgun).SetLeftFacingOffset(new Vector2(1, -17)); (CurrentWeapon as Handgun).SetRightFacingOffset(new Vector2(-1, -17)); } }; kickJetpackLeft.AnimationSwitchCallback = () => { IsKicking = false; }; animations.RegisterAnimation("KickJetpackLeft", kickJetpackLeft, () => false); SpriteSheetAnimation kickJetpackRight = kickJetpackLeft.CopyFlipped(); animations.RegisterAnimation("KickJetpackRight", kickJetpackRight, () => false); animations.AddFrameTransition("RunLeft", "RunBackwardsLeft"); animations.AddFrameTransition("RunRight", "RunBackwardsRight"); animations.AddFrameTransition("RunLeft", "RunRight"); animations.AddFrameTransition("RunBackwardsLeft", "RunBackwardsRight"); animations.AddFrameTransition("JetpackLeft", "JetpackRight"); Visible = true; Active = true; /*DebugFunction = () => * { * return "Fuel: " + (int)(((float)(Fuel / TankCapacity)) * 100) + " %"; * };*/ CurrentWeapon = new Handgun(scene, this); weapons.Add(CurrentWeapon); Machinegun mg = new Machinegun(scene, this); mg.Visible = false; Shotgun sg = new Shotgun(scene, this); sg.Visible = false; weapons.Add(mg); weapons.Add(sg); }
public override void AssignWeapon(Weapon weap) { weapon = (Machinegun)weap; }
/// <summary> /// The function takes List Arsenal and fills it with the guns what purchased with the money. /// </summary> /// <param name="arsenal"></param> /// <param name="money"></param> /// <returns></returns> static public List <Gun> BuyGuns(List <Gun> arsenal, int money) { int number; Drawer.GreenConsole(Environment.NewLine + "Теперь пришло время купить немного ПУШЕК!" + Environment.NewLine); Drawer.WhiteConsole("Вот тебе краткий список, введи номер оружия для приобретения:" + Environment.NewLine + "1) Пистолет - 10 монет." + Environment.NewLine + "2) Автоматическая винтовка - 15 монет." + Environment.NewLine + "3) Пулемет - 20 монет." + Environment.NewLine); while (money >= 10) { Console.WriteLine(Environment.NewLine + $"На данный момент у тебя {money} монет, продолжай покупки! (^_~)"); number = ReadInt("Введите номер оружия в пределах 1 и 3: ", 1, 3); switch (number) { case 1: money -= 10; Pistol pistol = new Pistol(random.Next(10, 16), random.Next(5, 9)); Drawer.GreenConsole($"Поздравляю, ты купил пистолет с {pistol.Patrons} патронами в обойме" + $" и дамагом {pistol.Damage}"); arsenal.Add(pistol); patronsSum += pistol.Patrons; break; case 2: if (money >= 15) { money -= 15; AutomaticWeapon automaticGun = new AutomaticWeapon(random.Next(13, 19), random.Next(9, 15), random.NextDouble() * 0.3 + 0.3); Drawer.GreenConsole($"Поздравляю, ты купил винтовку с {automaticGun.Patrons} патронами в обойме" + $" и дамагом {automaticGun.Damage}. Твой шанс промазать с ней равен {automaticGun.Coef:F3}, везунчик!"); arsenal.Add(automaticGun); patronsSum += automaticGun.Patrons; break; } else { Drawer.RedConsole("Тебе катастрофично не хватает монет на это!"); break; } case 3: if (money >= 20) { money -= 20; Machinegun machinegun = new Machinegun(random.Next(10, 26), random.Next(8, 17), random.NextDouble() * 0.1 + 0.3, random.Next(2, 5), random.NextDouble() * 0.2 + 0.1); Drawer.GreenConsole($"Поздравляю, ты купил пулемёт с {machinegun.Patrons} патронами в обойме" + $" и дамагом {machinegun.Damage}. Твой шанс промазать с ним равен {machinegun.Coef:F3}, везунчик!"); arsenal.Add(machinegun); patronsSum += machinegun.Patrons; break; } else { Drawer.RedConsole(Environment.NewLine + "Тебе катастрофично не хватает монет на это!"); break; } default: Drawer.RedConsole("Попробуйте ввести другие данные!"); break; } } Drawer.YellowConsole(Environment.NewLine + "\t\t\t\t <<АРСЕНАЛ ВАШЕГО ОРУЖИЯ БЫЛ УСПЕШНО СОЗДАН>>" + Environment.NewLine); return(arsenal); }