void UiInfo(string mes, Color col)
    {
        GameInfoUI info = gameObject.AddComponent <GameInfoUI>();

        info.SetButton(LocaleManager.locale.OK, () => { info.HideMessage(); Destroy(info); });
        info.ShowMessage(mes, col);
    }
Exemple #2
0
    public override void Init()
    {
        if (isInit == true)
        {
            return;
        }

        string[] panelNames = new string[] {
            "South_Panel", "East_Panel", "North_Panel", "West_Panel"
        };
        float[] eulerAngles = new float[] {
            0f, 90f, 180f, -90f
        };

        // init player ui.
        for (int i = 0; i < GameSettings.PlayerCount; i++)
        {
            string dir         = panelNames[i];
            float  eulerAngleZ = eulerAngles[i];

            Transform dirParent = transform.Find(dir);
            Transform uiTran    = dirParent.Find("PlayerUI");
            if (uiTran == null)
            {
                uiTran                  = ResManager.CreatePlayerUIObject().transform;
                uiTran.parent           = dirParent;
                uiTran.localScale       = Vector3.one;
                uiTran.localEulerAngles = new Vector3(0, 0, eulerAngleZ);
            }

            PlayerUI ui = uiTran.GetComponent <PlayerUI>();
            ui.Init();

            UIPanel parentPanel = dirParent.GetComponent <UIPanel>();
            ui.SetParentPanelDepth(parentPanel.depth);

            playerUIDict.Add(i, ui);
            //Debug.LogWarningFormat("PlayerUI: {0} {1}", i, dir);
        }

        gameInfo = transform.Find("Info_Panel/GameInfo").GetComponent <GameInfoUI>();

        ResManager.SetPoolRoot(mahjongPoolRoot);

        isInit = true;

        hasShining = false;

        ResManager.LoadStringTable(true);
    }
Exemple #3
0
    void Start()
    {
        //Change gravity direction
        //this should have no effect anymore
        //Physics2D.gravity = new Vector3(0,0,-1);

        //Aplication settings
                #if UNITY_ANDROID
        //do not turn the screen off while the game is running
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
                #endif
        //do we run the application while its in the background?
        //Generally no, however, in a PC build, this is useful to have set to true
        Application.runInBackground = false;

        //Create world object
        world = gameObject.AddComponent <World>();
        //find the UI object (added in inspector)
        ui = FindObjectOfType <UIController>();
        //Let the world create references to its variables
        world.Init();

        //Game setup
        //this order is not arbitrary by the way - World has to be created before terrain and before cars
        //this creates the world - roads, buildings, etc
        world.CreateWorld(string.Format("Levels/{0}/world", LevelManager.level));
        //this creates the terrain - water, sidewalks, etc
        world.CreateTerrain(string.Format("Levels/{0}/terrain", LevelManager.level));
        //this creates the cars - loads their starting points, their tanks, trips, etc
        CarFactory.CurrentSerialNumber = 1;
        world.SpawnCars(string.Format("Levels/{0}/cars", LevelManager.level));
        //this creates the textures around the world
        world.SurroundWorld();

        //Set up tutorials if they are available
        TutorialPresenter presenter = gameObject.AddComponent <TutorialPresenter>();
        presenter.Prepare(Resources.Load <TextAsset>(string.Format("Levels/{0}/tutorials", LevelManager.level)));
        tutpresenter = presenter;

        //Load the level properties - see LevelProperties for a full list
        LevelProperties level = LevelProperties.Parse(Utils.ReadText(string.Format("Levels/{0}/props", LevelManager.level)));
        if (level is null)
        {
            Debug.Log("Failed to parse level.");
        }

        //Add level script if its available (otherwise add generic script)
        if (!(level.ScriptName is null))
        {
            levelScript = (LevelScript)gameObject.AddComponent(Type.GetType(level.ScriptName));
        }
        if (levelScript is null)
        {
            Debug.Log("Adding a generic level script");
            levelScript = gameObject.AddComponent <GenericLevelScript>();
        }

        //Set up stuff
        resource = level.MaxResource;
        LevelManager.properties = level;
        ui.SetupUserUI(level);

        Debug.Log("World is created and prepared");
        //Create the GameInfoUI
        gameui = gameObject.AddComponent <GameInfoUI>();

        //Call level script event
        levelScript.OnLevelLoaded();
    }