Exemplo n.º 1
0
        //This is for a future update :D
        //const string SteamApiKey = "D57A6B0437CB735FFEE9317A9D42CCAA";

        protected override void Load()
        {
            instance = this;

            RocketLogger.Log(string.Format("Welcome to Gun Game v{0}!", Assembly.GetName().Version), ConsoleColor.Yellow);
            RocketLogger.Log("For any update information or support join my Discord Guild: discord.gg/BaE4Tka!", ConsoleColor.Yellow);

            GunGameConfig.Initialize();
            GameManager.Initialize();
            CommandManager.Initialize();
            EconomyManager.Initialize();

            if (GunGameConfig.instance.sqlSettings.enabled)
            {
                if (!SQLManager.Initialize())
                {
                    GunGamePlayerConfig.Initialize();
                    IsMySqlEnabled = false;
                    RocketLogger.Log("NOTE: Connection to MySQL database failed!", ConsoleColor.Red);
                    RocketLogger.Log("Initialized with MySQL support disabled.", ConsoleColor.Yellow);
                }
                else
                {
                    RocketLogger.Log("Initialized with MySQL support enabled.", ConsoleColor.Yellow);
                }
            }
            else
            {
                GunGamePlayerConfig.Initialize();
                IsMySqlEnabled = false;
                RocketLogger.Log("Initialized with MySQL support disabled.", ConsoleColor.Yellow);
            }

            EventManager.Register();

            if (GunGameConfig.instance.positions[0].x == 0 && GunGameConfig.instance.positions[0].y == 0 && GunGameConfig.instance.positions[0].z == 0)
            {
                RocketLogger.Log("NOTE: You have not set any spawn positions yet!", ConsoleColor.Yellow);
            }

            if (GunGameConfig.instance.safezone.x == 0 && GunGameConfig.instance.safezone.y == 0 && GunGameConfig.instance.safezone.z == 0)
            {
                RocketLogger.Log("NOTE: You have not set the lobby yet!", ConsoleColor.Yellow);
            }

            isLoaded = true;
        }
Exemplo n.º 2
0
    private void Initialize()
    {
        Inst      = this;
        Constants = transform.GetComponent <Constants>();
        Constants.Initialize();
        MainCamera = Camera.main;
        CameraController.Initialize();

        DBManager = new DBManager();
        DBManager.Initialize();

        SaveGameManager = new SaveGameManager();
        LevelAnchor     = GameObject.FindObjectOfType <LevelAnchor>();

        if (LevelAnchor == null)
        {
            GameObject o = GameObject.Instantiate(Resources.Load("LevelAnchor")) as GameObject;
            LevelAnchor = o.GetComponent <LevelAnchor>();
        }

        MaterialManager = new MaterialManager();
        MaterialManager.Initialize();

        SoundManager = new SoundManager();
        SoundManager.Initialize();

        ItemManager = new ItemManager();
        ItemManager.Initialize();

        EconomyManager = new EconomyManager();

        if (SceneType == SceneType.Space)
        {
            Debug.Log("Loading space scene");


            NPCManager = new NPCManager();
            NPCManager.Initialize();

            UIManager = new UIManager();


            CursorManager = new CursorManager();
            CursorManager.Initialize();

            PlayerProgress = new PlayerProgress();
            PlayerProgress.Initialize();

            PlayerControl = new PlayerControl();
            PlayerControl.Initialize();

            WorldManager = new WorldManager();
            WorldManager.PreInitialize();



            //temporarily spawn player at a station to undock
            //StationBase station = GameObject.Find("PlanetColombiaLanding").GetComponent<StationBase>();
            //station.Undock(PlayerControl.PlayerShip);

            //check if there's anchor save
            StarSystem system = null;
            if (LevelAnchor != null && !LevelAnchor.IsNewGame)
            {
                //load system from anchor save
                Debug.Log("Loading from anchor!");
                system = DBManager.XMLParserWorld.GenerateSystemScene(LevelAnchor.SpawnSystem);
                SaveGameManager.GetSave(LevelAnchor.ProfileName);
            }
            else if (LevelAnchor.IsNewGame)
            {
                //load a new game
                SaveGameManager.LoadNewGameInSpace();
                system = DBManager.XMLParserWorld.GenerateSystemScene(GameManager.Inst.PlayerProgress.SpawnSystemID);
            }


            WorldManager.CurrentSystem = system;
            WorldManager.InitializeSpace();

            EconomyManager.Initialize();

            if (LevelAnchor != null && !LevelAnchor.IsNewGame)
            {
                SaveGameManager.LoadSaveInSpace();
            }

            Debug.Log("About to create the player");
            PlayerControl.CreatePlayerParty();
            PlayerControl.LoadPlayerShip();

            UIManager.Initialize();

            if (LevelAnchor != null && !LevelAnchor.IsNewGame)
            {
                PlayerControl.SpawnPlayer();
            }

            LevelAnchor.IsNewGame = false;
        }
        else if (SceneType == SceneType.SpaceTest)
        {
            NPCManager = new NPCManager();
            NPCManager.Initialize();

            UIManager = new UIManager();
            //UIManager.Initialize();

            CursorManager = new CursorManager();
            CursorManager.Initialize();

            PlayerControl = new PlayerControl();
            PlayerControl.Initialize();

            WorldManager = new WorldManager();

            //WorldManager.Initialize();

            /*
             * GameObject [] npcs = GameObject.FindGameObjectsWithTag("NPC");
             * foreach(GameObject o in npcs)
             * {
             *      AI ai = o.GetComponent<AI>();
             *      ai.Initialize();
             *      NPCManager.AddExistingShip(ai.MyShip);
             * }
             */
            //temporarily spawn player at a station to undock
            //StationBase station = GameObject.Find("PlanetColombiaLanding").GetComponent<StationBase>();
            //station.Undock(PlayerControl.PlayerShip);
        }
        else if (SceneType == SceneType.Station)
        {
            UIManager = new UIManager();
            UIManager.Initialize();

            PlayerProgress = new PlayerProgress();
            PlayerProgress.Initialize();

            WorldManager = new WorldManager();
            WorldManager.PreInitialize();
            WorldManager.InitializeDocked();

            EconomyManager.Initialize();

            NPCManager = new NPCManager();
            NPCManager.InitializeDocked();

            if (LevelAnchor != null && !LevelAnchor.IsNewGame)
            {
                SaveGameManager.GetSave(LevelAnchor.ProfileName);
                SaveGameManager.LoadSaveInStation();
            }
            else if (LevelAnchor.IsNewGame)
            {
                SaveGameManager.LoadNewGameInStation();
            }

            LevelAnchor.IsNewGame = false;
        }
    }