public void OnTabSelect(TabButton tab)
    {
        this.selectedTab = tab;
        this.ResetTabs();
        tab.sprite.color = TabPanel.activeColor;

        int index = tab.transform.GetSiblingIndex();

        for (int i = 0; i < this.pages.Count; i++)
        {
            this.pages[i].SetActive(i == index);
        }

        GameLogger.LogMessage($"Selected tab {this.pages[index].name}", "TabPanel");
    }
Exemple #2
0
        //加载基础信息
        private bool LoadBaseInfo()
        {
            bool hasDefFile = false;

            //在zip中加载LevelDef
            ZipInputStream zip = ZipUtils.OpenZipFile(FilePath);
            ZipEntry       theEntry;

            while ((theEntry = zip.GetNextEntry()) != null)
            {
                if (theEntry.Name == "/LevelDef.xml" || theEntry.Name == "LevelDef.xml")
                {
                    hasDefFile = true;
                    LoadLevelDefInZip(zip, theEntry);
                }
                else if (theEntry.Name == "/" + Logo || theEntry.Name == Logo)
                {
                    LoadLogoInZip(zip, theEntry);
                }
            }
            zip.Close();
            zip.Dispose();

            if (!hasDefFile)
            {
                GameLogger.Error(TAG, "加载模组包失败,未找到 LevelDef.xml");
                GameErrorManager.LastError = GameError.InitializationFailed;

                LoadStatus = GameModStatus.InitializeFailed;
                LoadError  = "未找到 ModDef.xml";

                return(false);
            }

            //检查兼容性
            if (LevelCompatibilityInfo.MinVersion > GameConst.GameBulidVersion)
            {
                GameLogger.Error(TAG, "加载模组包失败,关卡与游戏版本不兼容");
                GameErrorManager.LastError = GameError.BadMod;

                LoadStatus = GameModStatus.BadMod;
                LoadError  = "关卡与游戏版本不兼";

                return(false);
            }

            return(true);
        }
 private void SetNormalize()
 {
     if (mScroll.horizontal)
     {
         mNormalValue = mScroll.normalizedPosition.x;
     }
     else if (mScroll.vertical)
     {
         mNormalValue = mScroll.normalizedPosition.y;
     }
     if (mNormalValue == 1)
     {
         mNormalValue = 0;
     }
     GameLogger.Log("mNormalValue:" + mNormalValue);
 }
Exemple #4
0
    /// <summary>
    /// 预加载窗口
    /// </summary>
    public UIWindow PreloadWindow(EWindowType type)
    {
        // 如果窗口已经存在
        if (IsContains(type))
        {
            return(null);
        }

        GameLogger.Log($"Preload window {type}");
        UIWindow window = _creater.CreateInstance(type);

        Push(window);
        window.InternalClose();
        window.InternalLoad(OnWindowPrepare);
        return(window);
    }
Exemple #5
0
        /// <summary>
        /// 生成 垂直自动布局
        /// </summary>
        /// <param name="name">布局名称</param>
        /// <param name="template">UI模板</param>
        /// <param name="handlers">接收器模板</param>
        /// <returns></returns>
        public UILayout BuildLayoutByTemplate(string name, string templateXml, Dictionary <string, GameHandler> handlers, string[] initialProps)
        {
            if (string.IsNullOrEmpty(templateXml))
            {
                GameLogger.Error(TAG, "BuildLayoutByTemplate {0} failed, templateXml is Empty", name);
                GameErrorManager.LastError = GameError.ParamNotProvide;
                return(null);
            }

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(templateXml);

            return(BuildLayoutByTemplateInternal(name, xmlDocument.DocumentElement,
                                                 handlers, null, null, initialProps));
        }
Exemple #6
0
 public void saveReplay(GameLogger replay)
 {
     if (Replayes.Find(repl => repl.gameID == replay.gameID).ToList().Count > 0)
     {
         Replayes.ReplaceOne(
             repl => repl.gameID == replay.gameID,
             replay,
             new UpdateOptions {
             IsUpsert = true
         });
     }
     else
     {
         Replayes.InsertOne(replay);
     }
 }
Exemple #7
0
        /// <summary>
        /// 执行模组包代码
        /// </summary>
        /// <param name="modUid">模组包UID</param>
        /// <returns>返回操作是否成功</returns>
        public bool RunGameMod(GameMod m)
        {
            if (m == null)
            {
                GameErrorManager.LastError = GameError.ParamNotProvide;
                return(false);
            }
            if (m.LoadStatus == GameModStatus.InitializeSuccess)
            {
                return(m.Run());
            }

            GameLogger.Warning(TAG, "无法执行化模组包 {0},因为没有初始化", m.PackageName);
            GameErrorManager.LastError = GameError.NotInitialize;
            return(false);
        }
Exemple #8
0
 private void displayStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.logContextMenuStrip.Cursor == Cursors.Help)
     {
         this.logContextMenuStrip.Show();
         this.toolTip1.Hide((IWin32Window)this);
         this.toolTip1.IsBalloon = false;
         this.toolTip1.IsBalloon = true;
         this.toolTip1.SetToolTip((Control)this.logContextMenuStrip, " ");
         this.toolTip1.Show("Displays the current standings from the battle history.", (IWin32Window)this.logContextMenuStrip, this.copyStripMenuItem.Width / 2, this.copyStripMenuItem.Height * 6 / 2);
     }
     else
     {
         GameLogger.MainObj().DisplayAll(true);
     }
 }
    public static void RestartGame(IMapGenerator generator)
    {
        GameLogger.LogMessage("Game restart", "GameManager");

        GameManager.customLevel = generator;

        if (GameManager.instance != null)
        {
            GameManager.instance.gameState          = GameState.NOT_LOADED;
            GameManager.instance.currentLevelNumber = 1;
            GameManager.instance.upgradeManager.ResetUpgrades();
            GameLogger.LogMessage("GameManager instantiated", "GameManager");
        }

        LoadingScreen.StartLoading();
    }
    public void OnEntityDead(Entity deadEntity)
    {
        if (deadEntity == playerEntity)
        {
            GameOver();
            return;
        }

        // This is a hacky way to implement a XP table for mobs, by using their current
        // XP as the XP to give to the player...
        GameLogger.Log("<color=yellow>You receive " + deadEntity.XP + " experience points!</color>");
        playerEntity.Stats.XP += deadEntity.XP;
        playerInfo.XPChanged();

        SetupNewEnemy();
    }
Exemple #11
0
        /// <summary>
        /// 加载模组包
        /// </summary>
        /// <param name="packagePath">模组包路径</param>
        /// <param name="initialize">是否立即初始化模组包</param>
        /// <returns>返回模组包UID</returns>
        public GameMod LoadGameMod(string packagePath, bool initialize = true)
        {
            GameMod mod = FindGameModByPath(packagePath);

            if (mod != null)
            {
                GameLogger.Warning(TAG, "Mod \"{0}\" already registered, skip", packagePath);
                return(mod);
            }

            //路径处理
            if (StringUtils.IsUrl(packagePath))
            {
                GameLogger.Error(TAG, "不支持从 URL 加载模组包 \"{0}\" ,请将其先下载至 streamingAssetsPath 后再加载。", packagePath);
                return(null);
            }
            //处理路径至mod文件夹路径
            if (!File.Exists(packagePath) && !GamePathManager.IsAbsolutePath(packagePath))
            {
                packagePath = GamePathManager.GetResRealPath("mod", packagePath);
            }
            if (!File.Exists(packagePath))
            {
                GameLogger.Error(TAG, "Mod file \"{0}\" not exists", packagePath);
                return(null);
            }

            mod = new GameMod(packagePath, this);
            if (!mod.Init())
            {
                return(null);
            }
            if (!gameMods.Contains(mod))
            {
                gameMods.Add(mod);
            }

            GameManager.GameMediator.DispatchGlobalEvent(GameEventNames.EVENT_MOD_REGISTERED, "*", mod.PackageName, mod);
            GameLogger.Log(TAG, "Register mod \"{0}\"", packagePath);

            if (initialize)
            {
                mod.Load(this);
            }

            return(mod);
        }
        /// <summary>
        /// Finishes the game.
        /// </summary>
        void Finish()
        {
            if (GameLogger != null)
            {
                foreach (var agent in OrderedAgentList)
                {
                    GameLogger.Log($"{Day},status,{agent.AgentIdx},{RoleOf(agent)},{StatusOf(agent)},{agentNameMap[agent]}");
                }
                GameLogger.Log($"{Day},result,{AliveHumanList.Count},{AliveWolfList.Count},{GetWinner()}");
                GameLogger.Close();
            }

            foreach (var agent in AgentList)
            {
                gameServer.Finish(agent);
            }
        }
    /*
     * PREPARE THE GAMESCREEN
     * Enable/Disable elements
     * finaly start loading AUDIO ASSET
     */

    void OnPrepareEvent()
    {
        listIndex    = 0;
        nextShowTime = 0;
        nextHitTime  = 0;
        foreach (ClickAreaCtrl c in clickAreas)
        {
            c.gameObject.SetActive(true);
        }
        gameElements.SetActive(true);
        gameUI.SetActive(true);
        ScoreCtrl.ResetScore();
        clicksCount = 0;
        StartCoroutine(LoadAudioAsset());

        GameLogger.Reset();
    }
        /// <summary>
        /// 根据全路径获取UI组件
        /// </summary>
        public T GetUIComponent <T>(string path) where T : UnityEngine.Component
        {
            Transform element = GetUIElement(path);

            if (element == null)
            {
                return(null);
            }

            Component component = element.GetComponent <T>();

            if (component == null)
            {
                GameLogger.Warning($"Not found ui component : {path}, {typeof(T)}");
            }
            return(component as T);
        }
Exemple #15
0
        public bool DoPreInit()
        {
            if (preIinitialized)
            {
                return(true);
            }

            preIinitialized = true;
            InitPre();

            if (IsLuaModul && luaObjectHost == null)
            {
                GameLogger.Error(GetFullName(), "LuaModul can oly use when GameLuaObjectHost is bind ! ");
                return(false);
            }
            return(DoInitStore());
        }
Exemple #16
0
        /// <summary>
        /// Sets the submaterial on a grid square.
        /// </summary>
        /// <param name="x">X coordinate of the grid square.</param>
        /// <param name="z">Z coordinate of the grid square.</param>
        /// <param name="submaterialId">The id of the submaterial (the gridsheet on the material from left->right, top->bottom).</param>
        public void SetSubmaterial(int x, int z, int submaterialId, Rotation rotation = Rotation.deg0)
        {
            if (x < 0 || x >= CountX || z < 0 || z >= CountZ)
            {
                GameLogger.FatalError("Attempted to set square material outside of range! ({0},{1}) is outside of ({2},{3})", x, z, CountX, CountZ);
            }

            int submaterialOffsetX = submaterialId % _submaterialCountX;
            int submaterialOffsetZ = submaterialId / _submaterialCountX;

            if (submaterialOffsetZ >= _submaterialCountZ)
            {
                throw new InvalidOperationException(string.Format("Submaterial index '{0}' is out of range for material {1} ({2}x{3}).", submaterialId, _material.name, _submaterialCountX, _submaterialCountZ));
            }

            float stepX = (1.0f / _submaterialCountX);
            float stepZ = (1.0f / _submaterialCountZ);

            int rotationOffset = 0;

            switch (rotation)
            {
            case Rotation.deg90:
                rotationOffset = 3;
                break;

            case Rotation.deg180:
                rotationOffset = 2;
                break;

            case Rotation.deg270:
                rotationOffset = 1;
                break;
            }

            var grid = _gridData[x, z];

            _uv[grid.VertexIndex + (Vertex.BottomLeft + rotationOffset) % 4]  = new Vector2(submaterialOffsetX * stepX + Constant.uvEpsilon, 1.0f - (submaterialOffsetZ + 1) * stepZ + Constant.uvEpsilon);
            _uv[grid.VertexIndex + (Vertex.BottomRight + rotationOffset) % 4] = new Vector2((submaterialOffsetX + 1) * stepX - Constant.uvEpsilon, 1.0f - (submaterialOffsetZ + 1) * stepZ + Constant.uvEpsilon);
            _uv[grid.VertexIndex + (Vertex.TopRight + rotationOffset) % 4]    = new Vector2((submaterialOffsetX + 1) * stepX - Constant.uvEpsilon, 1.0f - submaterialOffsetZ * stepZ - Constant.uvEpsilon);
            _uv[grid.VertexIndex + (Vertex.TopLeft + rotationOffset) % 4]     = new Vector2(submaterialOffsetX * stepX + Constant.uvEpsilon, 1.0f - submaterialOffsetZ * stepZ - Constant.uvEpsilon);
            _uv[grid.VertexIndex + Vertex.Center] = new Vector2(submaterialOffsetX * stepX + (stepX / 2), 1.0f - submaterialOffsetZ * stepZ - (stepZ / 2));
            grid.SubmaterialIndex = submaterialId;

            _mesh.uv = _uv;
        }
        /// <summary>
        /// Transition to SelectingTerrain state.
        /// </summary>
        /// <param name="context">The grid coordinate to edit.</param>
        public override void TransitionIn(object context)
        {
            var args = context as TerrainClickedArgs;

            if (args == null)
            {
                GameLogger.FatalError("EditingTerrainController was given incorrect context.");
            }

            _editingGridLocation = args.ClickLocation;

            _cursor.Activate();
            _cursor.Place(_editingGridLocation.x, _editingGridLocation.z);

            _mouseDragStartY       = Input.mousePosition.y;
            _mouseDragHeightChange = 0;
        }
Exemple #18
0
    /// <summary>
    /// (DEBUG ONLY) Prints <paramref name="matrix"/> into Unity Debug stream.
    /// </summary>
    /// <param name="matrix"> Matrix to print. </param>
    /// <typeparam name="T"> Type of matrix cell. </typeparam>
    public static void PrintMatrix <T>(T[,] matrix, int width, int height)
        where T : struct
    {
        GameLogger.LogMessage("=========================", "MatrixPrint");
        for (int i = 0; i < height; i++)
        {
            string buffer = string.Empty;
            for (int j = 0; j < width; j++)
            {
                buffer += Convert.ToInt32(matrix[i, j]);
            }

            GameLogger.LogMessage(buffer, "MatrixPrint");
        }

        GameLogger.LogMessage("=========================", "MatrixPrint");
    }
Exemple #19
0
        /// <summary>
        /// 移除模组包
        /// </summary>
        /// <param name="modUid">模组包UID</param>
        /// <returns>返回操作是否成功</returns>
        public bool UnLoadGameMod(string packageName)
        {
            GameMod mod = FindGameMod(packageName);

            if (mod == null)
            {
                GameLogger.Warning(TAG, "无法卸载模组 {0},因为没有加载", packageName);
                GameErrorManager.LastError = GameError.NotRegister;
                return(false);
            }

            mod.Destroy();
            gameMods.Remove(mod);
            GameManager.GameMediator.DispatchGlobalEvent(GameEventNames.EVENT_MOD_UNLOAD, "*", mod.PackageName, mod);

            return(true);
        }
Exemple #20
0
        /// <summary>
        /// 注册一个关卡文件
        /// </summary>
        /// <param name="path">文件路径</param>
        /// <returns></returns>
        public GameLevel RegisterLevel(string path)
        {
            GameLevel level = FindLevel(path);

            if (level != null)
            {
                return(level);
            }
            level = new GameLevel(path, this);
            if (!level.Init())
            {
                return(null);
            }

            GameLogger.Log(TAG, "Register level \"{0}\"", level);
            return(level);
        }
Exemple #21
0
        /// <summary>
        /// 取消注册球
        /// </summary>
        /// <param name="name">球类型名称</param>
        private bool UnRegisterBall(string name)
        {
            GameBall targetBall = GetRegisteredBall(name);

            if (targetBall != null)
            {
                ballTypes.Remove(targetBall);
                targetBall.Destroy();
                return(true);
            }
            else
            {
                GameLogger.Warning(TAG, "无法取消注册球 {0} 因为它没有注册", name);
                GameErrorManager.LastError = GameError.NotRegister;
                return(false);
            }
        }
Exemple #22
0
    public void SelectBrush(MapObject brushType)
    {
        if (this.selectedBrush >= MapObject.PortalRed && this.selectedBrush <= MapObject.PortalYellow && brushType != this.selectedBrush &&
            this.portalMap[this.selectedBrush].Item1 != null && this.portalMap[this.selectedBrush].Item2 == null)
        {
            var portalPos = new Vector2Int(Mathf.RoundToInt(this.portalMap[this.selectedBrush].Item1.transform.position.x),
                                           Mathf.RoundToInt(this.portalMap[this.selectedBrush].Item1.transform.position.y));
            Destroy(this.map[portalPos.y][portalPos.x].obj);
            this.map[portalPos.y][portalPos.x].obj = Instantiate(this.brushes[MapObject.Floor], new Vector3(portalPos.x, portalPos.y, 0), Quaternion.identity);
            this.map[portalPos.y][portalPos.x].obj.transform.SetParent(this.grid.transform);
            this.map[portalPos.y][portalPos.x].alias = MapObject.Floor;
            this.portalMap[this.selectedBrush].Item1 = null;
        }

        this.selectedBrush = brushType;
        GameLogger.LogMessage($"Brush selected is {brushType}", "EditorManager");
    }
        /// <summary>
        /// 根据全路径获取UI组件
        /// </summary>
        public Component GetUIComponent(string path, string typeName)
        {
            Transform element = GetUIElement(path);

            if (element == null)
            {
                return(null);
            }

            Component component = element.GetComponent(typeName);

            if (component == null)
            {
                GameLogger.Warning($"Not found ui component : {path}, {typeName}");
            }
            return(component);
        }
Exemple #24
0
    void TestNull_01()
    {
        GameObject go = new GameObject();
        Object     ob = new Object();

        GameLogger.Log("go == null : " + (go == null));     // false
        GameLogger.Log("ob == null : " + (ob == null));     //true

        /*
         * Instatiating a GameObject adds it to the scene so it’s completely initialized (!destroyed).
         *  Instantiating a simple UnityEngine.Object has no such semantics, so the it stays in the ‘destroyed’ state which compares true to null.
         *
         *  这段话的意思是 建立一个游戏对象添加到场景中,这个对象是完全被建立的(分配了内存空间)
         *  建立一个简单的UnityEngine.Object 对象是没有明确的语义的,(也是就是说不明确的制定,Object是基类,可以这么理解,你只说了我要一个东西,却不知道要什么东西,所以系统也就没办法去给你分配东西)
         *  所以它的存在是相当于 销毁状态的(也就是null的状态)。所以上边第二个结果就是返回true了,这个是一个特殊的情况
         */
    }
    void Start()
    {
        Application.runInBackground = true;

        reporter      = FindObjectOfType(typeof(Reporter)) as Reporter;
        reporter.show = true;
        GameLogger.Log("test long text sdf asdfg asdfg sdfgsdfg sdfg sfg" +
                       "sdfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdfg " +
                       "sdfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdfg " +
                       "sdfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdfg " +
                       "sdfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdfg " +
                       "sdfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdfg ssssssssssssssssssssss" +
                       "asdf asdf asdf asdf adsf \n dfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdf" +
                       "asdf asdf asdf asdf adsf \n dfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdf" +
                       "asdf asdf asdf asdf adsf \n dfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdf" +
                       "asdf asdf asdf asdf adsf \n dfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdf" +
                       "asdf asdf asdf asdf adsf \n dfgsdfg sdfg sdf gsdfg sfdg sf gsdfg sdfg asdf");

        style                  = new GUIStyle();
        style.alignment        = TextAnchor.MiddleCenter;
        style.normal.textColor = Color.white;
        style.wordWrap         = true;

        //for (int i = 0; i < 10; i++) {
        //	GameLogger.Log("Test Collapsed log");
        //	GameLogger.LogWarning("Test Collapsed Warning");
        //	GameLogger.LogError("Test Collapsed Error");
        //}

        //for (int i = 0; i < 10; i++) {
        //	GameLogger.Log("Test Collapsed log");
        //	GameLogger.LogWarning("Test Collapsed Warning");
        //	GameLogger.LogError("Test Collapsed Error");
        //}

        rect1 = new Rect(Screen.width / 2 - 120, Screen.height / 2 - 225, 240, 50);
        rect2 = new Rect(Screen.width / 2 - 120, Screen.height / 2 - 175, 240, 100);
        rect3 = new Rect(Screen.width / 2 - 120, Screen.height / 2 - 50, 240, 50);
        rect4 = new Rect(Screen.width / 2 - 120, Screen.height / 2, 240, 50);
        rect5 = new Rect(Screen.width / 2 - 120, Screen.height / 2 + 50, 240, 50);
        rect6 = new Rect(Screen.width / 2 - 120, Screen.height / 2 + 100, 240, 50);

        //thread = new Thread(new ThreadStart(threadLogTest));
        //thread.Start();
    }
    public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
    {
        if (!enabled)
        {
            return(true);
        }

        Sprite sprite = image.overrideSprite;

        if (sprite == null)
        {
            return(true);
        }

        Vector2 local;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(image.rectTransform, screenPoint, eventCamera, out local);

        Rect rect = image.rectTransform.rect;

        // Convert to have lower left corner as reference point.
        local.x += image.rectTransform.pivot.x * rect.width;
        local.y += image.rectTransform.pivot.y * rect.height;

        float u = local.x / rect.width;
        float v = local.y / rect.height;

        try
        {
            if (!reversed)
            {
                return(sprite.texture.GetPixelBilinear(u, v).a != 0);
            }
            else
            {
                return(sprite.texture.GetPixelBilinear(u, v).a == 0);
            }
        }
        catch (UnityException e)
        {
            GameLogger.LogError(e);
        }

        return(true);
    }
Exemple #27
0
        public void ConfigureLogging_ShouldCreateDirectoryIfNotExist()
        {
            try {
                var files = Directory.GetFiles(GameLogger.LOGS_DIR);
                foreach (string file in files)
                {
                    File.Delete(file);
                }
                Directory.Delete(GameLogger.LOGS_DIR);
            }
            catch (DirectoryNotFoundException) {
                // It's ok
            }

            GameLogger.ConfigureLogging();
            Assert.AreEqual(true, Directory.Exists(@"Logs"));
            GameLogger.CloseLog();
        }
    public void StopPlaying()
    {
        audioSource.Stop();
        ClearChildren();
        listIndex = 0;
        GameObject.Destroy(audioGameObject);
        myLoadedAssetBundle.Unload(true);
        foreach (ClickAreaCtrl c in clickAreas)
        {
            c.gameObject.SetActive(false);
        }
        gameUI.SetActive(false);
        pickUI.SetActive(true);
        gameElements.SetActive(false);
        gameObject.SetActive(false);

        GameLogger.ExportToDisk();
    }
Exemple #29
0
        protected virtual void VisualizeWindow_OnClosing(object sender, CancelEventArgs e)
        {
            _persistentGameMain?.Dispose();
            _persistentGameMain = null;
            GameMain?.Dispose();
            GameMain = null;

            AiLoggers[0]?.Dispose();
            AiLoggers[1]?.Dispose();
            GameLogger?.Dispose();

            if (_isForceClosing)
            {
                return;
            }
            e.Cancel = true;
            Hide();
        }
Exemple #30
0
    /// <summary>
    /// Bootstrap the game state and data.
    /// </summary>
    protected void Awake()
    {
        InitLogging();
        GameLogger.Info("Game started.");

        lock (_singletonLock)
        {
            if (_singleton != null)
            {
                GameLogger.FatalError("It appears there are multiple root Game objects.");
            }

            _singleton = this;
        }

        GameLogger.Info("Creating game objects.");
        InitGameObjects();
    }