Exemple #1
0
        private void OnResourceUpdateSuccessGameEvent(GameEventBase gameEventBase)
        {
            ResourceUpdateSuccessGameEvent resourceUpdateSuccessGameEvent = (ResourceUpdateSuccessGameEvent)gameEventBase;

            Debug.Log(resourceUpdateSuccessGameEvent.Name + "更新成功!");
            //todo
        }
        private void OnMove(GameEventBase gameEventBase)
        {
            InputMoveGameEvent inputMoveGameEvent = (InputMoveGameEvent)gameEventBase;

            switch (inputMoveGameEvent.MoveDir)
            {
            case MoveDir.Left:
                GameEntry.Camera.SetCameraRotate(0, inputMoveGameEvent.Speed);
                break;

            case MoveDir.Right:
                GameEntry.Camera.SetCameraRotate(1, inputMoveGameEvent.Speed);
                break;

            case MoveDir.Up:
                GameEntry.Camera.SetCameraUpAndDown(1);
                break;

            case MoveDir.Down:
                GameEntry.Camera.SetCameraUpAndDown(0);
                break;
            }
            Vector3 targetDir = deltaVec;

            targetDir = targetDir.GetRotateY(GameEntry.Camera.MainCamera.transform.eulerAngles.y);

            m_MoveComponent.ChangeSetInputMoveDirection(targetDir);
        }
        /// <summary>
        /// 技能攻击点击
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnSkillButtonClick(GameEventBase gameEventBase)
        {
            SkillButtonClickGameEvent skillButtonClickGameEvent = (SkillButtonClickGameEvent)gameEventBase;

            ActiveSkillComponent    activeSkillComponent    = Owner.GetUnitComponent <ActiveSkillComponent>();
            CharacterStateComponent characterStateComponent = Owner.GetUnitComponent <CharacterStateComponent>();

            if (activeSkillComponent == null || characterStateComponent == null)
            {
                return;
            }

            //无法控制状态
            if (characterStateComponent.Get(SpecialStateType.NotInControl))
            {
                return;
            }

            if (skillButtonClickGameEvent.IsNormalClick)
            {
                //skillButtonClickGameEvent.SkillId;
                Debug.Log("原地放技能");
                activeSkillComponent.Verify(skillButtonClickGameEvent.SkillId, (PlayerBase)Owner, null, Trigskill, null, Complate);
            }
            else
            {
                Vector3 targetDir = new Vector3(skillButtonClickGameEvent.Postion.x, 0, skillButtonClickGameEvent.Postion.y);
                targetDir = targetDir.GetRotateY(GameEntry.Camera.MainCamera.transform.eulerAngles.y);
                Owner.SelfTransform.rotation = Quaternion.LookRotation(targetDir);
                Debug.Log("改变方向放技能");
                activeSkillComponent.Verify(skillButtonClickGameEvent.SkillId, (PlayerBase)Owner, null, Trigskill, null, Complate);
            }
        }
Exemple #4
0
        /// <summary>
        /// 读取Assetbundle资源文件回调事件
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void LoadAssetFileCallBack(GameEventBase gameEventBase)
        {
            LoadAssetFileEvent loadAssetFileEvent = gameEventBase as LoadAssetFileEvent;

            if (loadAssetFileEvent == null)
            {
                return;
            }
            ResourceLoader resourceLoader = loadAssetFileEvent.Sender as ResourceLoader;

            if (resourceLoader == null)
            {
                return;
            }
            if (resourceLoader != this)
            {
                return;
            }

            byte[] buffer = loadAssetFileEvent.Buffer;
            if (loadAssetFileEvent.Success)
            {
                ParseBytes(buffer);
            }
            else
            {
                string erroemessage = string.Format("can't load assetbundle, the name is '{0}'", loadAssetFileEvent.AssetName);
                OnError(LoadResourceStatus.NotExist, erroemessage);
            }
        }
Exemple #5
0
        private void OnLoadSceneSuccess(GameEventBase gameEventBase)
        {
            LoadSceneSuccessGameEvent ne = (LoadSceneSuccessGameEvent)gameEventBase;

            //todo
            m_IsChangeSceneComplete = true;
        }
Exemple #6
0
        private void OnSkillCD(GameEventBase gameEventBase)
        {
            SkillCDGameEvent skillCDGameEvent = (SkillCDGameEvent)gameEventBase;

            if (skillCDGameEvent.SkillId == m_SkillData.SkillId)
            {
                if (m_SkillData.SkillId == 10010)
                {
                    m_SkillData.SkillId = 10011;
                    BeginValueCD();
                    return;
                }
                else if (m_SkillData.SkillId == 10011)
                {
                    m_SkillData.SkillId = 10012;
                    BeginValueCD();
                    return;
                }
                else if (m_SkillData.SkillId == 10012)
                {
                    m_SkillData.SkillId = 10010;
                    BeginCD(skillCDGameEvent.CD);
                    return;
                }
                BeginCD(skillCDGameEvent.CD);
            }
        }
Exemple #7
0
 /// <summary>
 /// 派发事件,这是线程安全的
 /// </summary>
 /// <param name="sender">事件发送者,一般填this即可</param>
 /// <param name="gameEventBase"></param>
 public void Dispatch(object sender, GameEventBase gameEventBase)
 {
     lock (m_Events)
     {
         gameEventBase.Sender = sender;
         m_Events.Enqueue(gameEventBase);
     }
 }
Exemple #8
0
        private void OnLoadDataTableFailure(GameEventBase gameEventBase)
        {
            LoadDataTableFailureGameEvent loadDataTableFailureGameEvent = (LoadDataTableFailureGameEvent)gameEventBase;

            if (loadDataTableFailureGameEvent.UserData != this)
            {
                return;
            }

            Log.Error("Can not load data table '{0}' from '{1}' with error message '{2}'.", loadDataTableFailureGameEvent.DataTableName, loadDataTableFailureGameEvent.DataTableAssetName, loadDataTableFailureGameEvent.ErrorMessage);
        }
        /// <summary>
        /// 遥感移动
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnRockerMove(GameEventBase gameEventBase)
        {
            RockerMoveGameEvent rockerMoveGameEvent = (RockerMoveGameEvent)gameEventBase;

            deltaVec = new Vector3(rockerMoveGameEvent.Postion.x, 0, rockerMoveGameEvent.Postion.y);

            Vector3 targetDir = deltaVec;

            targetDir = targetDir.GetRotateY(GameEntry.Camera.MainCamera.transform.eulerAngles.y);
            m_MoveComponent.SetInputMoveDirection(targetDir, targetDir.magnitude);
        }
Exemple #10
0
 /// <summary>
 /// 事件轮询
 /// </summary>
 internal void OnUpdate(float deltaTime, float unscaledDeltaTime)
 {
     lock (m_Events)
     {
         while (m_Events.Count > 0)
         {
             GameEventBase gameEventBase = m_Events.Dequeue();
             DispatchNow(gameEventBase.Sender, gameEventBase);
         }
     }
 }
Exemple #11
0
        private void OnLoadSceneUpdate(GameEventBase gameEventBase)
        {
            LoadSceneUpdateGameEvent ne = (LoadSceneUpdateGameEvent)gameEventBase;

            if (ne.UserData != this)
            {
                return;
            }

            Log.Info("Load scene '{0}' update, progress '{1}'.", ne.SceneAssetName, ne.Progress.ToString("P2"));
        }
Exemple #12
0
        private void OnLoadSceneFailure(GameEventBase gameEventBase)
        {
            LoadSceneFailureGameEvent ne = (LoadSceneFailureGameEvent)gameEventBase;

            if (ne.UserData != this)
            {
                return;
            }

            Log.Error("Load scene '{0}' failure, error message '{1}'.", ne.SceneAssetName, ne.ErrorMessage);
        }
Exemple #13
0
        private void OnLoadSceneDependencyAsset(GameEventBase gameEventBase)
        {
            LoadSceneDependencyAssetGameEvent ne = (LoadSceneDependencyAssetGameEvent)gameEventBase;

            if (ne.UserData != this)
            {
                return;
            }

            Log.Info("Load scene '{0}' dependency asset '{1}', count '{2}/{3}'.", ne.SceneAssetName, ne.DependencyAssetName, ne.LoadedCount.ToString(), ne.TotalCount.ToString());
        }
Exemple #14
0
        private void MainSocketConected(GameEventBase gameEventBase)
        {
            SocketConnectedGameEvent socketConnectedGameEvent = (SocketConnectedGameEvent)gameEventBase;

            if (socketConnectedGameEvent.Socket != GameEntry.Socket.MainSocket)
            {
                return;
            }

            GameEntry.Procedure.SetData <VarInt>(Constant.ProcedureData.NextSceneId, (int)SceneType.SelectRole);
            GameEntry.UI.OpenUIForm(UIFormId.Loading);
        }
Exemple #15
0
        private void OnLoadDataTableSuccess(GameEventBase gameEventBase)
        {
            LoadDataTableSuccessGameEvent loadDataTableSuccessGameEvent = (LoadDataTableSuccessGameEvent)gameEventBase;

            if (loadDataTableSuccessGameEvent.UserData != this)
            {
                return;
            }

            m_LoadedFlag[TextUtil.Format("DataTable.{0}", loadDataTableSuccessGameEvent.DataTableName)] = true;
            Log.Info("Load data table '{0}' OK.", loadDataTableSuccessGameEvent.DataTableName);
        }
Exemple #16
0
 private void OnReturnSelectRole(GameEventBase gameEventBase)
 {
     if (GameEntry.Data.UserData.RoleLists == null || GameEntry.Data.UserData.RoleLists.Count == 0)
     {
         CurrFsm.SetData <VarInt>(Constant.ProcedureData.NextSceneId, (int)SceneType.LogOn);
         GameEntry.UI.OpenUIForm(UIFormId.Loading);
     }
     else
     {
         GameEntry.UI.OpenUIForm(UIFormId.SelectRole);
     }
 }
Exemple #17
0
        private void OnLogOnGameServerReturn(GameEventBase gameEventBase)
        {
            LogOnGameServerReturnGameEvent logOnGameServerReturnGameEvent = (LogOnGameServerReturnGameEvent)gameEventBase;

            if (logOnGameServerReturnGameEvent.RoleCount == 0)
            {
                GameEntry.UI.OpenUIForm(UIFormId.CreateRole);
            }
            else
            {
                GameEntry.UI.OpenUIForm(UIFormId.SelectRole);
            }
        }
Exemple #18
0
        /// <summary>
        /// 资源更新失败回调
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnResourceUpdateFailureGameEvent(GameEventBase gameEventBase)
        {
            ResourceUpdateFailureGameEvent resourceUpdateFailureGameEvent = (ResourceUpdateFailureGameEvent)gameEventBase;

            Log.Error("资源更新失败" + resourceUpdateFailureGameEvent.DownloadUri + resourceUpdateFailureGameEvent.ErrorMessage);
            Debug.LogError("资源更新失败" + resourceUpdateFailureGameEvent.DownloadUri + resourceUpdateFailureGameEvent.ErrorMessage);

            if (m_AllAssetSize.ContainsKey(resourceUpdateFailureGameEvent.Name))
            {
                m_CurrentUpdateZipLength -= m_AllAssetSize[resourceUpdateFailureGameEvent.Name];
                m_AllAssetSize.Remove(resourceUpdateFailureGameEvent.Name);
            }
            //todo
        }
Exemple #19
0
        private void OnILRuntimePreload(GameEventBase gameEventBase)
        {
            ILRuntimePreloadGameEvent ilRuntimePreloadGameEvent = (ILRuntimePreloadGameEvent)gameEventBase;

            if (ilRuntimePreloadGameEvent.Success)
            {
                m_HotfixPreload = true;
                Log.Info("Hotfix preload complete");
            }
            else
            {
                Log.Error("Hotfix preload error");
            }
        }
        private void OnZoom(GameEventBase gameEventBase)
        {
            InputZoomGameEvent inputZoomGameEvent = (InputZoomGameEvent)gameEventBase;

            switch (inputZoomGameEvent.ZoomType)
            {
            case ZoomType.In:
                GameEntry.Camera.SetCameraZoom(0);
                break;

            case ZoomType.Out:
                GameEntry.Camera.SetCameraZoom(1);
                break;
            }
        }
Exemple #21
0
        private void OnResourceUpdateStartGameEvent(GameEventBase gameEventBase)
        {
            ResourceUpdateStartGameEvent resourceUpdateStartGameEvent = (ResourceUpdateStartGameEvent)gameEventBase;

            Debug.Log(resourceUpdateStartGameEvent.Name + "开始更新!");

            if (!m_AllAssetSize.ContainsKey(resourceUpdateStartGameEvent.Name))
            {
                m_CurrentUpdateZipLength += resourceUpdateStartGameEvent.CurrentLength;
                m_AllAssetSize.Add(resourceUpdateStartGameEvent.Name, resourceUpdateStartGameEvent.CurrentLength);
            }


            //todo
        }
Exemple #22
0
        /// <summary>
        /// 资源更新变更回调
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnResourceUpdateChangedGameEvent(GameEventBase gameEventBase)
        {
            ResourceUpdateChangedGameEvent resourceUpdateChangedGameEvent = (ResourceUpdateChangedGameEvent)gameEventBase;
            //Debug.Log(resourceUpdateChangedGameEvent.Name);

            //Debug.Log("更新变化!");
            VarInt currentsize = null;

            if (m_AllAssetSize.TryGetValue(resourceUpdateChangedGameEvent.Name, out currentsize))
            {
                m_CurrentUpdateZipLength -= currentsize.Value;
                currentsize.Value         = resourceUpdateChangedGameEvent.CurrentLength;
                m_CurrentUpdateZipLength += currentsize.Value;
            }
            //todo
        }
Exemple #23
0
        private void OnSceneMove(GameEventBase gameEventBase)
        {
            InputMoveGameEvent inputMoveGameEvent = (InputMoveGameEvent)gameEventBase;

            switch (inputMoveGameEvent.MoveDir)
            {
            case MoveDir.Left:
                if (TranCam != null)
                {
                    TranCam.Rotate(0, -inputMoveGameEvent.Speed * Time.deltaTime, 0);
                    if (TranCam.localEulerAngles.y > 180)
                    {
                        TranCam.localEulerAngles = new Vector3(0, Mathf.Clamp(TranCam.localEulerAngles.y, 330f, 360f), 0);
                    }
                    else
                    {
                        TranCam.localEulerAngles = new Vector3(0, Mathf.Clamp(TranCam.localEulerAngles.y, 0, 30f), 0);
                    }
                }

                break;

            case MoveDir.Right:
                if (TranCam != null)
                {
                    TranCam.Rotate(0, inputMoveGameEvent.Speed * Time.deltaTime, 0);
                    if (TranCam.localEulerAngles.y > 180)
                    {
                        TranCam.localEulerAngles = new Vector3(0, Mathf.Clamp(TranCam.localEulerAngles.y, 330f, 360f), 0);
                    }
                    else
                    {
                        TranCam.localEulerAngles = new Vector3(0, Mathf.Clamp(TranCam.localEulerAngles.y, 0, 30f), 0);
                    }
                }
                break;

            case MoveDir.Up:
                break;

            case MoveDir.Down:
                break;
            }
        }
        /// <summary>
        /// 遥感中心点点击
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnRockerInClick(GameEventBase gameEventBase)
        {
            RockerInClickGameEvent rockerInClickGameEvent = (RockerInClickGameEvent)gameEventBase;
            MountsComponent        mountsComponent        = Owner.GetUnitComponent <MountsComponent>();

            if (mountsComponent == null)
            {
                return;
            }

            if (mountsComponent.IsRide)
            {
                mountsComponent.HideMounts();
            }
            else
            {
                mountsComponent.ShowMounts(UnityEngine.Random.Range(1, 10));
            }
        }
Exemple #25
0
        /// <summary>
        /// 删除角色成功事件
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnDeleateRoleSuccess(ZJY.Framework.GameEventBase gameEventBase)
        {
            for (int i = GameEntry.Data.UserData.RoleLists.Count - 1; i >= 0; i--)
            {
                if (GameEntry.Data.UserData.RoleLists[i].RoleId == m_CurrSelectRoleId)
                {
                    GameEntry.Data.UserData.RoleLists.RemoveAt(i);
                }
            }

            if (GameEntry.Data.UserData.RoleLists.Count == 0)
            {
                CreateRole();
            }
            else
            {
                SetUI(GameEntry.Data.UserData.RoleLists);
                SetSelectRole(GameEntry.Data.UserData.RoleLists[0].RoleId);
            }
        }
Exemple #26
0
        /// <summary>
        /// 立刻派发事件,这不是线程安全的
        /// </summary>
        /// <param name="sender">事件发送者,一般填this即可</param>
        /// <param name="gameEventBase">事件内容</param>
        public void DispatchNow(object sender, GameEventBase gameEventBase)
        {
            gameEventBase.Sender = sender;
            LinkedList <OnActionHandler> lstHandler = null;

            if (m_EventHandlers.TryGetValue(gameEventBase.Id, out lstHandler) && lstHandler.Count > 0)
            {
                LinkedListNode <OnActionHandler> current = lstHandler.First;
                while (current != null)
                {
                    LinkedListNode <OnActionHandler> next = current.Next;
                    if (current.Value != null)
                    {
                        current.Value(gameEventBase);
                    }
                    current = next;
                }
            }

            GameEntry.Pool.UnSpawnClassObject(gameEventBase);
        }
Exemple #27
0
        private void OnLoadSceneSuccess(GameEventBase gameEventBase)
        {
            LoadSceneSuccessGameEvent ne = (LoadSceneSuccessGameEvent)gameEventBase;

            if (ne.UserData != this)
            {
                return;
            }

            Log.Info("Load scene '{0}' OK.", ne.SceneAssetName);

            if (m_BackgroundMusicId > 0)
            {
                GameEntry.Sound.PlayMusic(m_BackgroundMusicId);
            }
            if (InitForm.Instance != null)
            {
                InitForm.Instance.DestroySelf();
            }

            m_IsChangeSceneComplete = true;
        }
        /// <summary>
        /// 普通攻击点击
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnNormalAttakClick(GameEventBase gameEventBase)
        {
            Debug.Log("普攻");
            CharacterStateComponent characterStateComponent = Owner.GetUnitComponent <CharacterStateComponent>();
            ActiveSkillComponent    activeSkillComponent    = Owner.GetUnitComponent <ActiveSkillComponent>();

            if (characterStateComponent.Get(SpecialStateType.NotInControl))
            {
                return;
            }

            int skillId = 0;

            if (characterStateComponent.Get(SpecialStateType.PowerAttack))
            {
                skillId = m_SkillIndex[powerindex];
                powerindex++;
                if (powerindex > 7)
                {
                    powerindex = 5;
                }
            }
            else
            {
                skillId = m_SkillIndex[index];
                index++;
                if (index > 4)
                {
                    index = 1;
                }
            }



            activeSkillComponent.Verify(skillId, (PlayerBase)Owner, null, Trigskill, null, Complate);
        }
Exemple #29
0
        /// <summary>
        /// 改变技能指示器位置
        /// </summary>
        /// <param name="gameEventBase"></param>
        private void OnChangeSkillArea(GameEventBase gameEventBase)
        {
            ChangeSkillAreaGameEvent changeSkillAreaGameEvent = (ChangeSkillAreaGameEvent)gameEventBase;

            deltaVec = new Vector3(changeSkillAreaGameEvent.Postion.x, 0, changeSkillAreaGameEvent.Postion.y);
        }
Exemple #30
0
 /// <summary>
 /// 影藏技能指示器
 /// </summary>
 /// <param name="gameEventBase"></param>
 private void OnHideSkillArea(GameEventBase gameEventBase)
 {
     GameEntry.Entity.HideEntity(this);
 }