public ActionResult NewWeaponLot(NewWeaponLotModel model) { if (ModelState.IsValid) { using (var db = new BGS_DBContext()) { string userIdentityId = User.Identity.GetUserId(); var seller = db.Users.Single(u => u.Id == userIdentityId); for (int i = 0; i < model.LotCount; i++) { WeaponModel newWeaponModelModel = GameUtilCreater.WeaponModelFromModel(model); db.WeaponModels.Add(newWeaponModelModel); db.SaveChanges(); var lot = new LotModel() { Seller = seller, ItemId = newWeaponModelModel.Id, Price = model.Price, SellerId = seller.GameId, Status = LotStatus.Available, Type = LotType.Weapon }; db.LotModels.Add(lot); db.SaveChanges(); newWeaponModelModel.LotId = lot.Id; } db.SaveChanges(); return(RedirectToAction("Index", "Market")); } } ModelState.AddModelError("", "Что то не правильно"); return(View(model)); }
public void Capacity_SetInvalidValue_OldValue() { var testWM = new WeaponModel(); testWM.Capacity = -1; Assert.AreEqual(0, testWM.Capacity); }
public void OnSelectButtonClick(WeaponModel CurrentWeapon, GameObject CurrentItemHolder, int Index) { if (LastItemInList != null) { if (PlayerPrefs.GetString("Language", "EN").Equals("EN")) { LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = SelectButton.ImageInEnglish; } else { LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = SelectButton.ImageInArabic; } LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Button>().interactable = true; } LastItemInList = CurrentItemHolder; if (PlayerPrefs.GetString("Language", "EN").Equals("EN")) { LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = SelectedButton.ImageInEnglish; } else { LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = SelectedButton.ImageInArabic; } LastItemInList.transform.GetChild(0).GetChild(1).GetComponent <Button>().interactable = false; PlayerVariables.Inistance.setCurrentWeapon(CurrentWeapon); PlayerVariables.Inistance.setWeaponIndex(Index.ToString()); //save to playfab as selected }
private void ActivateWeaponModel(AiController controller) //event being fired twice issue { if (_activeModelReference != null) { StartCoroutine(Coroutine_ToggleWeaponModel(_activeCombatEquipmentSlot.modelReference, false, _shortWait)); _activeModelReference = null; } switch (controller.combatController.combatMode) { case Ai_CombatController.CombatMode.Melee: _activeCombatEquipmentSlot = controller.equipment.GetEquipmentSlot(EquipmentSlot.EquipmentType.MeleeWep); break; case Ai_CombatController.CombatMode.Ranged: _activeCombatEquipmentSlot = controller.equipment.GetEquipmentSlot(EquipmentSlot.EquipmentType.RangedWep); break; } if (_activeCombatEquipmentSlot.modelReference != null && controller.stateController.Drafted && _activeModelReference == null) { StartCoroutine(Coroutine_ToggleWeaponModel(_activeCombatEquipmentSlot.modelReference, true, _shortWait)); _activeModelReference = _activeCombatEquipmentSlot.modelReference; } activeWeapon = GetActiveWeapon(controller); }
private void OnWeaponSet(WeaponModel weapon) { if (CurrentWeapon != null) { CurrentWeapon.Release(); } }
private EnemyModel initEnemy(EnemyModel enemy) { EnemyModel newEnemy = Instantiate(enemy); for (int i = 0; i < enemy.weaponModels.Length; i++) { WeaponModel newWeaponModel = Instantiate(enemy.weaponModels[i]); if (newWeaponModel.GetType().Equals(typeof(MeleeWeaponModel))) { newWeaponModel.attackDemage = randomValue(1, 10); } else { newWeaponModel.attackDemage = randomValue(2, 20); } newEnemy.weaponModels[i] = newWeaponModel; } newEnemy.runningSpeed = randomValue(2, 15); newEnemy.walkSpeed = randomValue(2, (int)newEnemy.runningSpeed); newEnemy.energy = randomValue(10, 30); newEnemy.health = randomValue(2, 8); return(newEnemy); }
public async Task WeaponDamageEvent(ClassicPlayer player, ClassicPlayer target, uint weapon, ushort dmg, Position offset, BodyPart bodypart) { try { if (player == null || !player.Exists || target == null || !target.Exists) { return; } WeaponModel weaponModel = (WeaponModel)weapon; if (weaponModel == WeaponModel.Fist) { return; } if (Enum.IsDefined(typeof(AntiCheat.forbiddenWeapons), (Utils.AntiCheat.forbiddenWeapons)weaponModel)) { User.SetPlayerBanned(player, true, $"Waffen Hack[2]: {weaponModel}"); player.Kick(""); foreach (IPlayer p in Alt.Server.GetPlayers().ToList().Where(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && x.AdminLevel() > 0)) { p.SendChatMessage($"{Characters.GetCharacterName(player.CharacterId)} wurde gebannt: Waffenhack[2] - {weaponModel}"); } return; } } catch (Exception e) { Alt.Log($"{e}"); } }
private void Start() { m_weaponModel = GetComponent <WeaponModel>(); m_weaponModel.OnUpgradeWeapon += OnUpgradeWeapon; m_weaponModel.OnWeaponChanged += OnWeaponChanged; }
public static void SetWeapon(int weaponIndex) { switch (weaponIndex) { case 1: if (canEquip(WeaponCollection.GUN)) { ActiveWeapon = WeaponCollection.GUN; } break; case 2: if (canEquip(WeaponCollection.SHOTGUN)) { ActiveWeapon = WeaponCollection.SHOTGUN; } break; case 3: if (canEquip(WeaponCollection.GATLING)) { ActiveWeapon = WeaponCollection.GATLING; } break; case 4: if (canEquip(WeaponCollection.ROCKET_LAUNCHER)) { ActiveWeapon = WeaponCollection.ROCKET_LAUNCHER; } break; } }
private void CreateBullet(GameObject bullet, WeaponModel weapon) { Quaternion rotation = transform.rotation; GameObject fireBullet = (GameObject)Instantiate(bullet, transform.position, Quaternion.identity, BulletContainer.transform); rotation.z += Random.Range(-weapon.Accuracy / 2, weapon.Accuracy / 2); fireBullet.tag = tag; fireBullet.transform.rotation = rotation; if (weapon.Type == WeaponCollection.WeaponTypes.CQC) { fireBullet.GetComponent <global::fireKnife>().Weapon = weapon; } if (weapon.Type == WeaponCollection.WeaponTypes.BULLET) { fireBullet.GetComponent <global::fireBulletSimple>().Weapon = weapon; } if (weapon.Type == WeaponCollection.WeaponTypes.ROCKET) { fireBullet.GetComponent <global::fireRocket>().Weapon = weapon; } }
public void SelectWeapon(Button button) { var buttonType = button.GetComponent<WeaponButton>().WeaponType; var model = _weaponModels.First(w => w.Type == buttonType); if (_playerNetwork.GetUserModel().Money < model.Cost) { Debug.Log("Not Enough Cash!"); return; } // Update actual weapon and money values if (_currentWeapon.Type == model.Type) { _weapon.UpdateAmmo(_currentWeapon.Ammo); } else { _currentWeapon = model; _weapon.UpdateWeapon(_currentWeapon.Ammo, _currentWeapon.Damage, _currentWeapon.FireRate); } // Update user model _teamsController.UpdateUserModelForAll(_playerNetwork.GetUserModel().Uid, UserModelField.MoneyIncrement, _currentWeapon.Cost * -1); _teamsController.UpdateUserModelForAll(ServerData.serverInfo.userData.UID, UserModelField.Weapon, (int) buttonType); //Update UI UpdateWeaponUi(); PlayerCurrentWeapon.GetComponentsInChildren<Image>().First(x => x.name == "Image").sprite = _currentWeapon.Sprite; PlayerCurrentWeapon.GetComponentsInChildren<Text>().First(x => x.name == "Name").text = _currentWeapon.Name; PlayerCurrentWeapon.GetComponentsInChildren<Text>().First(x => x.name == "Ammo").text = _weapon.GetAmmo().ToString(); _hudController.AmmoText.text = _weapon.GetAmmo().ToString(); }
public void OnSelectSecondWpeaon(int id, ulong unLockLevel) { if (PlayerController.GetInstance.PlayerData.Level < unLockLevel) { MessageManager.GetInstance.Dispatch <string>(MessageDefine.OpenWarning, unLockLevel + "级解锁"); return; } if (!addPanel.activeSelf) { addPanel.SetActive(true); } if (PlayerController.GetInstance.PlayerData.SecondWeapons == null) { PlayerController.GetInstance.PlayerData.CurrentUsedSecondWeapon = id; PlayerController.GetInstance.PlayerData.SecondWeapons = new Dictionary <int, WeaponModel>(); currentWeaponModel = PlayerController.GetInstance.AllSecondWeapons[id]; PlayerController.GetInstance.PlayerData.SecondWeapons.Add(id, currentWeaponModel); UpdateDate(currentWeaponModel); AddListener(currentWeaponModel); return; } if (!PlayerController.GetInstance.PlayerData.SecondWeapons.ContainsKey(id)) { PlayerController.GetInstance.PlayerData.SecondWeapons.Add(id, PlayerController.GetInstance.AllSecondWeapons[id]); } if (PlayerController.GetInstance.PlayerData.CurrentUsedSecondWeapon == id) { return; } RemoveListener(currentWeaponModel); PlayerController.GetInstance.PlayerData.CurrentUsedSecondWeapon = id; currentWeaponModel = PlayerController.GetInstance.AllSecondWeapons[id]; UpdateDate(currentWeaponModel); AddListener(currentWeaponModel); }
public static IList <WeaponModel> GetAllWeapons() { string content; using (HttpClient client = new HttpClient()) { content = client.GetStringAsync(baseURL + "/api/equipment-categories/weapon").Result; } JObject allWeapons = JObject.Parse(content); IList <JToken> weapons = allWeapons["equipment"].Children().ToList(); IList <WeaponModel> weaponList = new List <WeaponModel>(); foreach (JToken weapon in weapons) { WeaponModel weaponModel = weapon.ToObject <WeaponModel>(); using (HttpClient client = new HttpClient()) { weaponModel = JsonConvert.DeserializeObject <WeaponModel>(client.GetStringAsync(baseURL + weaponModel.URL).Result); } weaponList.Add(weaponModel); } return(weaponList); }
public void Damage_SetInvalidValue_OldValue() { var testWM = new WeaponModel(); testWM.Damage = -1; Assert.AreEqual(0, testWM.Damage); }
internal OnWeaponFireEventArgs(dynamic weapon, dynamic ex, dynamic ey, dynamic ez, MtaElement hitElement, dynamic sx, dynamic sy, dynamic sz) { Weapon = new WeaponModel((int)weapon); HitElement = ElementManager.Instance.GetElement <PhysicalElement>(hitElement); EndPosition = new Vector3((float)ex, (float)ey, (float)ez); StartPosition = new Vector3((float)sx, (float)sy, (float)sz); }
public void Accuracy_SetValidValue_NewValue() { var testWM = new WeaponModel(); testWM.Accuracy = .5f; Assert.AreEqual(.5f, testWM.Accuracy); }
public void Accuracy_SetInvalidSmallValue_OldValue() { var testWM = new WeaponModel(); testWM.Accuracy = -.2f; Assert.AreEqual(0, testWM.Accuracy); }
public void ID_SetWhenNull_NewValue() { var testWM = new WeaponModel(); testWM.ID = "test"; Assert.AreEqual("test", testWM.ID); }
void FireKnife(WeaponModel weapon) { if (!Controller.FIRE && Controller.ALT_FIRE) { fireBullet.Fire(weapon); } }
void OnBgBtnClick() { if (groups.AnyTogglesOn()) { groups.SetAllTogglesOff(); if (currentWeaponModel != null) { RemoveListener(currentWeaponModel); } currentWeaponModel = null; currentClickToggle = -1; PlayerController.GetInstance.CurrentPlayer.Machine.TranslateState(PlayerState.Idle); } else { if (PlayerController.GetInstance.CurrentPlayer.Machine.GetCurrentState() == PlayerState.Ready) { GameController.GetInstance.EnterBattle(); } else if (PlayerController.GetInstance.CurrentPlayer.Machine.GetCurrentState() == PlayerState.Idle) { PlayerController.GetInstance.CurrentPlayer.Machine.TranslateState(PlayerState.Ready); } } }
public static void mountItemForInventory(EquipedModel equiped, string slot_name, string item_data) { object equipment; int inv_idx = String_functions.getFirstNumberFromString(slot_name); string item_type = item_data.Split(',')[0]; switch (item_type) { case "Weapon": equipment = new WeaponModel(item_data); break; case "Food": equipment = new FoodModel(item_data); break; case "Potions": equipment = new PotionModel(item_data); break; case "Runes": equipment = new ItemModel(item_data); break; default: equipment = new EquipmentModel(item_type, item_data); break; } equiped.InventoryItem[inv_idx] = equipment; }
void UpdateDate(WeaponModel model) { if (model == null) { return; } property1Txt.text = string.Format("{0}(Lv{1}) {2}", model.Properties[0].RopertyName, model.Properties[0].Level, Util.ToString(model.Properties[0].PropertyValue())); property2Txt.text = string.Format("{0}(Lv{1}) {2}", model.Properties[1].RopertyName, model.Properties[1].Level, Util.ToString(model.Properties[1].PropertyValue())); addLevelCoin1.text = Util.ToString(model.Properties[0].NextLevelUpdateCoin()); addLevelCoin2.text = Util.ToString(model.Properties[1].NextLevelUpdateCoin()); if (model.Properties[0].NextLevelUpdateCoin() > PlayerController.GetInstance.PlayerData.Coin) { addLevel1.interactable = false; addLevelCoin1.color = Color.red; } else { addLevel1.interactable = true; addLevelCoin1.color = Color.black; } if (model.Properties[1].NextLevelUpdateCoin() > PlayerController.GetInstance.PlayerData.Coin) { addLevel2.interactable = false; addLevelCoin2.color = Color.red; } else { addLevel2.interactable = true; addLevelCoin2.color = Color.black; } }
public async void ShowWeaponDetail(WeaponModel weaponModel) { await DispatcherHelper.RunAsync(() => { try { //HideRetry(); WeaponDetailUIControl wduc = new WeaponDetailUIControl(); wduc.weaponModel = weaponModel; if (popup == null) { popup = new Popup(); } if (!popup.IsOpen) { popup.Child = wduc; popup.IsLightDismissEnabled = false; //应当占据NavigationRootPage的rootFrame区域,此区域距离左和上的距离都为48,在加上Pivot的Header头高度为45(已取消) //popup.VerticalOffset = 48; //if (!AppEnvironment.IsPhone) //{ // popup.HorizontalOffset = 48; //} popup.IsOpen = true; } } catch { } }); }
public void Shoot(WeaponModel weapon) { view.ShowMessage("Наношу урон: " + weapon.damage); enemy.OnTakeStrike(weapon.damage); view.ShowMessage("Перезарядка: " + weapon.reloadTime * model.WeaponsReloadKoeff); weapon.reloadTimeLeft += weapon.reloadTime * model.WeaponsReloadKoeff; }
public async Task OnPlayerDeath(ClassicPlayer player, IEntity killer, uint weapon) { try { if (player == null || !player.Exists) { return; } int charId = (int)player.GetCharacterMetaId(); if (charId <= 0) { return; } if (Characters.IsCharacterUnconscious(charId)) { return; } if (Characters.IsCharacterInJail(charId)) { player.Spawn(new Position(1691.4594f, 2565.7056f, 45.556763f), 0); player.Position = new Position(1691.4594f, 2565.7056f, 45.556763f); return; } openDeathscreen(player); Characters.SetCharacterUnconscious(charId, true, 10); // Von 15 auf 10 geändert. ServerFactions.createFactionDispatch(player, 3, $"HandyNotruf", $"Eine Verletzte Person wurde gemeldet"); ClassicPlayer killerPlayer = (ClassicPlayer)killer; if (killerPlayer == null || !killerPlayer.Exists) { return; } WeaponModel weaponModel = (WeaponModel)weapon; if (weaponModel == WeaponModel.Fist) { return; } foreach (IPlayer p in Alt.Server.GetPlayers().ToList().Where(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && x.AdminLevel() > 0)) { p.SendChatMessage($"{Characters.GetCharacterName(killerPlayer.CharacterId)} ({killerPlayer.CharacterId}) hat {Characters.GetCharacterName(player.CharacterId)} ({player.CharacterId}) getötet. Waffe: {weaponModel}"); LoggingService.NewDeathLog(player.CharacterId, killerPlayer.CharacterId, weapon); } if (Enum.IsDefined(typeof(AntiCheat.forbiddenWeapons), (Utils.AntiCheat.forbiddenWeapons)weaponModel)) { User.SetPlayerBanned(killerPlayer, true, $"Waffen Hack[2]: {weaponModel}"); killerPlayer.Kick(""); player.Health = 200; foreach (IPlayer p in Alt.Server.GetPlayers().ToList().Where(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && x.AdminLevel() > 0)) { p.SendChatMessage($"{Characters.GetCharacterName(killerPlayer.CharacterId)} wurde gebannt: Waffenhack[2] - {weaponModel}"); } return; } } catch (Exception e) { Alt.Log($"{e}"); } }
/// <summary> /// Method for player to have an ability to change weapon during gameplay. Actually not only for player, but bots somehow dont change their weapons (too dumb) /// </summary> public void ChangeWeapon(WeaponModel _weapon) { StopAllCoroutines(); weapon = _weapon; shotDelay = weapon.cooldown; StartCoroutine(CooldownCoroutine(0.5f)); }
public void Fire() { GameObject weapon = Instantiate(weaponObject, spawnTransform.position, spawnTransform.rotation); WeaponModel weaponModel = weapon.transform.GetComponent <WeaponModel>(); weaponModel.xVelocity = mainTransform.localScale.x * weaponModel.horizontalVelocity; AudioSource.PlayClipAtPoint(soundEffect, Camera.main.transform.position, 0.5f); }
public static WeaponModel create(WeaponType type) { WeaponModel instance = new WeaponModel(); instance._template = WeaponTemplate.Find(type); instance._durability = instance._template.DurabilityMax(); return(instance); }
public IActionResult ManageWeapon(string id) { model = new WeaponModel(HttpContext.Session.GetString("dbusername"), HttpContext.Session.GetString("dbpassword")); ViewBag.Weapon = model.GetWeapon(id); ViewBag.Dangers = model.GetDangers(); ViewBag.Planets = model.GetPlanets(); return(View()); }
public bool Upsert(WeaponModel weapon) { using (var db = new LiteDatabase(ConnectionHelper.DBFileName)) { var weapons = db.GetCollection <WeaponModel>(weaponDocumentName); return(weapons.Upsert(weapon)); } }
private void FireBullet(WeaponModel weapon) { if (Bullet == null) { return; } CreateBullet(Bullet, weapon); }
protected override void Awake() { base.Awake(); _teamsController = global::TeamsController.Instance; _userController = global::UserController.Instance; _hudController = global::HUDController.Instance; _weaponModels = new List<WeaponModel>(global::WeaponContainer.Instance.WeaponModels); _currentWeapon = _weaponModels.First(w => w.Type == WeaponType.Pistol); ToggleKey = KeyCode.B; ToggleEnabled = true; }
public Weapon(WeaponModel model) { Model = model; }
public void SetClass(bool class_1) { if (this.class_1 == class_1) return; this.class_1 = class_1; if (model != null) { model.owner = null; Destroy(model); } GameObject m = (GameObject)Instantiate( class_1 ? fab_class_1.gameObject : fab_class_2.gameObject); model = m.GetComponent<WeaponModel>(); model.owner = this; model.transform.parent = transform; }
public void HitByWeapon(WeaponModel weaponModel, IArmed other) { //ship is hit not the player //Deactivate(); }
public void WeaponHit(WeaponModel weaponModel, IDamageable other) { //should the interface hold the health or just state (dead/alive) ? - STATE ! //check the order of events Debug.Log(other.RxHealth.Value); if (other.RxHealth.Value <= 0)//if the enemy is dead increase the score { RxPlayerScore.Value += other.RxScore.Value; } }
public Gun(WeaponModel model) : base(model) { }
public Knife(WeaponModel model) : base(model) { }