private void generateSkillsUI() { List <int> skill = GameEntityMgr.GetSelectedEntity()?.GetNowSkillSockets(); if (skill == null) { return; } int cnt = skill.Count; skillUI = new SkillUI[cnt]; for (int i = 0; i < cnt; i++) { GameObject skillUIGo = //poolRemote.CreatePrefab(SkillPrefabObj); PoolingSystem.Instance.GetOneClone_NotActive(prefab); Transform skillUIT = skillUIGo.transform; skillUIT.SetParent(this.transform); skillUIT.localScale = Vector3.one; skillUIT.localPosition = Vector3.zero; skillUIT.SetSiblingIndex(i); skillUI[i] = skillUIGo.GetComponent <SkillUI>(); //var data = xxxx int data = skill[i]; skillUI[i].SetModel(data); skillUIGo.SetActive(true); } GetComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.MinSize; }
private void Awake() { btnMember.onClick.AddListener(() => { if (showEntity.BeAlive()) { GameEntityMgr.SetSelectedEntity(showEntity); } }); Func <bool> loopOneSeconds = () => { if (showEntity == null) { return(true); } bool selected = GameEntityMgr.IsEntitySelected(showEntity.entityID); GameEntity gameEntity = GameEntityMgr.Instance.GetGameEntity(showEntity.entityID); selectedBg.SetActive(selected); EntityAnimStatus status = gameEntity.GetEntityVisual().Status; deathBg.SetActive(!gameEntity.BeAlive()); beMovingBg.SetActive(status == EntityAnimStatus.Run); beAttackBg.SetActive(status == EntityAnimStatus.Battle); return(true); }; GameTimer.AwaitLoopSecondsBaseOnCore(1, loopOneSeconds); }
IEnumerator playerUpdate() { while (!entityVisual.modelLoaded) { yield return(null); } while (BeAlive()) { pathSensor.TakeSample(this); if (pathSensor.IsDirty && pathSensor.Value) { currentPath?.Clear(); AcceptPathChange(); } if (currentPath == null || currentPath.Count == 0) { if (currentPath?.Count == 0) { currentPath = null; onReachDst(); entityVisual.SetAniStatus(EntityAnimStatus.Idle); if (GameEntityMgr.GetSelectedEntity() == this) { ShowEyeSight(); } } //yield return new WaitForSeconds(0.5f); yield return(new WaitForEndOfFrame()); } if (currentPath != null && currentPath.Count > 0) { if (controllRemote.PTiliMove(1)) { if (currentPath.Count == 1) { //yield return movefromApoint2Bpoint(currentPath[0], currentPath[0]); currentPath.RemoveAt(0); } else { ICell start = currentPath[0]; ICell next = currentPath[1]; yield return(movefromApoint2Bpoint(start, next)); currentPath.RemoveAt(0); } } else { currentPath.Clear(); } } } }
public void UpdateInfo() { GameEntityMgr instance = GameEntityMgr.Instance; if (instance == null) { return; } List <GameEntity> players = instance.GetAllPlayers(); }
internal void UpdateUI() { Skill sk = GameCore.GetRegistServices <BattleService>().GetSkillByID(skillID); if (sk != null) { text.text = "技能 " + GameCore.GetRegistServices <BattleService>().GetSkillByID(skillID).desc; } selectBg.SetActive(GameEntityMgr.GetSelectedEntity().GetControllRemote().SelectedSkillID == skillID && sk != null); }
void Start() { GameEntityMgr mgr = GameCore.GetRegistServices <GameEntityMgr>(); mgr.onEntitySelected += UpdateBattleUI; mgr.onSelectedEntityValueChange += (changeType) => { selectedRoleArea.UpdateInfo(); }; UpdateBattleUI(); }
private void onEntityDataChange(ValueChangeType changeType) { bool selected = GameEntityMgr.IsEntitySelected(showEntity.entityID); GameEntity gameEntity = GameEntityMgr.Instance.GetGameEntity(showEntity.entityID); selectedBg.SetActive(selected); EntityAnimStatus status = gameEntity.GetEntityVisual().Status; deathBg.SetActive(!gameEntity.BeAlive()); beAttackBg.SetActive(changeType == ValueChangeType.HPDown); beMovingBg.SetActive(status == EntityAnimStatus.Run); }
private void OnEnable() { deathBg.SetActive(false); selectedBg.SetActive(false); beAttackBg.SetActive(false); beMovingBg.SetActive(false); memberName.text = showEntity.GetEntityName(); GameEntityMgr mgr = GameEntityMgr.Instance; mgr.AddEntityRuntimeValueChangedListenerByEntityID(showEntity.entityID, onEntityDataChange); mgr.onEntitySelected += UpdateSelectEntity; }
void Start() { GameEntityMgr.Instance.onSelectedEntityValueChange += (eventType) => { if (eventType == ValueChangeType.AutoSkillChange) { foreach (SkillUI ui in skillUI) { ui.selectBg?.SetActive(GameEntityMgr.GetSelectedEntity().GetControllRemote().SelectedSkillID == ui.GetData()); } } }; }
void Start() { if (text == null) { text = transform.Find("Text").GetComponent <Text>(); } btnSelectSkill?.onClick.AddListener(() => { if (valid) { GameEntityMgr.GetSelectedEntity().SelectSkill(skillID); } }); }
public override void TakeSample(GameEntity _in) { if (overtime()) { GameEntityMgr mgrRemote = GameEntityMgr.Instance; if (_in.GetTargetEntity() == null) { GameEntity nearest = mgrRemote.GetNearestOpSideEntity(_in); if (nearest) { Value = nearest; } } } }
private void Start() { button2itemid.Add(s_item1.GetInstanceID(), 0); button2itemid.Add(s_item2.GetInstanceID(), 0); st_Daiji.onClick.AddListener(() => { doStrategy(GSNPCStrategy.Daiji); }); st_Jingjie.onClick.AddListener(() => { doStrategy(GSNPCStrategy.Jingjie); }); st_Autofight.onClick.AddListener(() => { doStrategy(GSNPCStrategy.AutoFight); }); st_BackToManual.onClick.AddListener(() => { GameEntityMgr.GetSelectedEntity()?.Back2Manual(); }); s_item1.onClick.AddListener(() => { startUseItem(button2itemid[s_item1.GetInstanceID()]); }); s_item2.onClick.AddListener(() => { startUseItem(button2itemid[s_item2.GetInstanceID()]); }); s_switchSkillList.onClick.AddListener(() => { GameEntity entity = GameEntityMgr.GetSelectedEntity(); if (entity == null) { return; } List <int> newSkills = entity.GetdifferentSkills(entity.GetNowSkillSockets()); entity.ChangeNowSkillSockets(newSkills); ScrollViewRemote remote = s_scroll.GetComponent <ScrollViewRemote>(); remote.UpdateUI(); }); }
public void FocusOnCurrentEntity() { GameEntityMgr e = GameCore.GetRegistServices <GameEntityMgr>(); if (e.SelectedEntity != null) { dest = e.SelectedEntity.CurrentPoint; applyView(); } else { GameEntity gameEntity = e.GetRandomAlivePlayerEntity(); if (gameEntity != null) { dest = gameEntity.CurrentPoint; applyView(); } } }
internal static void SpawnPlayer(EntityZhiye zhiye) { GameEntityMgr entityMgr = GetRegistServices <GameEntityMgr>(); int cnt = entityMgr.GetAllPlayers().Count; if (cnt >= ProjectConsts.MAXPLAYER_CONTROLL_ENTITY_CNT) { return; } string prefabname = "GameEntity"; GameObject prefab = Resources.Load <GameObject>(prefabname); GameObject clone = GameObject.Instantiate(prefab); GameEntity entity = clone.GetComponent <GameEntity>(); entity.SetEntityZhiyeConfig(zhiye); entity.SetControllType(EntityType.Player); entityMgr.RegEntity(clone.GetComponent <GameEntity>()); }
//用于快速切换玩家的自动状态 与 玩家操作 IEnumerator updateContainer() { yield return(null); while (BeAlive()) { if (runtimeSwitcher != null && runtimeSwitcher.MoveNext()) { yield return(runtimeSwitcher.Current); } else { yield return(null); } } entityVisual.PlayAnim(EntityAnimEnum.Death); yield return(new WaitForSeconds(3)); GameEntityMgr.Respawn(this); }
internal void UpdateInfo() { if (GameEntityMgr.Instance == null || this.gameObject.activeInHierarchy == false) { return; } GameEntity selected = GameEntityMgr.GetSelectedEntity(); if (selected != null) { nonePlayer.SetActive(false); ScrollViewRemote remote = s_scroll.GetComponent <ScrollViewRemote>(); remote.UpdateUI(); entityname.text = selected.GetEntityName(); hpSlider.value = selected.GetControllRemote().GetHPPer(); magicSlider.value = selected.GetControllRemote().GetMagicPer(); } else { nonePlayer.SetActive(true); } }
void initUniRxPrograming() { RX_LastMoveFrom = new Vector2ReactiveProperty(CurrentPoint); RX_LastMoveTo = new Vector2ReactiveProperty(CurrentPoint); RX_currentPoint = new Vector2ReactiveProperty(CurrentPoint); RX_LastClickCell.Subscribe(_ => { RX_targetEntity.Value = null; }); //如何过滤过快的点击切换路径? //假若RX_LastClickCell的输入频率是 0.3s 内来了 10个数据(玩家0.3s内点击了10个可以移动的地方) //则以最后一个数据为准作为通知 RX_LastClickCell.Throttle(TimeSpan.FromSeconds(0.2f)).Subscribe(_ => { RX_PathChanged.Value = true; }); RX_currentPoint.Subscribe(point => { mapController.SetStartPoint(Vector2Int.CeilToInt(point)); }); RX_LastMoveTo.Subscribe((to) => { m_Transform.LookAt(HexCoords.GetHexVisualCoords(Vector2Int.CeilToInt(to))); RX_moveFromA2BPer.Value = 0; RX_moveSpeed.Value = 1; }); RX_LastMoveTo.Buffer(RX_LastMoveTo.Where(point => point == RX_currentPoint.Value).Throttle(TimeSpan.FromSeconds(C_TimeToReachOnePoint))).Subscribe(_ => { RX_moveSpeed.Value = 0; }); #region 控制移动 RX_moveFromA2BPer.Skip(1).Subscribe(per => { entityVisual.Run2(); Vector3 fromVisualPos = Coords.PointToVisualPosition(Vector2Int.CeilToInt(RX_LastMoveFrom.Value)); Vector3 toVisualPos = Coords.PointToVisualPosition(Vector2Int.CeilToInt(RX_LastMoveTo.Value)); Vector3 v = Vector3.Lerp(fromVisualPos, toVisualPos, RX_moveFromA2BPer.Value); m_Transform.position = v; //float near_start_or_near_dst = -0.5f + per; if (per >= 0.5f) { RX_currentPoint.Value = RX_LastMoveTo.Value; } else { RX_currentPoint.Value = RX_LastMoveFrom.Value; } }); var idle = RX_moveSpeed.Where(speed => speed == 0); var confused = idle.Where(_ => { return(false); }); idle.Subscribe(_ => { entityVisual.Idle2(); }); #endregion //0 0.5 0.9 1 1 1 0 0.6 1 -> 0 0.5 0.9 1 0 0.6 1 RX_reachFragment = RX_moveFromA2BPer.DistinctUntilChanged(); RX_reachFragment.Subscribe(_ => { //Debug.Log(_); }); RX_reachFragment.Where(per => per == 1).Subscribe(_ => { RXEnterCellPoint(Vector2Int.CeilToInt(RX_currentPoint.Value)); } ); RX_moveFromA2BPer.Buffer(RX_moveFromA2BPer.Where(per => per == 1).Throttle(TimeSpan.FromSeconds(0.3f))) .Where(buffer => GameCore.GetGameStatus() == GameStatus.Run && buffer.Count >= 2).Subscribe(_ => { if (GameEntityMgr.GetSelectedEntity() == this) { ShowEyeSight(); } }); RX_PathChanged.Where(changed => changed).Subscribe(_ => { //allowMove = false; RX_PathChanged.Value = false; Disposable_movementTimeLine?.Dispose(); IList <ICell> path = mapController.CalculatePath(); //Disposable_movementTimeLine = Observable.FromCoroutine(MoveM).Subscribe(unit => Disposable_movementTimeLine = Observable.FromCoroutine((tok) => MoveMS(path)).SelectMany(aftermove).Subscribe(); //RX_moveAlongPath(path, tellmeHowToMove(UseForClickCellMove)); //Disposable_movementTimeLine = Observable.EveryUpdate().CombineLatest(RX_reachFragment, (frame, per) => //{ // return per; //}).Where(per => per >= 1).Where(per => //{ // if (!controllRemote.PTiliMove(1)) // { // Disposable_movementTimeLine.Dispose(); // return false; // } // return true; //}).StartWith(1).Subscribe(h => //{ // Debug.Log("reach and show next fragment"); // if (path.Count > 1) // { // RX_LastMoveFrom.Value = path[0].Point; // RX_LastMoveTo.Value = path[1].Point; // path.RemoveAt(0); // } // else // { // Disposable_movementTimeLine.Dispose(); // } //}); //if (path.Count > 0) //{ // //转变为 (1-2)-(2-3)-(3-4)-(4-5)队列 // var rawPath = path.ToObservable<ICell>(); // var skipheader = rawPath.Skip(1); // var from_to_pathset = rawPath.Zip(skipheader, (raw, skip) => // { // return new FromAndTo(raw.Point, skip.Point); // }); // //要求路线按每隔 XXs 发出1个,其中第一段希望立即发出 这个时间没有基于gamecore状态 // var timeLine = Observable.EveryUpdate().CombineLatest(RX_reachFragment, (frame, per) => // { // return per; // }).Where(per => per == 1); // Disposable_movementTimeLine = timeLine.Subscribe(async (__) => // { // var s = await from_to_pathset.ToYieldInstruction(); // Debug.Log(__ + s.from.ToString() + " " + s.to); // RX_LastMoveFrom.Value = s.from; // RX_LastMoveTo.Value = s.to; // }); // Disposable_movementTimeLine = timeLine.StartWith(1).Zip(from_to_pathset, (time, from_to) => // { // return new { from_to = from_to, per = time }; // }).Where(zip => zip.per == 1).Do(zip => // { // Debug.Log("change next "); // var from_to = zip.from_to; // RX_LastMoveFrom.Value = from_to.from; // RX_LastMoveTo.Value = from_to.to; // }, // () => // { // }).Subscribe(); //} }); RX_alive.Value = BeAlive(); var onDeath = RX_alive.Where(alive => !alive); onDeath.Subscribe(_ => { Disposable_moveFromA2BPer.Dispose(); }, () => { }); //检测当前选中的玩家和第一个被点击的非玩家对象 var getFrameStream = Observable.EveryUpdate(); var selectEntityStream = getFrameStream.Select(_ => GameEntityMgr.GetSelectedEntity()); // 1 0 2 0 1 var onSelectEntityChangedStream = selectEntityStream.DistinctUntilChanged().Where(newEntity => newEntity != null); // 1 0 2 0 1 => 1 2 1 var selectEntityChooseNPCStream = RX_targetEntity.DistinctUntilChanged(); //1 0 2 onSelectEntityChangedStream.Subscribe(_ => { //Debug.Log(_.entityID); }); selectEntityChooseNPCStream.Subscribe(_ => { }); //选中玩家后,第一次选中不同的npc var rx_selectPlayer_then_npc = onSelectEntityChangedStream.CombineLatest(selectEntityChooseNPCStream, (frameDuringSelected, choosenpc) => { //int error = -1; //if (choosenpc == null) // return error; //if (choosenpc.BeAlive()) //{ // return choosenpc.entityID; //} //return error; return(choosenpc); }) /*.DistinctUntilChanged()*/.Where(combineResults => /*combineResults != -1*/ combineResults != null); rx_selectPlayer_then_npc.Subscribe(npc => { Debug.Log(npc.entityID); //move to entity then attack IList <ICell> path2reachEntity = mapController.GetPathFinder().FindPathOnMap(mapController.GetMap().GetCell(CurrentPoint), mapController.GetMap().GetCell(npc.CurrentPoint), mapController.GetMap()); ForgetMovement(); Disposable_movementTimeLine = Observable.FromCoroutine((tok) => MoveMS(path2reachEntity)).SelectMany(aftermove).Subscribe(); //RX_moveAlongPath(path2reachEntity, tellmeHowToMove(UseForBattleMove)); //Observable.FromCoroutine(playerAction2Entity).Subscribe(); }); var rx_selectPlayer_then_mapcell = getFrameStream.CombineLatest(RX_LastClickCell.DistinctUntilChanged(), (frameDuringSelected, selectPoint) => { return(selectPoint); }).DistinctUntilChanged(); rx_selectPlayer_then_mapcell.Subscribe(Cell => { //Debug.Log(Cell); }); }
public GameEntityMgr() : base() { Instance = this; }
private void UpdateSelectEntity() { bool selected = showEntity != null && GameEntityMgr.IsEntitySelected(showEntity.entityID); selectedBg.SetActive(selected); }
private void doStrategy(GSNPCStrategy strategy) { GameEntityMgr.GetSelectedEntity()?.ChangeAutoPlayStrategy(strategy); }