public void DisplayWeaponLevelInfo(WeaponProperty wp, bool unlocked) { CommonUtils.SetChildSliderValue(weaponInfo, "Infos/Power/Silder", wp.Power / GameGlobalValue.s_MaxWeaponAttack); CommonUtils.SetChildSliderValue(weaponInfo, "Infos/FireRate/Silder", (wp.FireRate) / GameGlobalValue.s_MaxFireRatePerSeconds); CommonUtils.SetChildSliderValue(weaponInfo, "Infos/MagSize/Silder", (float)wp.ClipSize / GameGlobalValue.s_MaxMagazineSize); CommonUtils.SetChildSliderValue(weaponInfo, "Infos/ScoreBouns/Silder", wp.ScoreBonus / GameGlobalValue.s_MaxSocreBonus); if (wp.UpgPrice > 0) { CommonUtils.SetChildActive(weaponInfo, "Background/Upgrade", true); CommonUtils.SetChildActive(weaponInfo, "Background/TextMax", false); CommonUtils.SetChildText(weaponInfo, "Background/Upgrade/UpgPrice", wp.UpgPrice.ToString()); } else { CommonUtils.SetChildActive(weaponInfo, "Background/Upgrade", false); CommonUtils.SetChildActive(weaponInfo, "Background/TextMax", true); CommonUtils.SetChildButtonActive(weaponInfo, "Background", true); } if (wp.UpgPrice > 0 && unlocked) { CommonUtils.SetChildButtonActive(weaponInfo, "Background", true); } else { CommonUtils.SetChildButtonActive(weaponInfo, "Background", false); } }
private void OnEnable() { if (ItemName == null) { ItemName = "null"; } this.ChangeTexture(ItemName, ItemType); switch (ItemType) { case "prop": break; case "weapon": WeaponProperty weaponProperty = new WeaponProperty(); weaponProperty = (WeaponProperty)squareProperty; break; case "slot": break; default: break; } }
private Save CreateSaveGameObject() { Save save = new Save(); foreach (var item in GameManager.Instance.square) { save.squareName.Add(item.itemName); save.squareNumber.Add(item.itemNumber); save.squareType.Add(item.itemType); if (item.itemType == "weapon") { WeaponProperty wp = (WeaponProperty)item; save.bagWeaponMultiple.Add(wp.weaponProperties.Multiple); save.bagWeaponDamageLevel.Add(wp.weaponProperties.DamageLevel); save.bagWeaponTrackBullet.Add(wp.weaponProperties.TrackBullet); save.bagWeaponBulletRange.Add(wp.weaponProperties.BulletRange); save.bagWeaponShoot1.Add(wp.weaponProperties.shoot[0]); save.bagWeaponShoot2.Add(wp.weaponProperties.shoot[1]); save.bagWeaponShoot3.Add(wp.weaponProperties.shoot[2]); } } //当前装备的武器 save.currentWeaponName = GameManager.Instance.currentWeapon.itemName; save.currentWeaponMultiple = GameManager.Instance.currentWeapon.weaponProperties.Multiple; save.currentWeaponDamageLevel = GameManager.Instance.currentWeapon.weaponProperties.DamageLevel; save.currentWeaponTrackBullet = GameManager.Instance.currentWeapon.weaponProperties.TrackBullet; save.currentWeaponBulletRange = GameManager.Instance.currentWeapon.weaponProperties.BulletRange; save.currentWeaponShoot = GameManager.Instance.currentWeapon.weaponProperties.shoot; return(save); }
public void Exchange(WeaponProperty wp) { string name = weaponProperty.itemName; int number = weaponProperty.itemNumber; string type = weaponProperty.itemType; //weaponProperties float bulletRange = weaponProperty.weaponProperties.BulletRange; int damageLevel = weaponProperty.weaponProperties.DamageLevel; int multiple = weaponProperty.weaponProperties.Multiple; string[] sss = weaponProperty.weaponProperties.shoot; int trackBullet = weaponProperty.weaponProperties.TrackBullet; weaponProperty.itemName = wp.itemName; weaponProperty.itemNumber = wp.itemNumber; weaponProperty.itemType = wp.itemType; //weaponProperties weaponProperty.weaponProperties.BulletRange = wp.weaponProperties.BulletRange; weaponProperty.weaponProperties.DamageLevel = wp.weaponProperties.DamageLevel; weaponProperty.weaponProperties.Multiple = wp.weaponProperties.Multiple; weaponProperty.weaponProperties.shoot = wp.weaponProperties.shoot; weaponProperty.weaponProperties.TrackBullet = wp.weaponProperties.TrackBullet; wp.itemName = name; wp.itemNumber = number; wp.itemType = type; //weaponProperties wp.weaponProperties.BulletRange = bulletRange; wp.weaponProperties.DamageLevel = damageLevel; wp.weaponProperties.Multiple = multiple; wp.weaponProperties.shoot = sss; wp.weaponProperties.TrackBullet = trackBullet; }
public void LoadByJSON() //菜单栏中的Load按钮 { if (File.Exists(Application.dataPath + "/StreamingAssets/Json/Data.text")) { StreamReader sr = new StreamReader(Application.dataPath + "/StreamingAssets/Json/Data.text"); string jsonString = sr.ReadToEnd(); sr.Close(); Save save = JsonUtility.FromJson <Save>(jsonString); int weaponNumber = 0; for (int i = 0; i < save.squareName.Count; i++) { if (save.squareType[i] == "weapon") { WeaponProperty wp = new WeaponProperty(); wp.weaponProperties.Multiple = save.bagWeaponMultiple[weaponNumber]; wp.weaponProperties.DamageLevel = save.bagWeaponDamageLevel[weaponNumber]; wp.weaponProperties.TrackBullet = save.bagWeaponTrackBullet[weaponNumber]; wp.weaponProperties.BulletRange = save.bagWeaponBulletRange[weaponNumber]; wp.weaponProperties.shoot[0] = save.bagWeaponShoot1[weaponNumber]; wp.weaponProperties.shoot[1] = save.bagWeaponShoot2[weaponNumber]; wp.weaponProperties.shoot[2] = save.bagWeaponShoot3[weaponNumber]; GameManager.Instance.square[i] = wp; weaponNumber++; } GameManager.Instance.square[i].itemName = save.squareName[i]; GameManager.Instance.square[i].itemNumber = save.squareNumber[i]; GameManager.Instance.square[i].itemType = save.squareType[i]; } //当前装备的武器 GameManager.Instance.currentWeapon.itemName = save.currentWeaponName; if (save.currentWeaponName == "null") { GameManager.Instance.currentWeapon.itemNumber = 0; GameManager.Instance.currentWeapon.itemType = "null"; } else { GameManager.Instance.currentWeapon.itemNumber = 1; GameManager.Instance.currentWeapon.itemType = "weapon"; } GameManager.Instance.currentWeapon.weaponProperties.Multiple = save.currentWeaponMultiple; GameManager.Instance.currentWeapon.weaponProperties.DamageLevel = save.currentWeaponDamageLevel; GameManager.Instance.currentWeapon.weaponProperties.TrackBullet = save.currentWeaponTrackBullet; GameManager.Instance.currentWeapon.weaponProperties.BulletRange = save.currentWeaponBulletRange; GameManager.Instance.currentWeapon.weaponProperties.shoot = save.currentWeaponShoot; ExBullet.instance.MultipleBullet = GameManager.Instance.currentWeapon.weaponProperties.Multiple; ExBullet.instance.Level = GameManager.Instance.currentWeapon.weaponProperties.DamageLevel; ExBullet.instance.shoot = GameManager.Instance.currentWeapon.weaponProperties.shoot; } else { Debug.Log("Data.text not exists"); } }
public void LoadWeapon(WeaponProperty wp) //这是读取json保存的数据 { wp.itemName = currentWeapon.itemName; wp.itemType = currentWeapon.itemType; wp.itemNumber = currentWeapon.itemNumber; wp.weaponProperties.Multiple = currentWeapon.weaponProperties.Multiple; wp.weaponProperties.DamageLevel = currentWeapon.weaponProperties.DamageLevel; wp.weaponProperties.TrackBullet = currentWeapon.weaponProperties.TrackBullet; wp.weaponProperties.BulletRange = currentWeapon.weaponProperties.BulletRange; wp.weaponProperties.shoot = currentWeapon.weaponProperties.shoot; // wp = currentWeapon; }
WeaponProperty GetWeaponProperty(int id) { WeaponProperty wp = new WeaponProperty(); var propertyConfig = SingletonManager.Get <WeaponPropertyConfigManager>().FindByWeaponId(id); if (propertyConfig != null) { wp = propertyConfig.GetWeaponProperty(); } return(wp); }
public void SaveWeapon(WeaponProperty wp) //从背包里获得当前装备中的武器数据,以供游戏中使用 { currentWeapon.itemName = wp.itemName; currentWeapon.itemType = wp.itemType; currentWeapon.itemNumber = wp.itemNumber; currentWeapon.weaponProperties.Multiple = wp.weaponProperties.Multiple; currentWeapon.weaponProperties.DamageLevel = wp.weaponProperties.DamageLevel; currentWeapon.weaponProperties.TrackBullet = wp.weaponProperties.TrackBullet; currentWeapon.weaponProperties.BulletRange = wp.weaponProperties.BulletRange; currentWeapon.weaponProperties.shoot = wp.weaponProperties.shoot; ExBullet.instance.MultipleBullet = currentWeapon.weaponProperties.Multiple; ExBullet.instance.Level = currentWeapon.weaponProperties.DamageLevel; ExBullet.instance.shoot = currentWeapon.weaponProperties.shoot; }
void OnSelectWeaponChanged(bool isOn, LevelMapWeaponObject weaponObject) { if (isOn && weaponObject) { //Weapon weapon = weaponObject.GetWeapon(); // WeaponProperty wp = WeaponManager.Instance.GetCurrentPropertyById(weaponObject.weaponId); WeaponItem wi = WeaponManager.Instance.GetWeaponItemById(weaponObject.weaponId); if (wi != null) { selectWeaponId = wi.Id; //设置名字 SetChildText(weaponSelect.GetComponent <RectTransform>(), "SelectedWeaponName", wi.Name); WeaponProperty wp = wi.GetCurrentProperty(); if (wp != null) { //设置武器攻击值 SetChildSliderValue(weaponInfo, "Pwoer", wp.Power / GameGlobalValue.s_MaxWeaponAttack); //设置攻击次数 SetChildSliderValue(weaponInfo, "FireRate", (wp.FireRate) / GameGlobalValue.s_MaxFireRatePerSeconds); //准确度 //float stab = 1.0f; //if (weapon.randomShooting) //{ // stab -= weapon.randomShootingSize.x / GameGlobalValue.s_MaxShakeDistance; //} //SetChildSliderValue(weaponInfo, "Stability", stab); //弹夹 SetChildSliderValue(weaponInfo, "Magazine", (float)wp.ClipSize / GameGlobalValue.s_MaxMagazineSize); //移动速度 // SetChildSliderValue(weaponInfo, "Mobility", weapon.moveSpeed / GameGlobalValue.s_MaxMobility); //得分能力 SetChildSliderValue(weaponInfo, "ScoreBouns", wp.ScoreBonus / GameGlobalValue.s_MaxSocreBonus); } } } else { selectWeaponId = -1; } }
public void UninstallWeapon() { for (int i = 0; i < BagManager.Instance.squareControls.Length; i++) { if (BagManager.Instance.squareControls[i].ItemProperty.itemName == "null") { WeaponProperty wp = new WeaponProperty(); BagManager.Instance.squareControls[i].ItemProperty = wp; Exchange((WeaponProperty)BagManager.Instance.squareControls[i].ItemProperty); DisplayInformation(); ChangeTexture(); BagManager.Instance.squareControls[i].ChangeTexture(BagManager.Instance.squareControls[i].ItemName, BagManager.Instance.squareControls[i].ItemType); Debug.Log("成功卸下装备"); return; } } Debug.Log("背包格子已满,无法卸下装备"); }
/// <summary> /// 获取武器等级信息 /// </summary> /// <param name="id">武器ID</param> /// <param name="level">武器等级</param> /// <returns></returns> public WeaponProperty GetPropertyById(int id, int level) { WeaponProperty wp = null; WeaponItem wi = GetWeaponItemById(id); if (wi != null) { //当level = -1时获取当前武器信息 if (level == -1) { wp = wi.Levels[wi.Level]; } else if (level < wi.Levels.Length && level >= 0) { wp = wi.Levels[level]; } } return(wp); }
public void Awake() { //Debug.Log("wepon init"); weaponItem = WeaponManager.Instance.GetWeaponItemById(ID); if (weaponItem == null) { Debug.LogError("Miss weapon info."); return; } WeaponProperty wp = weaponItem.GetCurrentProperty(); attack = wp.Power; shootInterval = 1f / wp.FireRate; this.scoreBonus = wp.ScoreBonus; curBulltCount = BulletCount = wp.BulletCount; magSize = wp.ClipSize; }
void CurWeaponShow() { //当前武器属性 WeaponProperty PropertyData = GameManager.Instance.GetWeaponProPerty(_curWeapon); if (!PropertyData.IsNull()) { string path = PropertyData.PrefabsPath; _curWeaponPrefabs = Resources.Load(path) as GameObject; if (_curWeaponPrefabs) { _curWeaponObj = Instantiate(_curWeaponPrefabs, CurWeaponPosition.position, CurWeaponPosition.rotation); } else { Debug.Log("CurWeapon path is error!"); } } }
//读取武器配置列表 public static Dictionary <int, WeaponProperty> ReadWeaponProperty() { DataRowCollection dataLst = ReadExcel.GameReadExcel(ExcelPathConfigs.WEAPONP_ROPERTY_PATH); Dictionary <int, WeaponProperty> weaponPropertyDict = new Dictionary <int, WeaponProperty>(); if (dataLst == null) { Debug.Log("ReadWeaponProperty is failed! DataRowCollection obj is null!"); return(weaponPropertyDict); } for (int i = 1; i < dataLst.Count; i++) { WeaponProperty data = new WeaponProperty(); DataRow excelst = dataLst[i]; if (excelst[0].ToString() == "" && excelst[1].ToString() == "") { continue; } data.Id = int.Parse(excelst[0].ToString()); //武器id data.WeaponName = excelst[1].ToString(); //武器名称 data.ShootRange = int.Parse(excelst[2].ToString()); //射程 data.MaxShootRange = int.Parse(excelst[3].ToString()); //最大射程 data.ATK = float.Parse(excelst[4].ToString()); //攻击力 data.FireRate = float.Parse(excelst[5].ToString()); //射速 data.ShootSpeed = float.Parse(excelst[6].ToString()); //子弹射击速度 data.MinAccumulateForce = float.Parse(excelst[7].ToString()); //蓄力最小数 data.MaxAccumulateForce = float.Parse(excelst[8].ToString()); //蓄力最大数 data.MaxAccumulateForceTime = float.Parse(excelst[9].ToString()); //蓄力最大限制时间 data.MinConsumeEnergy = int.Parse(excelst[10].ToString()); //最小能量消耗数值 data.MaxConsumeEnergy = int.Parse(excelst[11].ToString()); //最大能量消耗数值 data.HP = int.Parse(excelst[12].ToString()); //武器的子弹数 data.PrefabsPath = excelst[13].ToString(); //预置体路 data.BulletId = int.Parse(excelst[14].ToString()); //子弹Id weaponPropertyDict.Add(data.Id, data); } return(weaponPropertyDict); }
public void Add(string name, string type) { int emptySquareNumber = -1; for (int i = 0; i < square.Length; i++) //遍历数组 { if (emptySquareNumber == -1 && square[i].itemName == "null") //在遍历数组的同时,看有没有空的格子 { emptySquareNumber = i; //有就记录第一个找到的空格 if (type == "weapon") //因为武器都不同,所以一个格子一个武器 { WeaponProperty weaponProperty = new WeaponProperty(); weaponProperty.weaponProperties.RandomProperties(); //武器的属性是在一开始捡起来的时候随机的 square[emptySquareNumber] = weaponProperty; square[emptySquareNumber].itemName = name; square[emptySquareNumber].itemType = type; square[emptySquareNumber].itemNumber++; return; } } if (type != "weapon" && square[i].itemName == name) //如果在数组里找到相同名字的 { square[i].itemNumber++; //数量++,返回 return; } } if (emptySquareNumber == -1) //没有空格的情况 { Debug.Log("背包已满"); } else //新增加物品的情况 { square[emptySquareNumber].itemName = name; square[emptySquareNumber].itemType = type; square[emptySquareNumber].itemNumber++; } }
public void SetWeaponProperty(int weaponId) { WeaponProperty = GameManager.Instance.GetWeaponProPerty(weaponId); }
set => this.SetValue(WeaponProperty, value);
public void ClickUseButton() //使用按钮 { if (selectionItem == null || selectionItem.ItemName == "null") { return; } Debug.Log(selectionItem.ItemProperty.itemType); switch (selectionItem.ItemProperty.itemType) { case "prop": selectionItem.ItemNumber--; if (selectionItem.ItemNumber == 0) //使用完后将格子清空 { selectionItem.ItemProperty = new ItemProperty(); selectionItem.ChangeTexture("null", "null"); Initialize(); return; } selectionItem.ChangeTexture(selectionItem.ItemProperty.itemName, selectionItem.ItemProperty.itemType); //未用完更新一下数量文本 break; case "weapon": WeaponProperty selectionItemItemProperty = (WeaponProperty)selectionItem.ItemProperty; //交换 if (weapon.GetComponent <WeaponControl>().weaponProperty.itemName == "null") //还未装备武器 { // weapon.GetComponent<WeaponControl>().weaponProperty = (WeaponProperty)selectionItem.ItemProperty; weapon.GetComponent <WeaponControl>().Exchange(selectionItemItemProperty); weapon.GetComponent <WeaponControl>().ChangeTexture(); selectionItem.ItemProperty = new ItemProperty(); selectionItem.ChangeTexture(selectionItem.ItemProperty.itemName, selectionItem.ItemProperty.itemType); weapon.GetComponent <WeaponControl>().DisplayInformation(); Initialize(); } else { // WeaponProperty swap = new WeaponProperty(); // swap = selectionItemItemProperty; // selectionItemItemProperty = weapon.GetComponent<WeaponControl>().weaponProperty; // weapon.GetComponent<WeaponControl>().weaponProperty = swap; weapon.GetComponent <WeaponControl>().Exchange(selectionItemItemProperty); selectionItem.ChangeTexture(selectionItem.ItemProperty.itemName, selectionItem.ItemProperty.itemType); weapon.GetComponent <WeaponControl>().ChangeTexture(); weapon.GetComponent <WeaponControl>().DisplayInformation(); Initialize(); } break; case "slot": if (weapon.GetComponent <WeaponControl>().weaponProperty.itemName == "null") { Debug.Log("还未装备武器,无法使用"); return; } if (!weapon.GetComponent <WeaponControl>().EmbeddedIntoTheSlot(selectionItem.ItemProperty.itemName)) { Debug.Log("武器的槽位已满"); return; } Debug.Log("装上槽位"); weapon.GetComponent <WeaponControl>().DisplayInformation(); selectionItem.ItemNumber--; if (selectionItem.ItemNumber == 0) //使用完后将格子清空 { selectionItem.ItemProperty = new ItemProperty(); selectionItem.ChangeTexture("null", "null"); Initialize(); return; } selectionItem.ChangeTexture(selectionItem.ItemProperty.itemName, selectionItem.ItemProperty.itemType); //未用完更新一下数量文本 break; default: break; } }
/// <summary> /// Get the value of the current property of this model /// </summary> public int GetProperty(WeaponSkill skill, WeaponProperty property) { return(MtaShared.GetWeaponProperty(ID, skill.ToString().ToLower(), property.ToString().ToLower())); }
void RefreshWeaponAttr() { var config = GetConfig(); viewModel.AttrGroupActive = false; WeaponProperty contrastProperty = new WeaponProperty(); if (config.Category == (int)ECategory.Weapon || config.Category == (int)ECategory.WeaponPart) //需要加上武器配件的// { if (IsWeaponAvatar(config)) { return; } if (curShowTipData.NeedContrast()) { contrastProperty = GetWeaponProperty(curShowTipData.ContrastTemId); } viewModel.AttrGroupActive = true; arrtDataList.Clear();//todo WeaponProperty wp = new WeaponProperty(); if (config.Category == (int)ECategory.Weapon) { wp = GetWeaponProperty(config.Id); if (IsMyWeapon())//todo,还需添加装备配件的属性 { foreach (var it in curShowTipData.WeaponPartsList) { var newWp = GetWeaponProperty(it.Id); wp.Add(newWp); } } } foreach (var item in TipConst.WeaponPropertyName) { string propertyName = item.Key; if (propertyName.Equals(TipConst.BulletPropertyName) || propertyName.Equals(TipConst.MaxBulletPropertyName)) { continue; } var cpropertyInfo = wp.GetType().GetField(propertyName); float propertyValue = (float)cpropertyInfo.GetValue(wp); if (propertyValue > 0) { var itemData = new ContrastPropertyItemData() { IsBullet = false, Value = propertyValue, Name = TipConst.GetWeaponPropertyName(propertyName), }; if (curShowTipData.NeedContrast()) { var contrastProperValue = (float)cpropertyInfo.GetValue(contrastProperty); itemData.DiffValue = itemData.Value - contrastProperValue; } arrtDataList.Add(itemData); } } int BulletValue = wp.Bullet; int MaxBulletValue = wp.Bulletmax; if (BulletValue != 0 && MaxBulletValue != 0) { var itemData = new ContrastPropertyItemData() { IsBullet = true, Bullet = BulletValue, MaxBullet = MaxBulletValue, Name = TipConst.GetWeaponPropertyName(TipConst.BulletPropertyName), }; arrtDataList.Add(itemData); } attrUIList.SetDataList <WeaponPropertyBarItem, ContrastPropertyItemData>(arrtDataList); } }
public void ShowItemText(string name, string type, SquareControl square) //显示物品信息 { switch (type) { case "prop": nameText.text = name; if (name == "null") { descriptionText.text = "null"; } else { // descriptionText.text = ItemManager.Instance.propValue[name]["description"] as string; descriptionText.text = (string)ItemManager.Instance.GetPropertyByName(name, type, "description"); } break; case "weapon": nameText.text = name; if (name == "null") { descriptionText.text = "null"; } else { WeaponProperty wp = (WeaponProperty)square.ItemProperty; descriptionText.text = "Multiple:" + wp.weaponProperties.Multiple + "\n" + "DamageLevel:" + wp.weaponProperties.DamageLevel + "\n" + "TrackBullet:" + wp.weaponProperties.TrackBullet + "\n" + "BulletRange:" + wp.weaponProperties.BulletRange + "\n" + "Slot1:" + wp.weaponProperties.shoot[0] + "\n" + "Slot2:" + wp.weaponProperties.shoot[1] + "\n" + "Slot3:" + wp.weaponProperties.shoot[2] + "\n"; } break; case "slot": nameText.text = name; if (name == "null") { descriptionText.text = "null"; } else { // descriptionText.text = ItemManager.Instance.propValue[name]["description"] as string; descriptionText.text = (string)ItemManager.Instance.GetPropertyByName(name, type, "description"); } break; default: nameText.text = name; if (name == "null") { descriptionText.text = "null"; } else { // descriptionText.text = ItemManager.Instance.propValue[name]["description"] as string; descriptionText.text = (string)ItemManager.Instance.GetPropertyByName(name, type, "description"); } break; } }
/// <summary> /// Sets the value of a property of this mode /// </summary> /// <param name="skill"></param> /// <param name="property"></param> /// <param name="value"></param> /// <returns></returns> public bool SetProperty(WeaponSkill skill, WeaponProperty property, int value) { return(MtaShared.SetWeaponProperty(ID, skill.ToString().ToLower(), property.ToString().ToLower(), value)); }