private IEnumerator showBuildAnimation(int index, int level, bool isRepair, System.Action onComplate = null) { //yield return new WaitForSeconds(0.5f); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.building_upgrade); buildingAnimation.transform.position = islandFactory.GetBuildTransform(index).position; islandFactory.HideBuild(index); buildingAnimation.SetActive(true); yield return(new WaitForSeconds(1)); buildingAnimation.SetActive(false); BuildingData bd = new BuildingData(); bd.level = level; bd.status = 0; islandFactory.UpdateBuildingData(index, bd); islandFactory.ShowBuild(index); EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.Money, 0)); if (!isRepair) { EventDispatcher.instance.DispatchEvent(new GetStarPosEvent((pos) => { star.transform.position = islandFactory.GetBuildTransform(index).position; star.SetActive(true); Sequence sq = DOTween.Sequence(); sq.Append((star.transform as RectTransform).DOAnchorPos(new Vector2(0, 30), 0.3f).SetRelative().SetEase(Ease.OutCubic)); sq.Append((star.transform as RectTransform).DOAnchorPos(new Vector2(0, -30), 0.7f).SetRelative().SetEase(Ease.OutBounce)); sq.Append(star.transform.DOMove(pos, 1).SetEase(Ease.InCubic)); sq.OnComplete(() => { star.SetActive(false); EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.star, 0)); }); })); } if (onComplate != null) { yield return(new WaitForSeconds(2)); onComplate(); } }
private void Attack(int index, AttackData data) { RectTransform target = island.GetBuildTransform(index); aimIcon.transform.position = target.position; aimIcon.gameObject.SetActive(true); aimIcon.color = new Color(aimIcon.color.r, aimIcon.color.g, aimIcon.color.b, 0); boomAnimation.position = target.position; (boomAnimation as RectTransform).anchoredPosition += new Vector2(0, 80); particSys.anchoredPosition3D = target.anchoredPosition3D + new Vector3(0, 0, -100); shell.position = artillery.position; shell.localScale = new Vector3(1.3f, 1.3f, 1); float angle = Vector2.Angle(new Vector2(0, 1), target.position - artillery.position); if ((target.position - artillery.position).x > 0) { angle = angle * -1; } string tips = ""; if (!data.isShielded && !data.isMiniShielded) { if (data.attackTarget.buildings[index - 1].status == 2) { tips = string.Format("恭喜您,您成功摧毁了<#1995BCFF>{0}</color>的{2},获得了<#D34727FF>{1}</color>金币", data.attackTarget.name, GameUtils.GetShortMoneyStr(data.reward), GameMainManager.instance.configManager.islandConfig.GetBuildingName(index - 1)); } else { tips = string.Format("恭喜您,您成功损坏了<#1995BCFF>{0}</color>的{2},获得了<#D34727FF>{1}</color>金币", data.attackTarget.name, GameUtils.GetShortMoneyStr(data.reward), GameMainManager.instance.configManager.islandConfig.GetBuildingName(index - 1)); } GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_aim_target); Sequence sq = DOTween.Sequence(); sq.Append(artillery.DORotate(new Vector3(0, 0, angle), 0.5f)); sq.Insert(0, aimIcon.DOFade(1, 1)); sq.Insert(0, aimIcon.rectTransform.DOShakeAnchorPos(2, 30)); sq.AppendCallback(() => { aimIcon.gameObject.SetActive(false); shell.gameObject.SetActive(true); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_fire); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_bomb_fly); }); sq.Append(shell.transform.DOMove(target.position, 1).SetEase(Ease.OutBack)); sq.Insert(2, shell.transform.DOScale(new Vector3(0.5f, 0.5f, 1), 1).SetEase(Ease.OutQuad)); sq.AppendCallback(() => { GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_boob_explode); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.wheel_gold_med); shell.gameObject.SetActive(false); boomAnimation.gameObject.SetActive(true); particSys.gameObject.SetActive(true); island.UpdateBuildingData(index, data.attackTarget.buildings[index - 1]); EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.Money, 0)); }); sq.Insert(4.5f, DOTween.To(() => artillery.anchoredPosition, x => artillery.anchoredPosition = x, new Vector2(0, -250), 0.5f)); sq.InsertCallback(4.5f, () => { GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.panel_in); //GameMainManager.instance.uiManager.OpenPopupModalBox(tips, "", OnClickOkBtn); Alert.ShowPopupBox(tips, OnClickOkBtn); }); sq.AppendCallback(() => { boomAnimation.gameObject.SetActive(false); particSys.gameObject.SetActive(false); }); } else { tips = string.Format("您的攻击被<#1995BCFF>{0}</color>的盾牌阻挡了,获得了<#D34727FF>{1}</color>金币", data.attackTarget.name, GameUtils.GetShortMoneyStr(data.reward)); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_aim_target); Sequence sq = DOTween.Sequence(); sq.Append(artillery.DORotate(new Vector3(0, 0, angle), 0.5f)); sq.Insert(0, aimIcon.DOFade(1, 1)); sq.Insert(0, aimIcon.rectTransform.DOShakeAnchorPos(2, 30)); sq.AppendCallback(() => { aimIcon.gameObject.SetActive(false); shell.gameObject.SetActive(true); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_fire); GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_bomb_fly); }); sq.Append(shell.transform.DOMove(target.position, 1).SetEase(Ease.OutBack)); sq.Insert(2, shell.transform.DOScale(new Vector3(0.5f, 0.5f, 1), 1).SetEase(Ease.OutQuad)); sq.AppendCallback(() => { GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.shoot_hit_sheild); shield.gameObject.SetActive(true); particSys.gameObject.SetActive(true); EventDispatcher.instance.DispatchEvent(new UpdateBaseDataEvent(UpdateBaseDataEvent.UpdateType.Money, 0)); }); Debug.Log(target.position); sq.Append(shell.DOAnchorPos(new Vector2(target.position.x > 0?250:-350, -300), 1).SetRelative(true)); sq.AppendCallback(() => { shell.gameObject.SetActive(false); particSys.gameObject.SetActive(false); }); sq.Insert(4.5f, DOTween.To(() => artillery.anchoredPosition, x => artillery.anchoredPosition = x, new Vector2(0, -250), 0.5f)); sq.InsertCallback(5, () => { GameMainManager.instance.audioManager.PlaySound(AudioNameEnum.panel_in); //GameMainManager.instance.uiManager.OpenPopupModalBox(tips, "", OnClickOkBtn); Alert.ShowPopupBox(tips, OnClickOkBtn); }); sq.onComplete += () => { shell.gameObject.SetActive(false); }; } }