| | |
| | | /// </summary> |
| | | TowerPlacementGhost m_CurrentTower; |
| | | |
| | | public bool HasTower{ |
| | | get{ |
| | | return m_CurrentTower!=null; |
| | | public bool HasTower |
| | | { |
| | | get |
| | | { |
| | | return m_CurrentTower != null; |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | public GameObject TowerAppearEffectPrefab; |
| | | |
| | | //首次购买宝石特效 |
| | | public GameObject fireAppearEffect1; |
| | | public GameObject fireAppearEffect2; |
| | | |
| | | public GameObject waterAppearEffect1; |
| | | public GameObject waterAppearEffect2; |
| | | public GameObject woodAppearEffect1; |
| | | public GameObject woodAppearEffect2; |
| | | /// <summary> |
| | | /// 保存所有生成或合成的塔的最小等级,索引0 -> 火木水塔 索引1 -> 技能塔 |
| | | /// </summary> |
| | |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | GameObject effect = TowerUpgradeEffectPrefab; |
| | | newTower.currentTowerLevel.PlayUpGradeEffect(); |
| | | // GameObject effect = TowerUpgradeEffectPrefab; |
| | | |
| | | if (newTower.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | string path = $"UI/ToBattle_{newTower.attributeId}"; |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | effect = Instantiate(prefab); |
| | | } |
| | | // 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>(); |
| | | // // 在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); |
| | | // 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 isUpgrade = false, bool opponent = false) |
| | | public void PlaceTower(int lvl = 0, bool isUpgrade = false, bool opponent = false, bool isFirstAppear = false) |
| | | { |
| | | if (!isBuilding) |
| | | throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); |
| | |
| | | // River: 内部缓存数据,用于后期容易找到数据. |
| | | addTower(createdTower); |
| | | CancelGhostPlacement(); |
| | | if (!isUpgrade) |
| | | if (isFirstAppear) |
| | | { |
| | | PlayFirstAppearEffect(createdTower.towerName, createdTower.transform.position); |
| | | } |
| | | else if (!isUpgrade) |
| | | { |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | } |
| | | else |
| | | { |
| | | PlayUpgradeEffect(createdTower); |
| | | } |
| | | |
| | | // 处理成长骰子,复制骰子等等功能. |
| | | if (lvl == 0) |
| | | { |
| | | ProcessFeatureTower(createdTower); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放首次宝石出现特效 |
| | | /// </summary> |
| | | public void PlayFirstAppearEffect(string towerName, Vector3 worldPos) |
| | | { |
| | | if (towerName.StartsWith("GrowUpTower")) |
| | | { |
| | | //火元素 |
| | | PlayAppearEffect(worldPos, fireAppearEffect1); |
| | | PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | if (Application.platform == RuntimePlatform.WindowsEditor) |
| | | { |
| | | //UnityEditor.EditorApplication.isPaused = true; |
| | | } |
| | | } |
| | | else if (towerName.StartsWith("BlinkTower")) |
| | | { |
| | | //木元素 |
| | | PlayAppearEffect(worldPos, woodAppearEffect1); |
| | | PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | |
| | | } |
| | | else if (towerName.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | PlayAppearEffect(worldPos, waterAppearEffect1); |
| | | PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | } |
| | | } |
| | | void PlayAppearEffect(Vector3 worldPos, GameObject prefab) |
| | | { |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.position = worldPos; |
| | | 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> |
| | |
| | | if (placeObj != null) |
| | | { |
| | | m_CurrentArea = placeObj.GetComponent<IPlacementArea>(); |
| | | dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; |
| | | dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; |
| | | } |
| | | placeObj = GameObject.FindGameObjectWithTag("PlaceTowerOpponent"); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessHeartAllLose, AllHeartLose); |
| | |
| | | /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 |
| | | /// </summary> |
| | | /// <param name="tow"></param> |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false) |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false, bool isFirstAppear = false) |
| | | { |
| | | // 获取IPlaceArea. |
| | | if (m_CurrentArea == null) |
| | |
| | | OnSuccessBuyTower(); |
| | | SetState(State.Building); |
| | | |
| | | PlaceTower(lvl, isUpgrade); |
| | | PlaceTower(lvl, isUpgrade, false, isFirstAppear); |
| | | } |
| | | |
| | | return true; |
| | |
| | | { |
| | | base.Awake(); |
| | | |
| | | randomTowerBtn = transform.Find("BottomCanvas/Panel/TowerBuyBtn").GetComponent<Button>(); |
| | | DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10); |
| | | |
| | | state = State.Normal; |
| | | m_Camera = GetComponent<Camera>(); |
| | | m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | | //m_Camera = GetComponent<Camera>(); |
| | | TowerDestroyArr = new bool[5, AttackRowNumbers]; |
| | | } |
| | | |
| | |
| | | /// <param name="worldPos">世界坐标</param> |
| | | public void PlayToAttackEffect(int attributeId, Vector3 worldPos) |
| | | { |
| | | string path = $"UI/ToBattle_{attributeId}"; |
| | | string path = ""; |
| | | if (attributeId == 101) |
| | | { |
| | | path = "UI/Effect_Elf_Huo_DengChang_101"; |
| | | } |
| | | else if (attributeId == 105) |
| | | { |
| | | path = "UI/Effect_Elf_Shui_DengChang_105"; |
| | | } |
| | | else if (attributeId == 109) |
| | | { |
| | | path = "UI/Effect_Elf_Mu_DengChang_109"; |
| | | } |
| | | |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.position = worldPos; |