コード例 #1
0
        public override void OnOpen(object userData)
        {
            //对话框数据
            DialogParams dialogParams = (DialogParams)userData;

            if (dialogParams == null)
            {
                HotLog.Warning("DialogParams is invalid.");
                return;
            }

            DialogMode = dialogParams.Mode;
            RefreshDialogMode();
            //信息
            m_TitleText.text   = dialogParams.Title;
            m_MessageText.text = dialogParams.Message;
            //暂停游戏
            IsPauseGame = dialogParams.PauseGame;
            RefreshPauseGame();

            UserData = dialogParams.UserData;

            //按钮文本和事件
            RefreshConfirmText(dialogParams.ConfirmText);
            m_OnClickConfirm = dialogParams.OnClickConfirm;
            RefreshCancelText(dialogParams.CancelText);
            m_OnClickCancel = dialogParams.OnClickCancel;
            RefreshOtherText(dialogParams.OtherText);
            m_OnClickOther = dialogParams.OnClickOther;
        }
コード例 #2
0
 public override void OnOpen(object userData)
 {
     m_ProcedureMenu = userData as ProcedureMenu;
     if (m_ProcedureMenu == null)
     {
         HotLog.Warning("ProcedureMenu is invalid when open MenuForm.");
         return;
     }
 }
コード例 #3
0
        //显示实体血条
        public void ShowHPBar(Entity entity, float fromHPRatio, float toHPRatio)
        {
            if (entity == null)
            {
                HotLog.Warning("Entity is invalid.");
                return;
            }

            HPBarItem hpBarItem = GetActiveHPBarItem(entity);

            if (hpBarItem == null)
            {
                hpBarItem = CreateHPbarItem();
                m_ListActiveHPBar.Add(hpBarItem);
            }

            hpBarItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio);
        }
コード例 #4
0
        private int m_BackgroundMusicId      = 0;     //切换场景时的背景音乐

        //流程进入回调
        public override void OnEnter(IFsm <IProcedureManager> procedureOwner)
        {
            m_IsChangeSceneComplete = false;
            //订阅事件
            GameEntry.Event.Subscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess);
            GameEntry.Event.Subscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure);
            GameEntry.Event.Subscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate);
            GameEntry.Event.Subscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset);

            //停止所有声音
            GameEntry.Sound.StopAllLoadingSounds();     //停止正在加载所有声音
            GameEntry.Sound.StopAllLoadedSounds();      //停止加载完成的声音

            //隐藏所有实体
            GameEntry.Entity.HideAllLoadingEntities();      //加载中的实体
            GameEntry.Entity.HideAllLoadedEntities();       //加载完成的实体

            //卸载所有场景
            string[] loadedSceneAssetNames = GameEntry.Scene.GetLoadedSceneAssetNames();
            for (int i = 0; i < loadedSceneAssetNames.Length; i++)
            {
                GameEntry.Scene.UnloadScene(loadedSceneAssetNames[i]);
            }

            //还原游戏进度
            GameEntry.Base.ResetNormalGameSpeed();

            //获取场景数据
            int sceneId = procedureOwner.GetData <VarInt>(Constant.ProcedureData.NextSceneId).Value;

            m_ChangeToMenu = sceneId == MenuSceneId;        //是否切换到菜单场景
            IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>();
            DRScene drScene = dtScene.GetDataRow(sceneId);

            if (drScene == null)
            {
                HotLog.Warning("Can not load scene '{0}' from data table.", sceneId.ToString());
                return;
            }
            //加载场景
            GameEntry.Scene.LoadScene(RuntimeAssetUtility.GetSceneAsset(drScene.AssetName), RuntimeConstant.AssetPriority.SceneAsset, this);
            m_BackgroundMusicId = drScene.BackgroundMusicId;
        }
コード例 #5
0
        private float m_InitPosition = 0f;      //初始位置

        public override void OnInit(object userData)
        {
            base.OnInit(userData);
            //画布大小
            CanvasScaler canvasScaler = (CanvasScaler)RuntimeUIForm.GetComponentInParent(typeof(CanvasScaler));

            if (canvasScaler == null)
            {
                HotLog.Warning("Can not find CanvasScaler component.");
                return;
            }

            //初始位置设置为高度的一半
            m_InitPosition = -0.5f * canvasScaler.referenceResolution.x * Screen.height / Screen.width;

            ReferenceCollector collector = RuntimeUIForm.ReferenceCollector;

            m_RectTransform = (RectTransform)collector.Get("trans_Content", typeof(RectTransform));
            (collector.Get("bt_Back", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnClickClose);
        }
コード例 #6
0
        /// <summary>
        /// 获取两个阵营之间的关系。
        /// </summary>
        /// <param name="first">阵营一。</param>
        /// <param name="second">阵营二。</param>
        /// <returns>阵营间关系。</returns>
        public static RelationType GetRelation(CampType first, CampType second)
        {
            //第一阵营一定小于或等于第二阵营
            if (first > second)
            {
                CampType temp = first;
                first  = second;
                second = temp;
            }

            RelationType relationType;

            if (s_CampPairToRelation.TryGetValue(((int)first << 4) + (int)second, out relationType))
            {
                return(relationType);
            }

            HotLog.Warning("Unknown relation between '{0}' and '{1}'.", first.ToString(), second.ToString());
            return(RelationType.Unknown);
        }
コード例 #7
0
        private MyAircraft m_MyAircraft = null;     //我的战机

        //初始化
        public virtual void Initialize()
        {
            //注册事件
            GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
            GameEntry.Event.Subscribe(ShowEntityFailureEventArgs.EventId, OnShowEntityFailure);
            //滚动背景
            SceneBackground = Object.FindObjectOfType <ScrollableBackground>();
            if (SceneBackground == null)
            {
                HotLog.Warning("Can not find scene background.");
                return;
            }
            SceneBackground.VisibleBoundary.gameObject.GetOrAddComponent <HideByBoundary>();    //添加触发离开时隐藏实体
            GameEntry.Entity.ShowMyAircraft(new MyAircraftData(GameEntry.Entity.GenerateSerialId(), 10000)
            {
                Name     = "My Aircraft",
                Position = Vector3.zero
            });

            IsGameOver   = false;
            m_MyAircraft = null;
        }
コード例 #8
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);

            //缓存我的战机数据
            m_MyAircraftData = userData as MyAircraftData;
            if (m_MyAircraftData == null)
            {
                HotLog.Error("My aircraft data is invalid.");
                return;
            }

            ScrollableBackground sceneBackground = (ScrollableBackground)Object.FindObjectOfType(typeof(ScrollableBackground));

            if (sceneBackground == null)
            {
                HotLog.Warning("Can not find scene background.");
                return;
            }
            //创建移动区域
            m_PlayerMoveBoundary = new Rect(sceneBackground.PlayerMoveBoundary.bounds.min.x, sceneBackground.PlayerMoveBoundary.bounds.min.z,
                                            sceneBackground.PlayerMoveBoundary.bounds.size.x, sceneBackground.PlayerMoveBoundary.bounds.size.z);
        }
コード例 #9
0
        protected virtual void OnShowEntityFailure(object sender, GameEventArgs e)
        {
            ShowEntityFailureEventArgs ne = e as ShowEntityFailureEventArgs;

            HotLog.Warning("Show entity failure with error message '{0}'.", ne.ErrorMessage);
        }