public void Backspace() { if (playerSpell.Length == 0) { return; } char lastCharacter = playerSpell[playerSpell.Length - 1]; playerSpell = playerSpell.Remove(playerSpell.Length - 1, 1); spellText.text = playerSpell.ToString(); Button characterButton = characterPool.GetInstance <Button>(characterModel.gameObject, characterContainer); characterButton.GetComponentInChildren <Text>().text = lastCharacter.ToString(); characterButton.onClick.RemoveAllListeners(); characterButton.onClick.AddListener(delegate { characterPool.AddInstanceToPool(characterButton.gameObject); playerSpell.Append(lastCharacter.ToString()); spellText.text = playerSpell.ToString(); }); }
/// <summary> /// 横向跳动文本动画(用于显示伤害文本动画) /// </summary> /// <param name="hurtString">Hurt string.</param> public void PlayHurtTextAnim(ExploreText et) { // 从缓存池获取文本模型 Text hurtText = exploreTextPool.GetInstance <Text> (exploreTextModel.gameObject, exploreTextContainer); // 伤害文本的原始位置 Vector3 originHurtPos = Vector3.zero; // 伤害文本的第一次跳动终点 Vector3 firstHurtPos = Vector3.zero; // 伤害文本的第二次跳动终点 Vector3 secondHurtPos = Vector3.zero; // 提示文本的原始位置【伤害可能附带暴击,闪避等提示文字】 Vector3 originTintPos = Vector3.zero; // 提示文本的终点位置【伤害可能附带暴击,闪避等提示文字】 Vector3 finalTintPos = Vector3.zero; // 下面设置文本的动画路径 switch (et.towards) { case MyTowards.Left: case MyTowards.Up: originHurtPos = et.basePosition + new Vector3(-50f, 50f, 0); firstHurtPos = originHurtPos + new Vector3(-Random.Range(80, 100), Random.Range(0, 10), 0); secondHurtPos = firstHurtPos + new Vector3(-Random.Range(20, 30), Random.Range(0, 2), 0); originTintPos = originHurtPos + new Vector3(-100f, 100f, 0); break; case MyTowards.Right: case MyTowards.Down: originHurtPos = et.basePosition + new Vector3(50f, 50f, 0); firstHurtPos = originHurtPos + new Vector3(Random.Range(80, 100), Random.Range(0, 10), 0); secondHurtPos = firstHurtPos + new Vector3(Random.Range(20, 30), Random.Range(0, 2), 0); originTintPos = originHurtPos + new Vector3(100f, 100f, 0); break; } hurtText.transform.localPosition = originHurtPos; hurtText.text = et.text; hurtText.GetComponentInChildren <Image>().enabled = false; hurtText.gameObject.SetActive(true); float firstJumpPower = Random.Range(100f, 120f); // 伤害文本跳跃动画 hurtText.transform.DOLocalJump(firstHurtPos, firstJumpPower, 1, 0.4f).OnComplete(() => { float secondJumpPower = Random.Range(20f, 30f); // 伤害文本二次跳跃 hurtText.transform.DOLocalJump(secondHurtPos, secondJumpPower, 1, 0.15f).OnComplete(() => { hurtText.text = ""; hurtText.gameObject.SetActive(false); exploreTextPool.AddInstanceToPool(hurtText.gameObject); }); }); }
public void RemoveBagItemAt(int itemIndexInBag) { int actualIndex = itemIndexInBag - minItemIndexOfCurrentBag; Transform removedItem = bagItemsContainer.GetChild(actualIndex); bagItemsPool.AddInstanceToPool(removedItem.gameObject); //AddSequenceItemsIfBagNotFull (); }
public override void AddToPool(InstancePool pool) { bc2d.enabled = false; //DisableAllDetect(); if (delayMoveCoroutine != null) { StopCoroutine(delayMoveCoroutine); } //StopCoroutine("DelayedMovement"); pool.AddInstanceToPool(this.gameObject); StopMoveImmidiately(); gameObject.SetActive(false); pool.AddInstanceToPool(this.gameObject); }
/// <summary> /// 战斗过程中如果遗忘技能,需要将该主动技能的按钮移除 /// </summary> public void RemoveActiveSkillButton(Skill skill) { for (int i = 0; i < activeSkillButtonContainer.childCount; i++) { ActiveSkillButton activeSkillButton = activeSkillButtonContainer.GetChild(i).GetComponent <ActiveSkillButton>(); if (activeSkillButton.skill.skillId == skill.skillId) { activeSkillButton.Reset(); activeSkillButtonPool.AddInstanceToPool(activeSkillButton.gameObject); } } // 移除技能按钮时要更新技能按钮的点击响应,因为响应方法中有一个序号参数需要更新 //(进入战斗初始化的时候按照技能顺序给按钮定了序号,点击时根据序号参数获得使用的是哪个技能,遗忘技能后该序号参数应该也更新一次) for (int i = 0; i < player.attachedActiveSkills.Count; i++) { ActiveSkill activeSkill = player.attachedActiveSkills[i]; ActiveSkillButton activeSkillButton = activeSkillButtonContainer.GetChild(i).GetComponent <ActiveSkillButton>(); int index = i; float coolenPercentage = activeSkillButton.mask.fillAmount; activeSkill.coolenPercentage = (int)(coolenPercentage * 100); activeSkillButton.SetUpActiveSkillButton(activeSkill, index, activeSkillButtonContainer); activeSkillButton.AddListener(OnActiveSkillButtonClick); } }
public IEnumerator SingleTextFloatAndDisappear(string tint) { Text tintText = tintTextPool.GetInstance <Text>(tintTextModel.gameObject, tintTextContainer); singleTextTints.Add(tintText); tintText.text = tint; tintText.color = Color.white; tintText.transform.localPosition = Vector3.zero; yield return(new WaitForSecondsRealtime(tintHUDStayDuration)); float timer = 0; float tintTextAlphaChangeSpeed = 1 / tintHUDFloatDuration; while (timer < tintHUDFloatDuration) { tintText.transform.localPosition = new Vector3(0, singleTintTextFloatSpeed * Time.unscaledDeltaTime, 0) + tintText.transform.localPosition; tintText.color = new Color(1, 1, 1, 1 - tintTextAlphaChangeSpeed * timer); timer += Time.unscaledDeltaTime; yield return(null); } tintTextPool.AddInstanceToPool(tintText.gameObject); singleTextTints.Remove(tintText); }
private IEnumerator BulletMoveWithMoveVectorAndRange(MyTowards towards, Vector2 range) { float distanceX = 0; float distanceY = 0; Vector3 moveVector = Vector3.zero; while (distanceX < range.x && distanceY < range.y) { switch (towards) { case MyTowards.Left: moveVector = new Vector3(-speed * Time.deltaTime, 0, 0); break; case MyTowards.Right: moveVector = new Vector3(speed * Time.deltaTime, 0, 0); break; case MyTowards.Up: moveVector = new Vector3(0, speed * Time.deltaTime, 0); break; case MyTowards.Down: moveVector = new Vector3(0, -speed * Time.deltaTime, 0); break; } this.transform.position += moveVector; distanceX += moveVector.x; distanceY += moveVector.y; // Debug.Log (this.transform.position); yield return(null); } // Debug.LogFormat("before : {0}",bulletAnimator.GetCurrentAnimatorClipInfo(0). // bulletAnimator.SetBool ("Play",false); bc2d.enabled = false; bulletPool.AddInstanceToPool(this.gameObject); }
public void QuitUnlockedItemsPlane() { for (int i = 0; i < unlockedItemsContainer.childCount; i++) { Transform unlockedItem = unlockedItemsContainer.GetChild(i); unlockedItem.Find("ItemIcon").GetComponent <Image> ().enabled = false; unlockedItemsPool.AddInstanceToPool(unlockedItem.gameObject); } }
public override void AddToPool(InstancePool pool) { // attachedItem = null; bc2d.enabled = false; gameObject.SetActive(false); pool.AddInstanceToPool(this.gameObject); }
/// <summary> /// 加入缓存池 /// </summary> /// <param name="pool">Pool.</param> public override void AddToPool(InstancePool pool) { StopMoveImmidiately(); if (delayMoveCoroutine != null) { StopCoroutine(delayMoveCoroutine); } DisableAllDetect(); isReadyToFight = false; HideAllAlertAreas(); bc2d.enabled = false; gameObject.SetActive(false); pool.AddInstanceToPool(this.gameObject); }
public void AddToPool(InstancePool pool) { this.boxCollider.enabled = false; this.gameObject.SetActive(false); int posX = Mathf.RoundToInt(oriPos.x); int posY = Mathf.RoundToInt(oriPos.y); ExploreManager.Instance.newMapGenerator.mapWalkableInfoArray[posX, posY] = 1; characterSmallDetect.SetBoxColliderEnable(false); pool.AddInstanceToPool(this.gameObject); }
public void UpdateCrystalHarvest(int totalCount) { Transform crystal = crystalPool.GetInstance <Transform> (crystalModel.gameObject, crystalContainer); crystal.localPosition = new Vector3(0, 450, 0); crystal.GetComponent <Image> ().enabled = true; Tween crystalMove = crystal.DOLocalMove(new Vector3(-445, 680, 0), 0.5f).OnComplete(delegate { crystal.GetComponent <Image> ().enabled = false; crystalPool.AddInstanceToPool(crystal.gameObject); crystalHarvestCount.text = totalCount.ToString(); }); crystalMove.SetUpdate(true); }
public void SetUpExploreCanvas() { rejectNewUI = false; wordRecords = GameManager.Instance.gameDataCenter.currentMapWordRecords; transitionMask.gameObject.SetActive(true); pauseHUD.InitPauseHUD(true, ConfirmQuitToHomeView, null, null); wordHUD.InitWordHUD(true, QuitWordHUDCallBack, ChooseAnswerInWordHUDCallBack, ConfirmCharacterFillInWordHUDCallBack); creationView.ClearCharacterFragments(); if (!GameManager.Instance.UIManager.UIDic.ContainsKey("BagCanvas")) { GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.bagCanvasBundleName, "BagCanvas", null, false, true, false); } if (!GameManager.Instance.UIManager.UIDic.ContainsKey("NPCCanvas")) { GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.npcCanvasBundleName, "NPCCanvas", null, false, true, false); } gameLevelLocationText.text = string.Format("第{0}层", Player.mainPlayer.currentLevelIndex + 1); wordRecordText.text = string.Empty; if (wordRecords.Count > 0) { wordRecordText.text = wordRecords[wordRecords.Count - 1].spell; } bpUICtr.InitExploreAgentView(); bpUICtr.SetUpExplorePlayerView(Player.mainPlayer); bmUICtr.InitExploreAgentView(); GetComponent <Canvas>().enabled = true; transitionMask.color = Color.black; if (!Player.mainPlayer.isNewPlayer) { bool playerDataExist = DataHandler.FileExist(CommonData.playerDataFilePath); if (!playerDataExist) { GameManager.Instance.persistDataManager.SaveCompletePlayerData(); } transitionMask.gameObject.SetActive(false); //if (hasResetGame) //{ // //GameManager.Instance.persistDataManager.ResetPlayerDataToOriginal(); // transitionView.PlayTransition(TransitionType.ResetGameHint, delegate // { // transitionMask.gameObject.SetActive(false); // }); //} } else { ExploreManager.Instance.MapWalkableEventsStopAction(); transitionMask.gameObject.SetActive(true); TransitionType transitionType = GameManager.Instance.persistDataManager.versionUpdateWhenLoad ? TransitionType.VersionUpdate : TransitionType.Introduce; transitionView.PlayTransition(transitionType, delegate { GameManager.Instance.persistDataManager.versionUpdateWhenLoad = false; GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.guideCanvasBundleName, "GuideCanvas", delegate { TransformManager.FindTransform("GuideCanvas").GetComponent <GuideViewController>().ShowNewPlayerGuide(delegate { ExploreManager.Instance.MapWalkableEventsStartAction(); }); }); transitionMask.gameObject.SetActive(false); }); } creationView.InitCharacterFragmentsHUD(SetUpSpellItemView); //wordRecords.Clear(); miniCameraSize = TransformManager.FindTransform("MiniMapCamera").GetComponent <Camera>().orthographicSize; LoadMiniMapTexture(); UpdateMiniMapDisplay(ExploreManager.Instance.battlePlayerCtr.transform.position); if (Player.mainPlayer.currentLevelIndex < CommonData.maxLevelIndex) { for (int i = 0; i < monstersInfoWithDisplayUI.Count; i++) { Transform monsterUI = monstersInfoWithDisplayUI[i].monsterUI; monsterUIPool.AddInstanceToPool(monsterUI.gameObject); } monstersInfoWithDisplayUI.Clear(); GetMonstersDataAndUI(); monstersDisplayView.InitMonsterDisplayView(monstersInfoWithDisplayUI); monsterUIPool.ClearInstancePool(); } }
public override void AddToPool(InstancePool pool) { pool.AddInstanceToPool(this.gameObject); }
public void RemoveBagItemAt(int itemIndexInBag) { bagItemsPool.AddInstanceToPool(bagItemsContainer.GetChild(itemIndexInBag - minItemIndexOfCurrentBag).gameObject); AddSequenceItemsIfBagNotFull(); }
public void AddToPool(InstancePool pool) { boxCollider.enabled = false; gameObject.SetActive(false); pool.AddInstanceToPool(this.gameObject); }
public override void AddToPool(InstancePool pool) { bc2d.enabled = false; pool.AddInstanceToPool(this.gameObject); }
// 受到伤害文本动画 public void PlayHurtTextAnim(FightText ft) { // 从缓存池获取文本模型 Text hurtText = fightTextPool.GetInstance <Text> (fightTextModel.gameObject, fightTextContainer); Vector3 originHurtPos = Vector3.zero; Vector3 firstHurtPos = Vector3.zero; Vector3 secondHurtPos = Vector3.zero; Vector3 originTintPos = Vector3.zero; Vector3 finalTintPos = Vector3.zero; switch (direction) { case MyTowards.Left: originHurtPos = basePosition + new Vector3(-50f, 50f, 0); firstHurtPos = originHurtPos + new Vector3(-Random.Range(80, 100), Random.Range(0, 10), 0); secondHurtPos = firstHurtPos + new Vector3(-Random.Range(20, 30), Random.Range(0, 2), 0); originTintPos = originHurtPos + new Vector3(-100f, 100f, 0); break; case MyTowards.Right: originHurtPos = basePosition + new Vector3(50f, 50f, 0); firstHurtPos = originHurtPos + new Vector3(Random.Range(80, 100), Random.Range(0, 10), 0); secondHurtPos = firstHurtPos + new Vector3(Random.Range(20, 30), Random.Range(0, 2), 0); originTintPos = originHurtPos + new Vector3(100f, 100f, 0); break; } hurtText.transform.localPosition = originHurtPos; hurtText.text = string.Format("<b>{0}</b>", ft.text); hurtText.gameObject.SetActive(true); // 根据效果类型播放效果文本动画 switch (ft.specialResult) { case SpecialAttackResult.None: break; case SpecialAttackResult.Crit: string tintStr = "<color=red>暴击</color>"; PlayTintTextAnim(tintStr, originTintPos); break; case SpecialAttackResult.Miss: tintStr = "<color=gray>Miss</color>"; PlayTintTextAnim(tintStr, originTintPos); return; } float firstJumpPower = Random.Range(100f, 120f); // 伤害文本跳跃动画 hurtText.transform.DOLocalJump(firstHurtPos, firstJumpPower, 1, 0.35f).OnComplete(() => { float secondJumpPower = Random.Range(20f, 30f); // 伤害文本二次跳跃 hurtText.transform.DOLocalJump(secondHurtPos, secondJumpPower, 1, 0.15f).OnComplete(() => { hurtText.text = ""; hurtText.gameObject.SetActive(false); fightTextPool.AddInstanceToPool(hurtText.gameObject); }); }); }