/// <summary> /// Init /// </summary> protected void Init(uint batteryId, uint barrelId, uint bulletId) { this.batteryData = Masters.BatteryDB.FindById(batteryId); this.barrelData = Masters.BarrelDB.FindById(barrelId); this.bulletData = Masters.BulletDB.FindById(bulletId); this.fvAttackData = Masters.FvAttackDB.FindById(this.batteryData.fvAttackId); this.turretBase.batteryKey = this.batteryData.key; this.turretBase.barrelKey = this.barrelData.key; this.turretBase.bulletKey = this.bulletData.key; this.loader.Add<GameObject>(SharkDefine.GetBatteryPrefabPath(this.turretBase.batteryKey)); this.loader.Add<GameObject>(SharkDefine.GetBarrelPrefabPath(this.turretBase.barrelKey)); this.loader.Add<BulletBase>(SharkDefine.GetBulletPrefabPath(this.turretBase.bulletKey)); this.fvaAsset = this.loader.Add<FvAttackBase>(SharkDefine.GetFvAttackPrefabPath((FvAttackType)this.fvAttackData.type)); this.fvaBulletAsset = this.loader.Add<BulletBase>(SharkDefine.GetFvAttackBulletPrefabPath(this.fvAttackData.key)); this.loader.Add<Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)this.fvAttackData.type)); this.loader.Add<AudioClip>(SharkDefine.GetSeClipPath(this.barrelData.seName)); this.loader.Add<AudioClip>(SharkDefine.GetSeClipPath(this.bulletData.seName)); string fvAttackSeName = SeName.FvAttackSeName[(int)this.fvAttackData.type]; if (!string.IsNullOrEmpty(fvAttackSeName)) { this.loader.Add<AudioClip>(SharkDefine.GetSeClipPath(fvAttackSeName)); } if (this.fvAttackData.type == (uint)FvAttackType.Penetration) { this.fvaPenetrationChargeEffectAsset = this.loader.Add<GameObject>(SharkDefine.GetFVAChargeEffectPrefabPath(this.fvAttackData.key)); } }
/// <summary> /// 必要リソースの読み込み /// </summary> private void Load(Action onCompleted) { var items = Masters.ShopGroupDB .GetList() .SelectMany(x1 => Masters.ShopDB.GetList().FindAll(x2 => x2.shopGroupId == x1.id)) .SelectMany(x1 => Masters.ShopItemDB.GetList().FindAll(x2 => x2.shopItemId == x1.shopItemId)) .Select(x => CommonIconUtility.GetItemInfo(x.itemType, x.itemId)) .Concat(Masters.BillingGroupDB .GetList() .SelectMany(x1 => Masters.BillingDB.GetList().FindAll(x2 => x2.billingGroupId == x1.id)) .SelectMany(x1 => Masters.BillingItemDB.GetList().FindAll(x2 => x2.billingItemId == x1.billingItemId)) .Select(x => CommonIconUtility.GetItemInfo(x.itemType, x.itemId))) .Where(x => !x.IsCommonSprite()) .ToArray(); foreach (var item in items) { if (item is Master.CannonSetData) { var cannonSet = item as Master.CannonSetData; var batteryData = Masters.BatteryDB.FindById(cannonSet.batteryId); var barrelData = Masters.BarrelDB.FindById(cannonSet.barrelId); var bulletData = Masters.BulletDB.FindById(cannonSet.bulletId); var fvaData = Masters.FvAttackDB.FindById(batteryData.fvAttackId); //砲台サムネロード this.assetLoader.Add <Sprite>(SharkDefine.GetTurretSetSpritePath(batteryData.key)); //砲台パーツスプライトロード this.assetLoader.Add <Sprite>(SharkDefine.GetBatterySpritePath(batteryData.key)); this.assetLoader.Add <Sprite>(SharkDefine.GetBarrelSpritePath(barrelData.key)); this.assetLoader.Add <Sprite>(SharkDefine.GetBulletThumbnailPath(bulletData.key)); //砲台パーツプレハブロード this.assetLoader.Add <GameObject>(SharkDefine.GetBatteryPrefabPath(batteryData.key)); this.assetLoader.Add <GameObject>(SharkDefine.GetBarrelPrefabPath(barrelData.key)); this.assetLoader.Add <BulletBase>(SharkDefine.GetBulletPrefabPath(bulletData.key)); //FVAアイコンスプライトロード this.assetLoader.Add <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvaData.type)); //シリーズスキルスプライトロード if (batteryData.seriesId == barrelData.seriesId && batteryData.seriesId == bulletData.seriesId) { var serieseData = Masters.TurretSerieseDB.FindById(batteryData.seriesId); var serieseSkillData = Masters.SerieseSkillDB.FindById(serieseData.seriesSkillId); this.assetLoader.Add <Sprite>(SharkDefine.GetSeriesSkillIconSpritePath(serieseSkillData.key)); } } else { var spritePath = item.GetSpritePath(); this.assetLoader.Add <Sprite>(spritePath); } } //読み込み開始 this.assetLoader.Load(onCompleted); }
/// <summary> /// FVA情報の設定 /// </summary> public void SetFVAInfo(uint fvaId) { var fvaData = Masters.FvAttackDB.FindById(fvaId); this.iconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvaData.type)).asset as Sprite; this.nameText.text = fvaData.name; this.descriptionText.text = fvaData.description; }
/// <summary> /// アイコン差し替え /// </summary> public void RefleshIconSprite() { var batteryData = Masters.BatteryDB.FindById(userData.turretData.batteryMasterId); var fvAttackData = Masters.FvAttackDB.FindById(batteryData.fvAttackId); var iconSpritePath = SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvAttackData.type); var iconSpriteHandle = AssetManager.FindHandle <Sprite>(iconSpritePath); this.typeIconImage.sprite = iconSpriteHandle.asset as Sprite; }
/// <summary> /// ロード /// </summary> private void Load() { uint[] batteryIds = UserData.Get().batteryData.Select(x => x.itemId).Distinct().ToArray(); uint[] barrelIds = UserData.Get().barrelData.Select(x => x.itemId).Distinct().ToArray(); uint[] bulletIds = UserData.Get().bulletData.Select(x => x.itemId).Distinct().ToArray(); uint[] accessoryIds = UserData.Get().accessoriesData.Select(x => x.itemId).Distinct().ToArray(); uint[] fvAttackTypes = null; uint[] seriesSkillIds = null; uint[] gearIds = UserData.Get().gearData.Select(x => x.gearId).Distinct().ToArray(); var fvAttackIds = new List <uint>(); var seriesIds = new List <uint>(); foreach (uint id in batteryIds) { //台座スプライトのロード var data = Masters.BatteryDB.FindById(id); this.assetLoader.Add <Sprite>(SharkDefine.GetBatterySpritePath(data.key)); this.assetLoader.Add <GameObject>(SharkDefine.GetBatteryPrefabPath(data.key)); //FVアタックIDを詰める fvAttackIds.Add(data.fvAttackId); //シリーズIDを詰める seriesIds.Add(data.seriesId); } foreach (uint id in barrelIds) { //砲身スプライトのロード var data = Masters.BarrelDB.FindById(id); this.assetLoader.Add <Sprite>(SharkDefine.GetBarrelSpritePath(data.key)); this.assetLoader.Add <GameObject>(SharkDefine.GetBarrelPrefabPath(data.key)); //シリーズIDを詰める seriesIds.Add(data.seriesId); } foreach (uint id in bulletIds) { //砲弾プレハブ、砲弾サムネイルのロード var data = Masters.BulletDB.FindById(id); this.assetLoader.Add <Sprite>(SharkDefine.GetBulletThumbnailPath(data.key)); this.assetLoader.Add <BulletBase>(SharkDefine.GetBulletPrefabPath(data.key)); //シリーズIDを詰める seriesIds.Add(data.seriesId); } foreach (uint id in accessoryIds) { //アクセサリサムネイルのロード var data = Masters.AccessoriesDB.FindById(id); this.assetLoader.Add <Sprite>(SharkDefine.GetAccessoryThumbnailPath(data.key)); } //FVアタックIDからFVアタックタイプに fvAttackTypes = fvAttackIds .Distinct() .Select(id => Masters.FvAttackDB.FindById(id).type) .Distinct() .ToArray(); foreach (uint type in fvAttackTypes) { //FVアタックタイプアイコンのロード this.assetLoader.Add <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)type)); } //砲台シリーズIDからシリーズスキルIDに seriesSkillIds = seriesIds .Distinct() .Select(id => Masters.TurretSerieseDB.FindById(id).seriesSkillId) .Distinct() .ToArray(); foreach (uint id in seriesSkillIds) { //シリーズスキルアイコンのロード var data = Masters.SerieseSkillDB.FindById(id); this.assetLoader.Add <Sprite>(SharkDefine.GetSeriesSkillIconSpritePath(data.key)); } //ロード開始 this.assetLoader.Load(this.OnLoaded); }
/// <summary> /// パーツ情報セット /// </summary> public void SetPartsData(UserPartsData data, bool isEquipped, Action onReflesh, Action onRefleshDecomposition) { this.partsData = data; this.onReflesh = onReflesh; this.onRefleshDecomposition = onRefleshDecomposition; this.isEquipped = isEquipped; // パーツアイコンセット partsCommonIcon.Set( data: data, isEquipped: isEquipped, isLock: data.lockFlg, onClick: null ); // パーツが台座の場合 if (this.partsData.itemType == (uint)ItemType.Battery) { partsInfo = new BatteryPartsInfo(data); // 台座FVアタックスプライトセット this.partsViewFvAttackIconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)partsInfo.fvType)).asset as Sprite; // 台座FVアタック情報セット this.partsViewFvAttackNameText.text = partsInfo.fvName; this.partsViewFvAttackDescriptionText.text = partsInfo.fvDescription; } // パーツが砲身の場合 else if (this.partsData.itemType == (uint)ItemType.Barrel) { partsInfo = new BarrelPartsInfo(data); this.fvAttackArea.SetActive(false); } // パーツが砲弾の場合 else if (this.partsData.itemType == (uint)ItemType.Bullet) { partsInfo = new BulletPartsInfo(data); this.fvAttackArea.SetActive(false); } // パーツが装飾の場合 else if (this.partsData.itemType == (uint)ItemType.Accessory) { partsInfo = new DecorationPartsInfo(data); } // 同一のパーツ数テキスト this.overlapCountText.text = partsInfo.partsCount; // パーツ情報セット this.partsNameText.text = partsInfo.name; this.partsDescriptionText.text = partsInfo.description; // ゲージ var config = Masters.ConfigDB.FindById(1); var gearDatas = this.partsData.gearMasterIds.Select(gearId => Masters.GearDB.FindById(gearId)).ToArray(); // ギアスロットの全てのギアを能力値別に、合算 var gearPower = gearDatas.Select(x => (long)x.power).Sum(); var gearSpeed = gearDatas.Select(x => (long)x.speed).Sum(); var gearFvPoint = gearDatas.Select(x => (long)x.fvPoint).Sum(); // パーツはギア能力値を合算 uint power = partsInfo.power + (uint)gearPower; uint speed = partsInfo.speed + (uint)gearSpeed; uint fvPoint = partsInfo.fvPoint + (uint)gearFvPoint; Debug.LogFormat("power : {0}, bulletSpeed : {1}, fvPointGetValue{2} : {2}", power, speed, fvPoint); // ゲージ初期化 float gaugePower = 0f; float gaugeSpeed = 0f; float gaugeFvPoint = 0f; if (this.partsData.itemType == (uint)ItemType.Accessory) { this.fvAttackArea.SetActive(false); this.gaugeArea.SetActive(false); this.gearsArea.SetActive(false); } else { // パーツが砲弾の場合 if (this.partsData.itemType == (uint)ItemType.Bullet) { if (power < config.maxBulletPower / 5) { gaugePower = 0.2f; } else { gaugePower = (float)power / config.maxBulletPower; } gaugeSpeed = (float)speed / config.maxBarrelSpeed; gaugeFvPoint = (float)fvPoint / config.maxBatteryFvPoint; } // パーツが砲身の場合 else if (this.partsData.itemType == (uint)ItemType.Barrel) { if (speed < config.maxBarrelSpeed / 5) { gaugeSpeed = 0.2f; } else { gaugeSpeed = (float)speed / config.maxBarrelSpeed; } gaugePower = (float)power / config.maxBulletPower; gaugeFvPoint = (float)fvPoint / config.maxBatteryFvPoint; } // パーツが台座の場合 else if (this.partsData.itemType == (uint)ItemType.Battery) { if (speed < config.maxBatteryFvPoint / 5) { gaugeFvPoint = 0.2f; } else { gaugeFvPoint = (float)fvPoint / config.maxBatteryFvPoint; } gaugePower = (float)power / config.maxBulletPower; gaugeSpeed = (float)speed / config.maxBarrelSpeed; } // ゲージセット this.powerGauge.SetGaugeValue(Mathf.Clamp01(gaugePower)); this.bulletSpeedGauge.SetGaugeValue(Mathf.Clamp01(gaugeSpeed)); this.fvPointGetCalueGauge.SetGaugeValue(Mathf.Clamp01(gaugeFvPoint)); // ギアスロットセット this.GearSlotReflesh(data); } // ロックチェック if (data.lockFlg == 1) { this.lockOn.gameObject.SetActive(true); this.lockOff.gameObject.SetActive(false); } else { this.lockOn.gameObject.SetActive(false); this.lockOff.gameObject.SetActive(true); } // 分解詩修得アイテムマスターID取得(ギアがない場合) if (gearDatas.Length == 0) { this.getItem = Masters.ItemSellDB.GetList().FindAll(x => x.itemSellId == partsInfo.itemSellId).ToArray(); // 分解詩修得アイテムスクロールビュー this.decompositionScrollView.Initialize( this.decompositionItemPrefab.gameObject, this.getItem.Length, this.OnUpdateDecompositionScrollViewItem ); } // 分解詩修得アイテムマスターID取得(ギアがある場合) else { // パーツの分解時アイテム取得 this.getItem = Masters.ItemSellDB.GetList().FindAll(x => x.itemSellId == partsInfo.itemSellId).ToArray(); // パーツの分解時取得アイテムをリストの変更 List <Master.ItemSellData> sellDatas = getItem.ToList(); for (int i = 0; i < gearDatas.Length; i++) { // ギアの分解時アイテム取得 Master.ItemSellData[] getGearItem = Masters.ItemSellDB.GetList().FindAll(x => x.itemSellId == gearDatas[i].itemSellId).ToArray(); // getItemに追加 for (int y = 0; y < getGearItem.Length; y++) { sellDatas.Add(getGearItem[y]); } } // リスト配列に変更 this.getItem = sellDatas.ToArray(); // アイコンセット this.decompositionScrollView.Initialize( this.decompositionItemPrefab.gameObject, getItem.Length, this.OnUpdateDecompositionScrollViewItem ); } // ボタングレーアウトON/OFF if (this.partsData.lockFlg == 1 || this.partsData.useFlg || this.isGearLockCount > 0 || partsInfo.itemSellId == 0) { this.SetGrayout(true); this.decompositionButton.interactable = false; } else { this.SetGrayout(false); this.decompositionButton.interactable = true; } // 初期砲台の場合、分解不可能の案内メッセージ、テキストセット if (partsInfo.itemSellId == 0) { this.defaultCanonText.text = Masters.LocalizeTextDB.Get("CannotDisassembledDefaultCanon"); } else { this.defaultCanonText.text = null; } }
/// <summary> /// 表示更新 /// </summary> public void Reflesh(UserTurretData data) { //ゲージ最大値設定 var config = Masters.ConfigDB.FindById(1); var MAX_POWER = config.maxBulletPower; var MAX_BULLET_SPEED = config.maxBarrelSpeed; var MAX_FV_POINT_GET_VALUE = config.maxBatteryFvPoint; // マスターデータ var batteryData = Masters.BatteryDB.FindById(data.batteryMasterId); var barrelData = Masters.BarrelDB.FindById(data.barrelMasterId); var bulletData = Masters.BulletDB.FindById(data.bulletMasterId); var accessoryData = Masters.AccessoriesDB.FindById(data.accessoryMasterId); var fvAttackData = Masters.FvAttackDB.FindById(batteryData.fvAttackId); // 現在のパーツ var batteryPartsData = UserData.Get().batteryData.First(x => x.serverId == data.batteryServerId); var barrelPartsData = UserData.Get().barrelData.First(x => x.serverId == data.barrelServerId); var bulletPartsData = UserData.Get().bulletData.First(x => x.serverId == data.bulletServerId); // 装着中のギアを配列に合併 var gearDatas = batteryPartsData.gearMasterIds .Concat(barrelPartsData.gearMasterIds) .Concat(bulletPartsData.gearMasterIds) .Select(gearId => Masters.GearDB.FindById(gearId)) .ToArray(); // 能力値別に合算 var gearPower = gearDatas.Select(x => (long)x.power).Sum(); var gearSpeed = gearDatas.Select(x => (long)x.speed).Sum(); var gearFvPoint = gearDatas.Select(x => (long)x.fvPoint).Sum(); // パーツ能力値デとギア能力値を合併 uint power = bulletData.power + (uint)gearPower; uint bulletSpeed = barrelData.speed + (uint)gearSpeed; uint fvPointGetValue = batteryData.fvPoint + (uint)gearFvPoint; Debug.LogFormat("power : {0}, bulletSpeed : {1}, fvPointGetValue{2} : {2}", power, bulletSpeed, fvPointGetValue); var fvAttackIconSprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvAttackData.type)).asset as Sprite; var batterySprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetBatterySpritePath(batteryData.key)).asset as Sprite; var barrelSprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetBarrelSpritePath(barrelData.key)).asset as Sprite; var bulletSprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetBulletThumbnailPath(bulletData.key)).asset as Sprite; var accessorySprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetAccessoryThumbnailPath(accessoryData.key)).asset as Sprite; //攻撃力ゲージ設定 //float p = (float)(power - CustomTurretScene.minBulletPower) / (MAX_POWER - CustomTurretScene.minBulletPower) + 0.2f; float p; if (power < MAX_POWER / 5) { p = 0.2f; } else { p = (float)power / MAX_POWER; } this.powerGauge.SetGaugeValue(Mathf.Clamp01(p)); this.partsPowerGauge.SetGaugeValue(Mathf.Clamp01(p)); //発射速度ゲージ設定 //p = (float)(bulletSpeed - CustomTurretScene.minBarrelSpeed) / (MAX_BULLET_SPEED - CustomTurretScene.minBarrelSpeed) + 0.2f; if (bulletSpeed < MAX_BULLET_SPEED / 5) { p = 0.2f; } else { p = (float)bulletSpeed / MAX_BULLET_SPEED; } this.bulletSpeedGauge.SetGaugeValue(Mathf.Clamp01(p)); this.partsBulletSpeedGauge.SetGaugeValue(Mathf.Clamp01(p)); //FVポイント獲得値ゲージ設定 //p = (float)(fvPointGetValue - CustomTurretScene.minBatteryFvPoint) / (MAX_FV_POINT_GET_VALUE - CustomTurretScene.minBatteryFvPoint) + 0.2f; if (fvPointGetValue < MAX_FV_POINT_GET_VALUE / 5) { p = 0.2f; } else { p = (float)fvPointGetValue / MAX_FV_POINT_GET_VALUE; } this.fvPointGetValueGauge.SetGaugeValue(Mathf.Clamp01(p)); this.partsfvPointGetCalueGauge.SetGaugeValue(Mathf.Clamp01(p)); //パーツページのFVアタック名、アイコン画像、説明文設定 this.partsViewFvAttackNameText.text = fvAttackData.name; this.partsViewFvAttackIconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvAttackData.type)).asset as Sprite; this.partsViewFvAttackDescriptionText.text = fvAttackData.description; //砲台ページのFVアタック名、アイコン画像、説明文設定 this.turretViewFvAttackNameText.text = fvAttackData.name; this.turretViewFvAttackIconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetFvAttackTypeIconSpritePath((FvAttackType)fvAttackData.type)).asset as Sprite; this.turretViewFvAttackDescriptionText.text = fvAttackData.description; //セットスキル発動 if (batteryData.seriesId == barrelData.seriesId && batteryData.seriesId == bulletData.seriesId) { var seriesData = Masters.TurretSerieseDB.FindById(batteryData.seriesId); var seriesSkillData = Masters.SerieseSkillDB.FindById(seriesData.seriesSkillId); //パーツページのセットスキル名、説明文、アイコン画像設定 this.partsViewSetSkillIconImage.enabled = true; this.partsViewSetSkillIconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetSeriesSkillIconSpritePath(seriesSkillData.key)).asset as Sprite; this.partsViewSetSkillNameText.text = seriesSkillData.name; this.partsViewSetSkillDescriptionText.text = seriesSkillData.description; //砲台ページのセットスキル名、説明文、アイコン画像設定 this.turretViewSetSkillIconImage.enabled = true; this.turretViewSetSkillIconImage.sprite = AssetManager.FindHandle <Sprite>(SharkDefine.GetSeriesSkillIconSpritePath(seriesSkillData.key)).asset as Sprite; this.turretViewSetSkillNameText.text = seriesSkillData.name; this.turretViewSetSkillDescriptionText.text = seriesSkillData.description; } //セットスキル不発 else { //パーツページのセットスキル名、説明文、アイコン画像非表示 this.partsViewSetSkillIconImage.enabled = false; this.partsViewSetSkillNameText.text = null; this.partsViewSetSkillDescriptionText.text = null; //砲台ページのセットスキル名、説明文、アイコン画像非表示 this.turretViewSetSkillIconImage.enabled = false; this.turretViewSetSkillNameText.text = null; this.turretViewSetSkillDescriptionText.text = null; } //パーツページ台座アイコン this.partsViewBatteryIcon.SetIconSprite(batterySprite); this.partsViewBatteryIcon.SetRank((Rank)batteryData.rarity); this.partsViewBatteryIcon.SetGearSlot(batteryPartsData); //パーツページ砲身アイコン this.partsViewBarrelIcon.SetIconSprite(barrelSprite); this.partsViewBarrelIcon.SetRank((Rank)barrelData.rarity); this.partsViewBarrelIcon.SetGearSlot(barrelPartsData); //パーツページ砲弾アイコン this.partsViewBulletIcon.SetIconSprite(bulletSprite); this.partsViewBulletIcon.SetRank((Rank)bulletData.rarity); this.partsViewBulletIcon.SetGearSlot(bulletPartsData); //パーツページアクセサリアイコン this.partsViewAccessoryIcon.SetIconSprite(accessorySprite); this.partsViewAccessoryIcon.SetRank((Rank)accessoryData.rarity); //砲台ページ台座アイコン this.turretViewBatteryIcon.SetIconSprite(batterySprite); this.turretViewBatteryIcon.SetRank((Rank)batteryData.rarity); this.turretViewBatteryIcon.SetGearSlot(batteryPartsData); //砲台ページ砲身アイコン this.turretViewBarrelIcon.SetIconSprite(barrelSprite); this.turretViewBarrelIcon.SetRank((Rank)barrelData.rarity); this.turretViewBarrelIcon.SetGearSlot(barrelPartsData); //砲台ページ砲弾アイコン this.turretViewBulletIcon.SetIconSprite(bulletSprite); this.turretViewBulletIcon.SetRank((Rank)bulletData.rarity); this.turretViewBulletIcon.SetGearSlot(bulletPartsData); //砲台ページアクセサリアイコン this.turretViewAccessoryIcon.SetIconSprite(accessorySprite); this.turretViewAccessoryIcon.SetRank((Rank)accessoryData.rarity); }