public void CreateActor(ActorData actorData, Vector2 pos) { ResourceManager.Instance.LoadAsset("resourceassets/avatar.assetbundle", model => { GameObject actor = GameObject.Instantiate((GameObject)model.LoadAsset(System.IO.Path.GetFileNameWithoutExtension(actorData.cfgVo.ResName) + ".prefab")); actor.transform.position = new Vector3(pos.x, pos.y, 0); if ((ActorType)actorData.cfgVo.Type == ActorType.Player) { Player actorObject = actor.GetComponent <Player>(); actorObject.actorData = actorData; if (GameData.myData.uniqueId == actorData.uniqueId) { GameData.myself = actorObject; EventCenter.DispatchEvent(EventEnum.UpdateMainUIAttackBtn); CameraManager.Instance.Init(actorObject.transform); } } else { Monster actorObject = actor.GetComponent <Monster>(); actorObject.actorData = actorData; GameData.enemys.Add(actorObject); } }); }
private void Update() { if (Time.frameCount % 8 != 0) { return; } if (Vector2.Distance(transform.position, GameData.myself.transform.position) > 0.1f) { if (actionItem == this) { CancelAction(); } } else { if (actionItem == null || Vector2.Distance(actionItem.transform.position, GameData.myself.transform.position) > Vector2.Distance(transform.position, GameData.myself.transform.position)) { if (actionItem != null) { actionItem.CancelAction(); } actionItem = this; EventCenter.DispatchEvent(EventEnum.ActionEvent, new object[] { SceneEventType.PickUp, this }); } } }
private void Update() { if (Time.frameCount % 8 != 0) { return; } if (Vector2.Distance(transform.position, GameData.myself.transform.position) > 0.1f) { if (actionItem == this) { CancelAction(); } } else { if (actionItem == null || Vector2.Distance(actionItem.transform.position, GameData.myself.transform.position) > Vector2.Distance(transform.position, GameData.myself.transform.position)) { if (actionItem != null) { actionItem.CancelAction(); } actionItem = this; EventCenter.DispatchEvent(EventEnum.ActionEvent, new object[] { SceneEventType.NpcEvent, npcVo.EventType, npcVo.EventValue }); if (!string.IsNullOrEmpty(npcVo.Dialogue)) { EventCenter.DispatchEvent(EventEnum.ShowDialogue, new object[] { true, transform.position, LanguageManager.GetText(npcVo.Name), LanguageManager.GetText(npcVo.Bubble) }); } } } }
IEnumerator RunBallCoroutine(GolfPathInfo pathinfo) { if (pathinfo == null || pathinfo.ListPt == null || pathinfo.ListPt.Count == 0) { yield return(null); } for (int i = 0; i < pathinfo.ListPt.Count; i++) { GolfPathPoint golfPoint = pathinfo.ListPt[i]; if (golfPoint.Status == BallRunStatus.Roll) { if (golfPoint.BallType == BallType.OutHole) { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 2)); } else { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 0.5f)); } } else { yield return(Yielders.GetWaitForSeconds(golfPoint.Interval / 3)); } if (!string.IsNullOrEmpty(golfPoint.EventType)) { EventCenter.DispatchEvent(golfPoint.EventType, -1, golfPoint.EventParam); } SetBallPos(golfPoint.Position); BattleM.SetBallRunInfo(golfPoint.Position, golfPoint.AType, golfPoint.Status); } StopAllCoroutines(); }
/// <summary> /// 更新推杆参数 /// </summary> /// <param name="Param"></param> public static void SetRollOperation(BattingParam Param) { GolfPathInfo pathInfo = GetPath(Param); EventCenter.DispatchEvent(EventCenterType.Battle_DrawPath, -1, pathInfo); EventCenter.DispatchEvent(EventCenterType.Battle_PathCrossHole, -1, pathInfo.CheckCrossHole()); }
public override void CancelAction() { if (actionItem == this) { actionItem = null; EventCenter.DispatchEvent(EventEnum.ActionEvent, new object[] { SceneEventType.None }); } }
void GameInit() { #if UNITY_IOS Advertisement.Initialize("1740028"); #elif UNITY_ANDROID Advertisement.Initialize("1740027"); #endif EventCenter.DispatchEvent(EventEnum.GameInitOver); UIManager.Instance.OpenView(WindowKey.UIRoot); }
private void Update() { Vector = new Vector2(controlETCJoystick.axisX.axisValue, controlETCJoystick.axisY.axisValue); eventArgs = new JoyStickMovedEventArgs(Vector); if (eventArgs != null) { eventArgs.Vector = Vector; } EventCenter.DispatchEvent(eventArgs); }
private void GreenBall() { if (m_btnRing != null && m_kickBall != null) { m_btnRing.gameObject.SetActive(false); m_kickBall.gameObject.SetActive(false); } EventCenter.DispatchEvent(EventCenterType.Battle_SightView, -1, null); WndManager.CreateWnd <SwingModeWnd>(WndType.NormalWnd, false, false, null); }
private IEnumerator ClockCorotinue() { WaitForSeconds second = new WaitForSeconds(time); while (true) { yield return(second); EventCenter.DispatchEvent(eventArgs); } }
public override void CancelAction() { if (actionItem == this) { actionItem = null; EventCenter.DispatchEvent(EventEnum.ActionEvent, new object[] { SceneEventType.None }); if (!string.IsNullOrEmpty(npcVo.Dialogue)) { EventCenter.DispatchEvent(EventEnum.ShowDialogue, new object[] { false }); } } }
/// <summary> /// 窗口销毁时的清理动作 /// </summary> public virtual void OnDestroy() { AntiRegisterHooks(); if (m_blr != null) { m_blr.HideBlur(); } SoundManager.PlayMusic(m_PlayMusicID); if (TestMode == false) { EventCenter.DispatchEvent(EventCenterType.DialogEnd, -1, m_dialogID); } }
public override void TakeEffect(Entity entity) { Health health = entity.GetCapability <Health>(); if (health != null) { health.Value += Delta; if (Delta < 0 && entity.CompareTag("Enemies")) { EventCenter.DispatchEvent(evenArg); } } }
public static bool ProcessData(eMsgTypes Type, byte[] data, int index, int length) { object obj = protobufM.Deserialize(Type, data, index, length); if (obj == null) { return(false); } // 派发到DC中进行存储 DispatchEvent(Type, obj); // 派发消息用 EventCenter.DispatchEvent(Type, obj); return(true); }
private void RingDrag() { if (m_btnRing != null && m_kickBall != null) { m_btnRing.gameObject.SetActive(false); m_kickBall.gameObject.SetActive(true); } //if (m_objRing != null) //{ // m_objRing.SetActive(true); //} EventCenter.DispatchEvent(EventCenterType.Battle_SkyView, -1, null); WndManager.DestoryWnd <SwingModeWnd>(); }
/// <summary> /// 回合开始 /// </summary> /// <returns></returns> public static IEnumerator RoundStart(float waitTime) { g_Times++; m_SelfSel.SetStartPos(BallPos); if (BattleM.BallInAra != AreaType.PuttingGreen) { Vector3 PredictionPos = Path.CalcPredictionRingPos(GetFlyInput(null), BallPos); EventCenter.DispatchEvent(EventCenterType.Battle_UpdateRingPos, -1, PredictionPos); } EventCenter.DispatchEvent(EventCenterType.Battle_RoundStart, -1, null); yield return(Yielders.GetWaitForSeconds(waitTime)); // 先预测位置 if (BattleM.BallInAra != AreaType.PuttingGreen) { EventCenter.DispatchEvent(EventCenterType.Battle_ShowRing, -1, true); } }
private IEnumerator SpawnCorotinue() { StartCoroutine(WaveTipCorotinue(startInterval)); yield return(new WaitForSeconds(startInterval)); WaitForSeconds second = new WaitForSeconds(refreshInterval); int i = 0; float timer = 0; DataRow row = null; float time = 0; while (i < spawnTable.Rows.Count) { if (row == null) { row = spawnTable.Rows[i]; time = float.Parse(row["Time"] as string); } if (timer >= time) { string id = row["ID"] as string; Vector2 position = new Vector2(float.Parse(row["PositionX"] as string), float.Parse(row["PositionY"] as string)); SpawnEnemy(id, position); i++; row = null; } else { if (time - timer >= waveInterval && !inWaveTime) { StartCoroutine(WaveTipCorotinue(time - timer)); } } yield return(second); timer += refreshInterval; } EventCenter.DispatchEvent(new SpawnFinishedEventArgs(timer)); }
/// <summary> /// 发球 /// </summary> private static void RoundFireBall(object Param) { if (Param == null) { return; } BattingParam param = Param as BattingParam; GolfPathInfo pathInfo = GetPath(param); EventCenter.DispatchEvent(EventCenterType.Battle_BattingFinish, -1, pathInfo); EventCenter.DispatchEvent(EventCenterType.Battle_ShowRing, -1, false); m_SelfSel.SetBallSpeed(param.BattingSpeed); m_SelfSel.SetWindSpeed(param.WindSpeed); m_SelfSel.SetCurFBSpin(param.CurFBSpin); m_SelfSel.SetCurLRSpin(param.CurLRSpin); m_SelfSel.SetCurHookAngle(param.CurHookAngle); m_SelfSel.SetCurAccuracyOffset(param.CurAccuracyOffset); m_SelfSel.SetResultPos(pathInfo.GetRuseltPos()); BattleOperateInfo v = new BattleOperateInfo(m_SelfSel); AddBattleOperate(true, g_Times, v); }
private void Start() { RegisterHooks(); ShowBall = transform.Find("Ball").gameObject; EventCenter.DispatchEvent(EventCenterType.Battle_LoadBallFinish, -1, transform); }
void Update() { clickRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (!s_check) { if (!isMouseDown) { if (Application.isMobilePlatform && Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(i).fingerId) && (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.layer == uiLayerMask)) { m_isClickUi = true; break; } } } else if (EventSystem.current.IsPointerOverGameObject() && (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.layer == uiLayerMask)) { m_isClickUi = true; } if (Input.GetMouseButtonDown(0) && !m_isClickUi) { Physics.Raycast(clickRay, out clickPoint); if (clickPoint.collider != null && clickPoint.collider.gameObject.layer == uiLayerMask) { return; } isMouseDown = true; orginMousePosition = Input.mousePosition; } } if (isMouseDown) { if (Input.GetMouseButton(0)) { Vector3 dir = Input.mousePosition - orginMousePosition; if (dir.magnitude > 0.5f) { //Debug.Log("Input.mousePosition:" + Input.mousePosition + "orginMousePosition:" + orginMousePosition + "dir:" + dir); EventCenter.DispatchEvent(EventCenterType.Battle_DragMapMoveCamera, -1, dir); } } if (Input.GetMouseButtonUp(0)) { isMouseDown = false; orginMousePosition = Vector3.zero; } } if (Input.GetAxis("Mouse ScrollWheel") != 0) { EventCenter.DispatchEvent(EventCenterType.Battle_ScaleMapMoveCamera, -1, Input.GetAxis("Mouse ScrollWheel")); } } }