コード例 #1
0
ファイル: SceneManager.cs プロジェクト: ccylovemm/Discovery
 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);
         }
     });
 }
コード例 #2
0
ファイル: DropItem.cs プロジェクト: ccylovemm/Discovery
    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 });
            }
        }
    }
コード例 #3
0
 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) });
             }
         }
     }
 }
コード例 #4
0
ファイル: GolfBall.cs プロジェクト: 741645596/Golf
 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();
 }
コード例 #5
0
        /// <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());
        }
コード例 #6
0
ファイル: DropItem.cs プロジェクト: ccylovemm/Discovery
 public override void CancelAction()
 {
     if (actionItem == this)
     {
         actionItem = null;
         EventCenter.DispatchEvent(EventEnum.ActionEvent, new object[] { SceneEventType.None });
     }
 }
コード例 #7
0
ファイル: StartUp.cs プロジェクト: ccylovemm/Discovery
    void GameInit()
    {
#if UNITY_IOS
        Advertisement.Initialize("1740028");
#elif UNITY_ANDROID
        Advertisement.Initialize("1740027");
#endif
        EventCenter.DispatchEvent(EventEnum.GameInitOver);
        UIManager.Instance.OpenView(WindowKey.UIRoot);
    }
コード例 #8
0
ファイル: JoyStick.cs プロジェクト: auutesius/NotionWorld
 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);
 }
コード例 #9
0
ファイル: BattleMainWnd.cs プロジェクト: 741645596/Golf
 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);
 }
コード例 #10
0
    private IEnumerator ClockCorotinue()
    {
        WaitForSeconds second = new WaitForSeconds(time);

        while (true)
        {
            yield return(second);

            EventCenter.DispatchEvent(eventArgs);
        }
    }
コード例 #11
0
 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 });
         }
     }
 }
コード例 #12
0
 /// <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);
     }
 }
コード例 #13
0
        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);
                }
            }
        }
コード例 #14
0
ファイル: DataCenter.cs プロジェクト: 741645596/Golf
        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);
        }
コード例 #15
0
ファイル: BattleMainWnd.cs プロジェクト: 741645596/Golf
    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>();
    }
コード例 #16
0
        /// <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);
            }
        }
コード例 #17
0
ファイル: EnemySpawner.cs プロジェクト: auutesius/NotionWorld
    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));
    }
コード例 #18
0
        /// <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);
        }
コード例 #19
0
ファイル: GolfBall.cs プロジェクト: 741645596/Golf
 private void Start()
 {
     RegisterHooks();
     ShowBall = transform.Find("Ball").gameObject;
     EventCenter.DispatchEvent(EventCenterType.Battle_LoadBallFinish, -1, transform);
 }
コード例 #20
0
ファイル: RingDrag.cs プロジェクト: 741645596/Golf
    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"));
            }
        }
    }