private void Start() { if (AttackBtn) { AttackBtn.PointerDownEvent += (s, e) => Attack(); } // FluentText 初始化 FluentText.InitPanel(transform, FluentText.transform.position - transform.position); FluentText.ShowPanel(); FluentText.ChangeWord(FluentText.CurrentText); // 注册驱逐通知 TypeEventSystem.Register <MissionExpelledNotification>(OnExpelOne); // ResLoader Allocate resLoader = ResLoader.Allocate(); // 获取攻击动画时长 //if (Animator) { // AnimationClip[] clips = Animator.runtimeAnimatorController.animationClips; // foreach (AnimationClip clip in clips) { // if (clip.name == "Attack") { // attackDuration = clip.length; // break; // } // } //} }
// 构造聚会提示文字 private void InitPartyTipTexts() { partyTipTexts?.Clear(); partyTipTexts = new List <FluentTextController>(); GameObject empty = new GameObject("PartyTexts"); empty.transform.parent = transform; empty.transform.localPosition = Vector3.zero; foreach (EventPositions positions in Positions) { if (!positions.IsParty) { continue; } foreach (Vector3 pos in positions.Positions) { GameObject go = resLoader.LoadSync <GameObject>("FluentTextCanvas").Instantiate(); go.transform.SetParent(empty.transform); go.GetComponentsInChildren <Text>().ForEach(Text => { Text.fontSize = 120; Text.color = Color.red; }); FluentTextController fluentText = go.GetComponent <FluentTextController>(); fluentText.InitPanel(empty.transform, Vector3.zero); fluentText.ChangeWord("0"); //fluentText.ShowPanel(); fluentText.transform.localPosition = new Vector3(pos.x, 5, pos.z); partyTipTexts.Add(fluentText); } } }
private IEnumerator GO() { yield return(new WaitForSeconds(1f)); FluentText.ChangeWord(humanEvent.TipTexts[Random.Range(0, humanEvent.TipTexts.Length)]); FluentText.ShowPanel(); // Get target position and Move to target pos missionPos = App.Container.Resolve <LevelManager>().GetTargetPos(humanEvent.EventType); SwitchAgentObstacle(true); Agent.SetDestination(RandomNearPos(missionPos, Agent.stoppingDistance / 2)); while (!ArriveTarget()) { yield return(null); // 等待到下一帧 } SwitchAgentObstacle(false); // 到达指定地点后进行结算 if (humanEvent.IsParty) { var lookDir = missionPos - transform.position; lookDir.Set(lookDir.x, 0, lookDir.z); Quaternion q = Quaternion.LookRotation(lookDir); transform.rotation = q; // 播放动画 string anim = humanEvent.PartyAnimations[ Random.Range(0, humanEvent.PartyAnimations.Length)]; animator.PlayInFixedTime(anim, -1, 1f); // 告诉 Manager 自己到达某处聚集点 TypeEventSystem.Send(new PartyNotification(missionPos, transform)); yield return(new WaitForSeconds(2)); FluentText.HidePanel(); } else { ReportMission(done: true); Destroy(gameObject); } }
private void ShowNextWord() { TestCtrl.ChangeWord(Words[wordIndex]); wordIndex = (wordIndex + 1) % (Words.Length); }