Пример #1
0
 public override void execute()
 {
     // 创建房间成功,等待服务器通知进入房间
     if (mResult.mValue > 0)
     {
         ;
     }
     else
     {
         string info = "创建房间失败!";
         GameUtility.messageOK(info);
         UnityUtility.logInfo(info);
     }
 }
Пример #2
0
 /// 停止服务
 public void Stop()
 {
     try
     {
         if (mListener != null)
         {
             mListener.Stop();
         }
     }
     catch (Exception ex)
     {
         UnityUtility.logInfo(typeof(HttpServerManager) + ex.Message);
     }
 }
Пример #3
0
    protected void setCameraTargetTexture(GameObject parent, string cameraName, UITexture renderTexture)
    {
        GameObject cameraObject = UnityUtility.getGameObject(parent, cameraName);
        Camera     camera       = cameraObject.GetComponent <Camera>();

        if (renderTexture != null)
        {
            camera.targetTexture = renderTexture.mainTexture as RenderTexture;
        }
        else
        {
            camera.targetTexture = null;
        }
    }
Пример #4
0
 // 参数为Sound下的相对路径,并且不带后缀
 public void createAudio(string fileName, bool load = true, bool async = true)
 {
     if (mAudioClipList.ContainsKey(fileName))
     {
         UnityUtility.logError("error : audio has already loaded! file name : " + fileName);
         return;
     }
     mAudioClipList.Add(fileName, null);
     mAudioFlieName.Add(fileName);
     if (load)
     {
         loadAudio(fileName, async);
     }
 }
Пример #5
0
    // 打开一个二进制文件,fileName为绝对路径
    public static void openFile(string fileName, ref byte[] fileBuffer, ref int fileSize)
    {
        if (!fileName.StartsWith(CommonDefine.F_ASSETS_PATH))
        {
            UnityUtility.logError("fileName should be a absolute path!");
            return;
        }
        FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);

        fileSize   = (int)fs.Length;
        fileBuffer = new byte[fileSize];
        fs.Read(fileBuffer, 0, fileSize);
        fs.Close();
    }
Пример #6
0
    protected void updateRect(bool force = false)
    {
        if (!force && !mDirty)
        {
            return;
        }
        mDirty = false;
        float   width      = 0.0f;
        float   height     = 0.0f;
        Vector3 pos        = Vector3.zero;
        UIRect  parentRect = WidgetUtility.findParentRect(gameObject);

        if (parentRect != null)
        {
            GameObject parent = parentRect.gameObject;
            mParentSides = WidgetUtility.getParentSides(parent);
            float thisLeft   = mAnchorPoint[0].mRelative * mParentSides[2].x + mAnchorPoint[0].mAbsolute;
            float thisRight  = mAnchorPoint[2].mRelative * mParentSides[2].x + mAnchorPoint[2].mAbsolute;
            float thisTop    = mAnchorPoint[1].mRelative * mParentSides[1].y + mAnchorPoint[1].mAbsolute;
            float thisBottom = mAnchorPoint[3].mRelative * mParentSides[1].y + mAnchorPoint[3].mAbsolute;
            width  = thisRight - thisLeft;
            height = thisTop - thisBottom;
            pos.x  = (thisRight + thisLeft) / 2.0f;
            pos.y  = (thisTop + thisBottom) / 2.0f;
        }
        else
        {
            width  = mAnchorPoint[2].mAbsolute - mAnchorPoint[0].mAbsolute;
            height = mAnchorPoint[1].mAbsolute - mAnchorPoint[3].mAbsolute;
        }
        if (width < 0)
        {
            UnityUtility.logError("width error in anchor!");
        }
        if (height < 0)
        {
            UnityUtility.logError("height error in anchor!");
        }
        UIWidget thisWidget = WidgetUtility.getGameObjectWidget(gameObject);

        // 没有widget则是panel,panel是没有宽高的
        if (thisWidget != null)
        {
            thisWidget.width  = (int)(width + 0.5f);
            thisWidget.height = (int)(height + 0.5f);
        }
        Transform thisTrans = gameObject.transform;

        thisTrans.localPosition = pos;
    }
Пример #7
0
 public GameObject instantiate(string prefabName, GameObject parent, string objectName)
 {
     prefabName = prefabName.ToLower();
     if (mPrefabList.ContainsKey(prefabName))
     {
         if (objectName == "")
         {
             UnityUtility.logError("instantiate object's name can not be empty!");
             return(null);
         }
         return(UnityUtility.instantiatePrefab(parent, mPrefabList[prefabName], objectName, Vector3.one, Vector3.zero, Vector3.zero));
     }
     return(null);
 }
Пример #8
0
        private void RestoreSortOrder()
        {
            foreach (var item in managedObjects)
            {
                if (UnityUtility.IsNull(item.Target))
                {
                    continue;
                }

                item.Target.Layer.Canvas.sortingOrder = item.SortOrder;
            }

            managedObjects.Clear();
        }
Пример #9
0
        private void UpdateCurrentTime(float time)
        {
            if (State != State.Play)
            {
                return;
            }

            UpdateState();

            prevTime     = currentTime;
            currentTime += time;

            // Particle更新.
            for (var i = 0; i < particleInfos.Length; i++)
            {
                var particleInfo = particleInfos[i];

                var particleSystem = particleInfo.ParticleSystem;

                if (UnityUtility.IsNull(particleSystem))
                {
                    continue;
                }

                // フレーム更新.
                particleSystem.Simulate(time, false, false);

                // 状態更新.
                var playback = particleSystem.IsPlayback(particleInfo.IsSubemitter);

                switch (particleInfo.LifeCycle)
                {
                case LifecycleType.None:
                    particleInfo.LifeCycle = playback ? LifecycleType.Birth : LifecycleType.None;
                    break;

                case LifecycleType.Birth:
                    particleInfo.LifeCycle = playback ? LifecycleType.Alive : LifecycleType.Death;
                    break;

                case LifecycleType.Alive:
                    particleInfo.LifeCycle = playback ? LifecycleType.Alive : LifecycleType.Death;
                    break;

                case LifecycleType.Death:
                    particleInfo.LifeCycle = LifecycleType.None;
                    break;
                }
            }
        }
Пример #10
0
    protected override void applyTrembling(float value)
    {
        txNGUISlider window = mComponentOwner as txNGUISlider;

        if (window != null)
        {
            float curValue = mStartValue + (mTargetValue - mStartValue) * value;
            window.setSliderValue(curValue);
        }
        else
        {
            UnityUtility.logError("window is not a Slider Window!");
        }
    }
Пример #11
0
 public override void createSceneProcedure()
 {
     addProcedure <StartSceneLoading>(PROCEDURE_TYPE.PT_START_LOADING);
     addProcedure <StartSceneStandBy>(PROCEDURE_TYPE.PT_START_STAND_BY);
     addProcedure <StartSceneSelectRole>(PROCEDURE_TYPE.PT_START_SELECT_ROLE);
     addProcedure <StartSceneSetting>(PROCEDURE_TYPE.PT_START_SETTING);
     addProcedure <StartSceneSelectTrack>(PROCEDURE_TYPE.PT_START_SELECT_TRACK);
     addProcedure <StartSceneConfirmSelection>(PROCEDURE_TYPE.PT_START_CONFIRM_SELECTION);
     addProcedure <StartSceneExit>(PROCEDURE_TYPE.PT_START_EXIT);
     if (mSceneProcedureList.Count != (int)PROCEDURE_TYPE.PT_START_MAX - (int)PROCEDURE_TYPE.PT_START_MIN - 1)
     {
         UnityUtility.logError("error : not all procedure added! : " + typeof(StartScene).ToString());
     }
 }
Пример #12
0
        private void UpdateView()
        {
            var status = sendReportDisposable == null;

            sendReportButtonText.text = status ? "Send Report" : "Cancel";

            UnityUtility.SetActive(progressBar, !status);

            // 送信中.
            if (status)
            {
                UpdatePostProgress(0f);
            }
        }
Пример #13
0
        void OnEnable()
        {
            UpdateView();

            Observable.NextFrame()
            .TakeUntilDisable(this)
            .Subscribe(_ => OnRequestRefreshInputText())
            .AddTo(this);

            Observable.EveryUpdate()
            .TakeUntilDisable(this)
            .Subscribe(_ => UnityUtility.SetActive(sendReportButton, IsSendReportButtonEnable()))
            .AddTo(this);
        }
Пример #14
0
    public void Start()
    {
        Application.targetFrameRate = 120;
        AppDomain app = AppDomain.CurrentDomain;

        app.UnhandledException += UnhandledException;
        mFrameComponentMap      = new Dictionary <string, FrameComponent>();
        mFrameComponentInit     = new List <FrameComponent>();
        mFrameComponentUpdate   = new List <FrameComponent>();
        mFrameComponentDestroy  = new List <FrameComponent>();
        mTimeLock = new ThreadTimeLock(15);
        // 本地日志的初始化在移动平台上依赖于插件,所以在本地日志系统之前注册插件
        registeComponent <AndroidPluginManager>();
        registeComponent <AndroidAssetLoader>();
#if !UNITY_EDITOR
        // 由于本地日志系统的特殊性,必须在最开始就初始化
        FrameBase.mLocalLog = new LocalLog();
        FrameBase.mLocalLog.init();
#endif
        UnityUtility.mOnLog = getLogCallback();
        UnityUtility.logInfo("start game!", LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("QualitySettings.currentLevel:" + QualitySettings.GetQualityLevel(), LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("QualitySettings.activeColorSpace:" + QualitySettings.activeColorSpace, LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("Graphics.activeTier:" + Graphics.activeTier, LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("SystemInfo.graphicsDeviceType:" + SystemInfo.graphicsDeviceType, LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("SystemInfo.maxTextureSize:" + SystemInfo.maxTextureSize, LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("SystemInfo.supportsInstancing:" + SystemInfo.supportsInstancing, LOG_LEVEL.LL_FORCE);
        UnityUtility.logInfo("SystemInfo.graphicsShaderLevel:" + SystemInfo.graphicsShaderLevel, LOG_LEVEL.LL_FORCE);
        try
        {
            DateTime startTime = DateTime.Now;
            start();
            UnityUtility.logInfo("start消耗时间:" + (DateTime.Now - startTime).TotalMilliseconds);
            // 根据设置的顺序对列表进行排序
            mFrameComponentInit.Sort(FrameComponent.compareInit);
            mFrameComponentUpdate.Sort(FrameComponent.compareUpdate);
            mFrameComponentDestroy.Sort(FrameComponent.compareDestroy);
            notifyBase();
            registe();
            init();
        }
        catch (Exception e)
        {
            string innerMessage = e.InnerException != null ? e.InnerException.Message : "empty";
            UnityUtility.logError("init failed! " + e.Message + ", inner exception:" + innerMessage + "\nstack:" + e.StackTrace);
        }
        // 初始化完毕后启动游戏
        launch();
        mCurTime = DateTime.Now;
    }
Пример #15
0
    public GameCamera createCamera(string name, GameObject parent = null)
    {
        GameCamera camera = null;
        GameObject obj    = UnityUtility.getGameObject(parent, name);

        if (obj != null)
        {
            camera = new GameCamera(name);
            camera.init();
            camera.setObject(obj);
            mCameraList.Add(camera.getName(), camera);
        }
        return(camera);
    }
Пример #16
0
        // アニメーションの終了待ち.
        private IEnumerator WaitForEndOfAnimation()
        {
            if (!isInitialized)
            {
                yield break;
            }

            while (true)
            {
                if (State == State.Stop)
                {
                    yield break;
                }

                if (State == State.Play)
                {
                    if (Application.isPlaying)
                    {
                        var time = ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;

                        // 時間更新.
                        FrameUpdate(time);

                        // ParticleSysmteのSimulate.
                        foreach (var ps in particleSystems)
                        {
                            if (UnityUtility.IsNull(ps.ParticleSystem))
                            {
                                continue;
                            }

                            if (!ps.ParticleSystem.gameObject.activeInHierarchy)
                            {
                                continue;
                            }

                            ps.ParticleSystem.Simulate(time, false, false);
                        }

                        // 終了監視.
                        if (!IsAlive())
                        {
                            break;
                        }
                    }
                }

                yield return(null);
            }
        }
Пример #17
0
    // 通知开始销毁
    public override void notifyDestroy()
    {
        base.notifyDestroy();
        // 播放爆炸特效,隐藏箱子模型
        UnityUtility.getGameObject(mObject, mExplodeParticleName, true).SetActive(true);
        UnityUtility.getGameObject(mObject, mBoxModelNodeName, true).SetActive(false);
        // 1秒后销毁道具
        mItemManager.destroyItemDelay(this, 1.0f);
        // 30秒后在该位置重新克隆一个箱子
        ItemBoxParam param = new ItemBoxParam();

        param.mPosition = mObject.transform.position;
        mItemManager.createItemDelay(mType, GameDefine.CREATE_ITEM_BOX_TIME, param);
    }
Пример #18
0
        //----- method -----

        public SceneInstance(Scenes?identifier, ISceneBase instance, Scene?scene)
        {
            this.scene = scene;

            Identifier = identifier;
            Instance   = instance;

            var rootObjects = scene.Value.GetRootGameObjects();

            activeRoots = rootObjects
                          .Where(x => !UnityUtility.IsNull(x))
                          .Where(x => UnityUtility.IsActive(x))
                          .ToArray();
        }
Пример #19
0
    public void destroyObject(txUIObject obj, bool immediately = false)
    {
        // 查找该节点下的所有窗口,从布局中注销
        List <GameObject> children = new List <GameObject>();

        findAllChild(obj.mObject, children);
        int count = children.Count;

        for (int i = 0; i < count; ++i)
        {
            mLayout.unregisterUIObject(mLayout.getUIObject(children[i]));
        }
        UnityUtility.destroyGameObject(obj.mObject, immediately);
    }
Пример #20
0
	protected virtual void initFrameSystem()
	{
		registeFrameSystem(UnityUtility.Typeof<TimeManager>());
		registeFrameSystem(UnityUtility.Typeof<ApplicationConfig>());
		registeFrameSystem(UnityUtility.Typeof<FrameConfig>());
		registeFrameSystem(UnityUtility.Typeof<HttpUtility>());
#if !UNITY_IOS && !NO_SQLITE
		registeFrameSystem(UnityUtility.Typeof<SQLite>());
#endif
		registeFrameSystem(UnityUtility.Typeof<DataBase>());
		registeFrameSystem(UnityUtility.Typeof<CommandSystem>(), -1, -1, 2001);  // 命令系统在大部分管理器都销毁完毕后再销毁
		registeFrameSystem(UnityUtility.Typeof<GlobalTouchSystem>());
		registeFrameSystem(UnityUtility.Typeof<CharacterManager>());
		registeFrameSystem(UnityUtility.Typeof<AudioManager>());
		registeFrameSystem(UnityUtility.Typeof<GameSceneManager>());
		registeFrameSystem(UnityUtility.Typeof<KeyFrameManager>());
		registeFrameSystem(UnityUtility.Typeof<DllImportExtern>());
		registeFrameSystem(UnityUtility.Typeof<ShaderManager>());
		registeFrameSystem(UnityUtility.Typeof<CameraManager>());
		registeFrameSystem(UnityUtility.Typeof<InputManager>());
		registeFrameSystem(UnityUtility.Typeof<SceneSystem>());
		registeFrameSystem(UnityUtility.Typeof<GamePluginManager>());
		registeFrameSystem(UnityUtility.Typeof<ClassPool>(), -1, -1, 3101);
		registeFrameSystem(UnityUtility.Typeof<ClassPoolThread>(), -1, -1, 3102);
		registeFrameSystem(UnityUtility.Typeof<ListPool>(), -1, -1, 3103);
		registeFrameSystem(UnityUtility.Typeof<ListPoolThread>(), -1, -1, 3104);
		registeFrameSystem(UnityUtility.Typeof<DictionaryPool>(), -1, -1, 3105);
		registeFrameSystem(UnityUtility.Typeof<DictionaryPoolThread>(), -1, -1, 3106);
		registeFrameSystem(UnityUtility.Typeof<BytesPool>(), -1, -1, 3107);
		registeFrameSystem(UnityUtility.Typeof<BytesPoolThread>(), -1, -1, 3108);
		registeFrameSystem(UnityUtility.Typeof<HeadTextureManager>());
		registeFrameSystem(UnityUtility.Typeof<MovableObjectManager>());
		registeFrameSystem(UnityUtility.Typeof<EffectManager>());
		registeFrameSystem(UnityUtility.Typeof<TPSpriteManager>());
		registeFrameSystem(UnityUtility.Typeof<SocketFactory>());
		registeFrameSystem(UnityUtility.Typeof<SocketFactoryThread>());
		registeFrameSystem(UnityUtility.Typeof<PathKeyframeManager>());
		registeFrameSystem(UnityUtility.Typeof<EventSystem>());
		registeFrameSystem(UnityUtility.Typeof<StringBuilderPool>());
		registeFrameSystem(UnityUtility.Typeof<StringBuilderPoolThread>());
#if USE_ILRUNTIME
		registeFrameSystem(UnityUtility.Typeof<ILRSystem>());
#endif
		// 布局管理器也需要在最后更新,确保所有游戏逻辑都更新完毕后,再更新界面
		registeFrameSystem(UnityUtility.Typeof<LayoutManager>(), 1000, 1000, 1000);
		// 物体管理器和资源管理器必须最后注册,以便最后销毁,作为最后的资源清理
		registeFrameSystem(UnityUtility.Typeof<ObjectPool>(), 2000, 2000, 2000);
		registeFrameSystem(UnityUtility.Typeof<ResourceManager>(), 3000, 3000, 3000);
	}
Пример #21
0
        private void Start()
        {
            _graph = UnityUtility.FindParent <Graph>(this);

            _filterListener = UnityUtility.FindParent <GraphFilterListener>(this);
            if (_filterListener)
            {
                _filterListener.OnFilterUpdate += OnFilterUpdate;
                OnFilterUpdate();
            }

            _rotationAnimation.Init(Quaternion.identity);
            _colorAnimation.Init(new Color32(255, 255, 255, 0));
            StartCoroutine(RunUpdates());
        }
Пример #22
0
        private void OnFocuseChanged(bool isFocused)
        {
            // フォーカスされた時に既存の文字が全選択されるのを解除する.
            if (isFocused)
            {
                inputField.MoveTextEnd(true);
            }

            #if UNITY_EDITOR
            UnityUtility.SetActive(inputFieldText, !isFocused);
            UnityUtility.SetActive(inputField.textComponent, isFocused);

            inputFieldText.text = inputField.text;
            #endif
        }
Пример #23
0
    public T cloneObject <T>(txUIObject parent, T oriObj, string name, bool active = true) where T : txUIObject, new()
    {
        if (parent == null)
        {
            parent = mRoot;
        }
        GameObject obj    = UnityUtility.cloneObject(oriObj.getObject(), name);
        T          window = newUIObject <T>(name, parent, mLayout, obj);

        window.setActive(active);
        window.setLocalPosition(oriObj.getPosition());
        window.setLocalRotation(oriObj.getRotationEuler());
        window.setLocalScale(oriObj.getScale());
        return(window);
    }
Пример #24
0
    public static void removeScaleAnchor(GameObject obj)
    {
        // 先销毁自己的Anchor
        if (obj.GetComponent <ScaleAnchor>() != null)
        {
            UnityUtility.destroyGameObject(obj.GetComponent <ScaleAnchor>(), true);
        }
        // 再销毁子节点的Anchor
        int childCount = obj.transform.childCount;

        for (int i = 0; i < childCount; ++i)
        {
            removeScaleAnchor(obj.transform.GetChild(i).gameObject);
        }
    }
Пример #25
0
        private void CommandFunction(bool show, string colorCode = "#000000FF")
        {
            try
            {
                var color = colorCode.HexToColor();

                FadeImage.color = color;

                UnityUtility.SetActive(FadeImage, show);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Пример #26
0
 public GameScene(GAME_SCENE_TYPE type, string name)
     :
     base(name)
 {
     mSceneType          = type;
     mCurProcedure       = null;
     mDestroyEngineScene = true;
     mLastProcedureType  = PROCEDURE_TYPE.PT_NONE;
     mDestroyEngineScene = false;
     mSceneProcedureList = new Dictionary <PROCEDURE_TYPE, SceneProcedure>();
     mLastProcedureList  = new List <SceneProcedure>();
     // 创建场景对应的物体,并挂接到场景管理器下
     mSceneObject = UnityUtility.createObject(name, mGameSceneManager.getManagerObject());
     mAudioSource = mSceneObject.GetComponent <AudioSource>();
 }
Пример #27
0
	public void LateUpdate()
	{
		try
		{
			if (mPauseFrame)
			{
				return;
			}
			lateUpdate(mThisFrameTime);
		}
		catch (Exception e)
		{
			UnityUtility.logError(e.Message + ", stack:" + e.StackTrace);
		}
	}
Пример #28
0
	public void FixedUpdate()
	{
		try
		{
			if (mPauseFrame)
			{
				return;
			}
			fixedUpdate(Time.fixedDeltaTime);
		}
		catch (Exception e)
		{
			UnityUtility.logError(e.Message + ", stack:" + e.StackTrace);
		}
	}
Пример #29
0
    public override void createSceneProcedure()
    {
        addProcedure <MainSceneLoading>(PROCEDURE_TYPE.PT_MAIN_LOADING);
        addProcedure <MainSceneReady>(PROCEDURE_TYPE.PT_MAIN_READY);
        MainSceneGaming gaming = addProcedure <MainSceneGaming>(PROCEDURE_TYPE.PT_MAIN_GAMING);

        addProcedure <MainSceneGamingFinish>(PROCEDURE_TYPE.PT_MAIN_GAMING_FINISH, gaming);
        addProcedure <MainSceneFinish>(PROCEDURE_TYPE.PT_MAIN_FINISH);
        addProcedure <MainSceneSettlement>(PROCEDURE_TYPE.PT_MAIN_SETTLEMENT);
        addProcedure <MainSceneExit>(PROCEDURE_TYPE.PT_MAIN_EXIT);
        if (mSceneProcedureList.Count != (int)PROCEDURE_TYPE.PT_MAIN_MAX - (int)PROCEDURE_TYPE.PT_MAIN_MIN - 1)
        {
            UnityUtility.logError("error : not all procedure added! : " + typeof(MainScene).ToString());
        }
    }
Пример #30
0
 public override void execute()
 {
     if (mResult.mValue == 0)
     {
         CommandGameSceneChangeProcedure cmd = newCmd(out cmd, true, true);
         cmd.mProcedure = PROCEDURE_TYPE.PT_START_LOGIN;
         pushDelayCommand(cmd, mGameSceneManager.getCurScene());
     }
     else if (mResult.mValue == 1)
     {
         string info = "注册失败!";
         GameUtility.messageOK(info);
         UnityUtility.logInfo(info);
     }
 }