Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle
| | |
| | | public static bool IsNewbie = true; |
| | | |
| | | /// <summary> |
| | | /// 所有新手的引导步骤是否全部完成 |
| | | /// </summary> |
| | | public static bool IsNewbieGuideCompleted = false; |
| | | |
| | | /// <summary> |
| | | /// 无尽模式每一轮游戏中成功使用技能宝石的次数 |
| | | /// </summary> |
| | | public static int EndlessPortUseSkillTowerCount; |
| | |
| | | /// <summary> |
| | | /// 掉落半径 |
| | | /// </summary> |
| | | public float DropRadius { get; set; } = 50f; |
| | | public float DropRadius { get; set; } = 5f; |
| | | |
| | | public Canvas canvas; |
| | | |
| | |
| | | Transform mainUITransform = mainUI.GetComponent<Transform>(); |
| | | obj.GetComponent<Transform>().SetParent(mainUITransform, true); |
| | | |
| | | // Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos); |
| | | // Vector2 targetPos; |
| | | // RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, screenPos, canvas.worldCamera, out targetPos); |
| | | // RectTransform rectTransform = obj.GetComponent<RectTransform>(); |
| | | // rectTransform.anchoredPosition = pos; |
| | | // obj.transform.localRotation = Quaternion.identity; |
| | | |
| | | // Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos); |
| | | // screenPos.z = 0; |
| | | |
| | | obj.transform.position = worldPos; |
| | | obj.transform.localRotation = Quaternion.identity; |
| | | obj.transform.localScale = Vector3.one; |
| | | |
| | | // if (isRandom) |
| | | // { |
| | | // Vector2 p = UnityEngine.Random.insideUnitCircle * DropRadius; |
| | | // Vector3 pos1 = p.normalized * p.magnitude; |
| | | // Vector3 objPos = obj.transform.position; |
| | | // objPos.x += pos1.x; |
| | | // objPos.y += pos1.y; |
| | | // obj.transform.position = objPos; |
| | | // } |
| | | if (isRandom) |
| | | { |
| | | Vector2 p = UnityEngine.Random.insideUnitCircle * DropRadius; |
| | | Vector3 pos1 = p.normalized * p.magnitude; |
| | | Vector3 objPos = obj.transform.position; |
| | | objPos.x += pos1.x; |
| | | objPos.z += pos1.y; |
| | | obj.transform.position = objPos; |
| | | } |
| | | |
| | | dropReward.PlayParticle(); |
| | | DropObjDic.Add(drop.Id, obj); |
| | |
| | | if (EndlessLeveltate == LevelState.SpawningEnemies && IsAllWaveCompleted && NumberOfEnemies == 0) |
| | | { |
| | | // 新手的话,第一关完了暂停 |
| | | if (!GameConfig.IsNewbie || GameConfig.IsNewbieGuideCompleted) |
| | | if (!GameConfig.IsNewbie) |
| | | { |
| | | if (!UpdateLevel()) |
| | | ChangeLevelState(LevelState.AllEnemiesSpawned); |
| | |
| | | SelectBtn.onClick.AddListener(OnClickSelectBtn); |
| | | } |
| | | |
| | | private void OnEnable() |
| | | private void OnDisable() |
| | | { |
| | | Reset(); |
| | | } |
| | | |
| | | private void Reset() |
| | | { |
| | | isCompleted = false; |
| | | SelectedIndex = -1; |
| | |
| | | { |
| | | if (SelectedIndex == -1) return; |
| | | |
| | | int index = SelectedIndex; |
| | | |
| | | HideBuffUI(); |
| | | |
| | | if (BuffSelectCompleted != null) |
| | | BuffSelectCompleted(SelectedIndex); |
| | | BuffSelectCompleted(index); |
| | | } |
| | | |
| | | public void ShowBuffUI() |
| | |
| | | if (DropData.Reward.id == 0) |
| | | resId = $"{path}{(int)DropData.Reward.type}"; |
| | | else |
| | | resId = $"{path}{(int)DropData.Reward.type}_${DropData.Reward.id}"; |
| | | resId = $"{path}{(int)DropData.Reward.type}_{DropData.Reward.id}"; |
| | | Icon.sprite = Resources.Load<Sprite>(resId); |
| | | Icon.SetNativeSize(); |
| | | } |
| | |
| | | /// </summary> |
| | | public void ReturnToMainMenu() |
| | | { |
| | | if (GameConfig.IsNewbieGuideCompleted) |
| | | GameConfig.IsNewbie = false; |
| | | |
| | | // 清空所有Tween数据: |
| | | DOTween.Clear(); |
| | | EndlessUIStart.bFirstLoaded = false; |
| | |
| | | using UnityEngine; |
| | | using TowerDefense.Level; |
| | | using UnityEngine.UI; |
| | | using Protobuf; |
| | | |
| | | /** |
| | | * 无尽模式结算界面列表脚本 |
| | |
| | | |
| | | for (int i = 0; i < list.Count; ++i) |
| | | { |
| | | if (list[i].Reward.type == CURRENCY.Gold) |
| | | { |
| | | AddItem($"{(int)list[i].Reward.type}"); |
| | | } |
| | | else |
| | | { |
| | | for (int j = 0; j < list[i].Reward.count; ++j) |
| | | { |
| | | AddItem($"{(int)list[i].Reward.type}_{list[i].Reward.id}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void AddItem(string resId) |
| | | { |
| | | GameObject item = Instantiate(ItemPrefab); |
| | | EndlessPropIcon propIcon = item.GetComponent<EndlessPropIcon>(); |
| | | string resId = list[i].Reward.id == 0 ? resId = $"{(int)list[i].Reward.type}" : $"{list[i].Reward.type}_{list[i].Reward.id}"; |
| | | |
| | | Sprite iconSp = Resources.Load<Sprite>($"{iconPath}{resId}"); |
| | | Sprite bgSp = Resources.Load<Sprite>($"{bgPath}{resId}"); |
| | |
| | | propIcon.SetIcon(iconSp); |
| | | propIcon.SetBg(bgSp); |
| | | item.transform.SetParent(Grid.transform, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | private void NewbieGuideEnd() |
| | | { |
| | | EndlessLevelManager.instance.RestartWave(); |
| | | GameConfig.IsNewbieGuideCompleted = true; |
| | | GameConfig.IsNewbie = false; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | SetState(State.Normal); |
| | | // 新的代码,合并升级为随机塔防类型. |
| | | randomUpgradeTower(); |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(TowerUpgradeEffectPrefab); |
| | | obj.transform.position = sTower.transform.position; |
| | | Vector3 pos = obj.transform.position; |
| | | pos.y += 5f; |
| | | obj.transform.position = pos; |
| | | ParticleSystem ps = obj.GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | PlaceGhost(pointer); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | GameObject effect = TowerUpgradeEffectPrefab; |
| | | |
| | | if (newTower.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | string path = $"UI/ToBattle_{newTower.attributeId}"; |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | effect = Instantiate(prefab); |
| | | } |
| | | |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(effect); |
| | | obj.transform.position = newTower.transform.position; |
| | | Vector3 pos = obj.transform.position; |
| | | pos.y += 5f; |
| | | obj.transform.position = pos; |
| | | ParticleSystem ps = obj.GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <exception cref="InvalidOperationException"> |
| | | /// Throws exception if not in Build State or <see cref="m_CurrentTower"/> is not at a valid position |
| | | /// </exception> |
| | | public void PlaceTower(int lvl = 0, bool opponent = false) |
| | | public void PlaceTower(int lvl = 0, bool isUpgrade = false, bool opponent = false) |
| | | { |
| | | if (!isBuilding) |
| | | throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); |
| | |
| | | // River: 内部缓存数据,用于后期容易找到数据. |
| | | addTower(createdTower); |
| | | CancelGhostPlacement(); |
| | | if (!isUpgrade) |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | else |
| | | PlayUpgradeEffect(createdTower); |
| | | |
| | | // 处理成长骰子,复制骰子等等功能. |
| | | if (lvl == 0) |
| | |
| | | /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 |
| | | /// </summary> |
| | | /// <param name="tow"></param> |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1) |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false) |
| | | { |
| | | // 获取IPlaceArea. |
| | | if (m_CurrentArea == null) |
| | |
| | | OnSuccessBuyTower(); |
| | | SetState(State.Building); |
| | | |
| | | PlaceTower(lvl); |
| | | PlaceTower(lvl, isUpgrade); |
| | | } |
| | | |
| | | return true; |
| | |
| | | targetTower = getTowerByName(tname); |
| | | |
| | | // River: 随机找一个空白位置放置塔防。 |
| | | EndlessGameUI.instance.RandomPlaceTower(targetTower, x, y, lvl); |
| | | EndlessGameUI.instance.RandomPlaceTower(targetTower, x, y, lvl, -1, true); |
| | | } |
| | | } |
| | |
| | | //UpgradeSelectedTower(); |
| | | // 新的代码,合并升级为随机塔防类型. |
| | | randomUpgradeTower(); |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(TowerUpgradeEffect); |
| | | obj.transform.position = sTower.transform.position; |
| | | Vector3 pos = obj.transform.position; |
| | | pos.y += 5f; |
| | | obj.transform.position = pos; |
| | | ParticleSystem ps = obj.GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | PlaceGhost(pointer); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | GameObject effect = TowerUpgradeEffect; |
| | | |
| | | if (newTower.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | string path = $"UI/ToBattle_{newTower.attributeId}"; |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | effect = Instantiate(prefab); |
| | | } |
| | | |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(effect); |
| | | obj.transform.position = newTower.transform.position; |
| | | Vector3 pos = obj.transform.position; |
| | | pos.y += 5f; |
| | | obj.transform.position = pos; |
| | | ParticleSystem ps = obj.GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <exception cref="InvalidOperationException"> |
| | | /// Throws exception if not in Build State or <see cref="m_CurrentTower"/> is not at a valid position |
| | | /// </exception> |
| | | public void PlaceTower(int lvl = 0, bool opponent = false) |
| | | public void PlaceTower(int lvl = 0, bool opponent = false, bool isUpgrade = false) |
| | | { |
| | | if (!isBuilding) |
| | | throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); |
| | |
| | | addTower(createdTower); |
| | | |
| | | CancelGhostPlacement(); |
| | | |
| | | if (!opponent) |
| | | { |
| | | if (!isUpgrade) |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | else |
| | | PlayUpgradeEffect(createdTower); |
| | | } |
| | | |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | |
| | |
| | | /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 |
| | | /// </summary> |
| | | /// <param name="tow"></param> |
| | | public void RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0) |
| | | public void RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, bool isUpgrade = false) |
| | | { |
| | | // 获取IPlaceArea. |
| | | if (m_CurrentArea == null) |
| | |
| | | OnSuccessBuyTower(); |
| | | SetState(State.Building); |
| | | |
| | | PlaceTower(lvl); |
| | | PlaceTower(lvl, false, isUpgrade); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // River: 随机找一个空白位置放置塔防。 |
| | | GameUI.instance.RandomPlaceTower(targetTower, x, y, lvl); |
| | | GameUI.instance.RandomPlaceTower(targetTower, x, y, lvl, true); |
| | | return; |
| | | } |
| | | } |