//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("CURRENT GAME PTR NULL: RETURNING TO MAIN MENU");

			//TODO -- spawn error message, return to main menu
		}

		//populate map of level buttons
		LevelButtonEventHandler[] levelButtons = GetComponentsInChildren<LevelButtonEventHandler>();
		foreach(LevelButtonEventHandler handler in levelButtons)
		{
			Button button = handler.gameObject.GetComponent<Button>();
			if(button != null)
			{
				mLevelButtonMap.Add(handler, button);
			}
		}

		//TODO -- init high scores using the game manager and current game ptr
		//TODO -- enable / disable buttons based on current game ptr level completion

		//sanity check -- null any selected level data on the current game ptr
		mSavedGameManager.getCurrentGame().setSelectedLevel(SceneIndex.NULL);
		mSelectedLevel = SceneIndex.NULL;
	}
//--------------------------------------------------------------------------------------------

	public void handleLevelCompleted(SceneIndex level)
	{
		isLevelComplete = true;

		//get the saved game manager
		gameManager = GameObject.Find("SavedGameManager").GetComponent<SavedGameManager>();
		if(gameManager == null)
		{
			return;
		}

		//save whether or not the final chassis was used
		didUseFinalChassis = gameManager.getCurrentGame().getCurrentLoadout().getChasis() == Loadout.LoadoutChasis.FINAL;

		//save the score, and if there were no hits (if player not hit, bonus added to final score)
		score = GameObject.Find("Score").GetComponent<Score>();
		finalScore = score.wasPlayerHit ? 
			score.trueScore : 
			score.trueScore + (int)PointVals.NO_HITS;

		//save score and get the old high scores
		oldPersonalHighScore = gameManager.getCurrentGame().highScores[(int)level - 3];
		oldGlobalHighScore = gameManager.globalHighScores[(int)level - 3];

		//save game
		gameManager.handleLevelCompleted(level, finalScore, didUseFinalChassis);

		//now we can activate the panel and run its animations
		gameObject.SetActive(true);
		StartCoroutine(handlePanelAnimations());

		//activate the button
		button.Select();
	}
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = SavedGameManager.createOrLoadSavedGameManager(gmPrefab).GetComponent<SavedGameManager>();
		StartCoroutine(mScreenFader.FadeFromBlack());

		lastButtonClicked = null;
	}
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = SavedGameManager.createOrLoadSavedGameManager(gmPrefab).GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("ERROR: CURRENT GAME PTR NULL -- LOADING MAIN MENU");
			SceneManager.LoadScene((int)SceneIndex.MAIN_MENU);
			return;
		}

		//init the sprite arrays
		levelTitleSprites = Resources.LoadAll<Sprite>("GUI_Assets/LevelTitles");
		levelButtonSprites = Resources.LoadAll<Sprite>("GUI_Assets/LevelButtonIcons");
		levelImgSprites = Resources.LoadAll<Sprite>("GUI_Assets/WorldIcons");
		stageButtonSprites = Resources.LoadAll<Sprite>("GUI_Assets/StageButtonIcons");

		//hide classified levels / worlds
		setLevelButtonsClassified();

		//need to get a handle on the final chassis stars
		finalChassisStars = mStagePanel.GetComponentsInChildren<FinalChassisStar>();

		//tutorial always unlocked, init menu to this
		lastButtonClicked = mLevelPanel.GetComponentInChildren<Button>();
		lastButtonClicked.Select();
		handleLevelButtonMouseOver(0);

		//sanity check -- null any selected level data on the current game ptr
		mSavedGameManager.getCurrentGame().setSelectedLevel(SceneIndex.NULL);
		mSelectedLevel = SceneIndex.NULL;

		StartCoroutine(mScreenFader.FadeFromBlack());
	}
//--------------------------------------------------------------------------------------------

	void OnEnable()
	{
		mName = "";

		mMainMenu = GetComponentInParent<MainMenuEventHandler>();
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		StartCoroutine(buildList());
	}
	//

//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		//TODO -- temp
		if(mSavedGameManager.getCurrentGame() == null)
		{
			mSavedGameManager.createNewGame("test");
		}
	}
//--------------------------------------------------------------------------------------------

	void Start()
	{
		//on startup, set the static object if we haven't already
		if(mInstance == null)
		{
			mInstance = this;
			isGodMode = GOD_MODE;
			GameObject.DontDestroyOnLoad(gameObject);
		}
		else
		{
			Destroy(gameObject);
			return;
		}

		//set saved game file location
		switch((int)Environment.OSVersion.Platform)
		{
		case 0:
		case 1:
		case 2:
		case 3:
			Debug.Log("PLATFORM DETECTED: WINDOWS");

			mSavedGameFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Cull_the_Swarm";
			Directory.CreateDirectory(mSavedGameFile);
			mSavedGameFile += "\\saved_games.ini";

			break;

		case 4:
		case 6:
			Debug.Log("PLATFORM DETECTED: UNIX / MAC");

			mSavedGameFile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/Library/Cull_the_Swarm";
			Directory.CreateDirectory(mSavedGameFile);
			mSavedGameFile += "/saved_games.ini";

			break;

		default:
			Debug.Log("UNHANDLED PLATFORM: " + Environment.OSVersion.Platform);
			mSavedGameFile = "";
			break;
		}


		Debug.Log("SAVED GAME FILE: " + mSavedGameFile);

		//read from the saved game file on startup
		if(!readSavedGameFile())
		{
			Debug.Log("ERROR READING FROM SAVED GAME FILE!");
		}
	}
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = SavedGameManager.createOrLoadSavedGameManager(gmPrefab).GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("ERROR: CURRENT GAME PTR NULL -- LOADING MAIN MENU");
			SceneManager.LoadScene((int)SceneIndex.MAIN_MENU);
			return;
		}

		//init resource arrays
		buttonSprites = Resources.LoadAll<Sprite>("GUI_Assets/Menu_Loadouts");
		iconSprites = Resources.LoadAll<Sprite>("GUI_Assets/LoadoutIcons_new");

		elementStrings = new string[16, 3]		//name, description, unlock
		{
			{"Exterminator", 		"Standard issue chassis. Takes 3 hits.", 									"-"},
			{"Final", 				"Breaks after a single hit, but radiates a mysterious energy...", 			"Complete Tutorial 3 to unlock!"},
			{"Booster", 			"Slower than the Exterminator, but Precision gives you a speed boost.", 	"Complete Level 1-1 to unlock!"},
			{"Shrink", 				"Slower than the Exterminator, but your hitbox in Precision is SMALL.", 	"Complete Level 2-2 to unlock!"},
			{"Quick", 				"Quicker but weaker than the Exterminator. Secondaries recharge faster.", 	"Complete Level 3-3 to unlock!"},

			{"Bug Repellants", 		"Standard issue anti-bug bullets.", 										"-"},
			{"No-Miss Swatter", 	"Fire and forget! Automatically attacks the nearest enemy.", 				"Complete Tutorial 2 to unlock!"},
			{"Precision Pesticide", "Laser that sweeps from side to side as you move.", 						"Complete Level 1-2 to unlock!"},
			{"Citronella Flame", 	"Shoots a short, but powerful cone of fire.", 								"Complete Level 2-1 to unlock!"},
			{"Volt Lantern", 		"Powerful forward and rear facing lasers.", 								"Complete Level 3-2 to unlock!"},

			{"EMP Counter", 		"Disrupts enemy firing systems and clears the area of bullets.", 			"-"},
			{"Phasing System", 		"Renders your ship invulnerable for a short time.", 						"Complete Tutorial 1 to unlock!"},
			{"Holo-Duplicate", 		"Deploys a hologram of your ship that enemies attack instead.", 			"Complete Level 1-3 to unlock!"},
			{"Mosquito Tesla Coil", "Hold to absorb bullets. Release to send damage back. Does not recharge!", 	"Complete Level 2-3 to unlock!"},
			{"Freeze Ray", 			"Starts a chain reaction that freezes nearby enemy bullets.", 				"Complete Level 3-1 to unlock!"},

			{"-", "-", "-"}
		};

		//sanity check -- null any current loadout data on the current game ptr
		mSavedGameManager.getCurrentGame().setCurrentLoadout(null);
		mCurrentLoadout = new Loadout();

		//initialize the default loadout
		mCurrentLoadout.setChasis(Loadout.LoadoutChasis.EXTERMINATOR);
		mCurrentLoadout.setPrimary(Loadout.LoadoutPrimary.REPEL);
		mCurrentLoadout.setSecondary(Loadout.LoadoutSecondary.EMP);

		//init menu as though chassis button has been clicked
		chassisButton.Select();
		handleChassisButtonClicked();

		StartCoroutine(mScreenFader.FadeFromBlack());
		StartCoroutine(handleIconAnimation());
	}
//--------------------------------------------------------------------------------------------

	void OnEnable()
	{
		mName = "";

		mNameField.onValueChanged.AddListener( delegate{ handleTextEditValueChanged(); } );
		mNameField.onEndEdit.AddListener( delegate{ handleEditFinished(); } );

		mMainMenu = GetComponentInParent<MainMenuEventHandler>();
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		mNameField.Select();
	}
Exemple #10
0
        private void SaveGameDialogIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!((bool)e.NewValue))
            {
                return;
            }

            DataContext = SavedGameManager.FindSavedGames(includeAutoSave: false);

            SaveGameFilename.Clear();
            SaveGameFilename.Text = GenerateFileName(GameContext.Current);
            SaveGameFilename.Focus();
            SaveGameFilename.SelectAll();
        }
Exemple #11
0
    // Use this for initialization
    void OnEnable()
    {
        displaySavedGames(SavedGameManager.getSavedGames());
        inputField.onValueChanged.AddListener((str) => activeString = str);
        string msg;

        if (loadGameMode)
        {
            msg = "load";
        }
        else
        {
            msg = "save";
        }
        actionButton.GetComponentInChildren <Text>().text = msg;
        actionButton.onClick.AddListener(() => { var a = loadGameMode? loadGame(): saveGame(); });
    }
Exemple #12
0
    void Awake()
    {
        //Check if instance already exists
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(this);
        }

        saveData = new SaveData();

        //Get Player Controller in scene
        playerController = GameObject.FindObjectOfType <PlayerController>();
    }
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("CURRENT GAME PTR NULL: RETURNING TO MAIN MENU");

			//TODO -- spawn error message, return to main menu
		}

		//TODO -- enable / disable loadout buttons using current game ptr's avaialble loadouts

		//sanity check -- null any current loadout data on the current game ptr
		mSavedGameManager.getCurrentGame().setCurrentLoadout(null);
		mCurrentLoadout = new Loadout();
	}
	//TODO -- array for global high scores

//--------------------------------------------------------------------------------------------

	void Start()
	{
		//on startup, set the static object if we haven't already
		if(mInstance == null)
		{
			mInstance = this;
			GameObject.DontDestroyOnLoad(gameObject);
		}
		else
		{
			Destroy(gameObject);
			return;
		}

		//read from the saved game file on startup
		if(!readSavedGameFile())
		{
			Debug.Log("ERROR READING FROM SAVED GAME FILE!");
		}
	}
Exemple #15
0
        private void FSWEvent(FileSystemEventArgs e)
        {
            Logger.Log("FSW Event: " + e.FullPath);

            if (Path.GetFileName(e.FullPath) == "SAVEGAME.NET")
            {
                if (!gameSaved)
                {
                    bool success = SavedGameManager.InitSavedGames();

                    if (!success)
                    {
                        return;
                    }
                }

                gameSaved = true;

                SavedGameManager.RenameSavedGame();
            }
        }
Exemple #16
0
        /// <summary>
        /// Refreshes the UI  based on the latest saved game
        /// and information in the saved spawn.ini file, as well
        /// as information on whether the local player is the host of the game.
        /// </summary>
        public void Refresh(bool isHost)
        {
            isSettingUp = true;
            IsHost      = isHost;

            SGPlayers.Clear();
            Players.Clear();
            ddSavedGame.Items.Clear();
            lbChatMessages.Clear();
            lbChatMessages.TopIndex = 0;

            ddSavedGame.AllowDropDown = isHost;
            btnLoadGame.Text          = isHost ? "Load Game" : "I'm Ready";

            IniFile spawnSGIni = new IniFile(ProgramConstants.GamePath + "Saved Games\\spawnSG.ini");

            loadedGameID          = spawnSGIni.GetStringValue("Settings", "GameID", "0");
            lblMapNameValue.Text  = spawnSGIni.GetStringValue("Settings", "UIMapName", string.Empty);
            lblGameModeValue.Text = spawnSGIni.GetStringValue("Settings", "UIGameMode", string.Empty);

            uniqueGameId = spawnSGIni.GetIntValue("Settings", "GameID", -1);

            int playerCount = spawnSGIni.GetIntValue("Settings", "PlayerCount", 0);

            SavedGamePlayer localPlayer = new SavedGamePlayer();

            localPlayer.Name       = ProgramConstants.PLAYERNAME;
            localPlayer.ColorIndex = MPColors.FindIndex(
                c => c.GameColorIndex == spawnSGIni.GetIntValue("Settings", "Color", 0));

            SGPlayers.Add(localPlayer);

            for (int i = 1; i < playerCount; i++)
            {
                string sectionName = "Other" + i;

                SavedGamePlayer sgPlayer = new SavedGamePlayer();
                sgPlayer.Name       = spawnSGIni.GetStringValue(sectionName, "Name", "Unknown player");
                sgPlayer.ColorIndex = MPColors.FindIndex(
                    c => c.GameColorIndex == spawnSGIni.GetIntValue(sectionName, "Color", 0));

                SGPlayers.Add(sgPlayer);
            }

            for (int i = 0; i < SGPlayers.Count; i++)
            {
                lblPlayerNames[i].Enabled = true;
                lblPlayerNames[i].Visible = true;
            }

            for (int i = SGPlayers.Count; i < 8; i++)
            {
                lblPlayerNames[i].Enabled = false;
                lblPlayerNames[i].Visible = false;
            }

            List <string> timestamps = SavedGameManager.GetSaveGameTimestamps();

            timestamps.Reverse(); // Most recent saved game first

            timestamps.ForEach(ts => ddSavedGame.AddItem(ts));

            if (ddSavedGame.Items.Count > 0)
            {
                ddSavedGame.SelectedIndex = 0;
            }

            CopyPlayerDataToUI();
            isSettingUp = false;
        }
Exemple #17
0
        public override void Initialize()
        {
            Name = "MultiplayerGameLobby";

            base.Initialize();

            InitPlayerOptionDropdowns();

            ReadyBoxes = new XNACheckBox[MAX_PLAYER_COUNT];

            int readyBoxX = GameOptionsIni.GetIntValue(Name, "PlayerReadyBoxX", 7);
            int readyBoxY = GameOptionsIni.GetIntValue(Name, "PlayerReadyBoxY", 4);

            for (int i = 0; i < MAX_PLAYER_COUNT; i++)
            {
                XNACheckBox chkPlayerReady = new XNACheckBox(WindowManager);
                chkPlayerReady.Name            = "chkPlayerReady" + i;
                chkPlayerReady.Checked         = false;
                chkPlayerReady.AllowChecking   = false;
                chkPlayerReady.ClientRectangle = new Rectangle(readyBoxX, ddPlayerTeams[i].ClientRectangle.Y + readyBoxY,
                                                               0, 0);

                PlayerOptionsPanel.AddChild(chkPlayerReady);

                chkPlayerReady.DisabledClearTexture   = chkPlayerReady.ClearTexture;
                chkPlayerReady.DisabledCheckedTexture = chkPlayerReady.CheckedTexture;

                ReadyBoxes[i] = chkPlayerReady;
                ddPlayerSides[i].AddItem("Spectator", AssetLoader.LoadTexture("spectatoricon.png"));
            }

            ddGameMode.ClientRectangle = new Rectangle(
                MapPreviewBox.ClientRectangle.X - 12 - ddGameMode.ClientRectangle.Width,
                MapPreviewBox.ClientRectangle.Y, ddGameMode.ClientRectangle.Width,
                ddGameMode.ClientRectangle.Height);

            lblGameModeSelect.ClientRectangle = new Rectangle(
                btnLaunchGame.ClientRectangle.X, ddGameMode.ClientRectangle.Y + 1,
                lblGameModeSelect.ClientRectangle.Width, lblGameModeSelect.ClientRectangle.Height);

            lbMapList.ClientRectangle = new Rectangle(btnLaunchGame.ClientRectangle.X,
                                                      MapPreviewBox.ClientRectangle.Y + 23,
                                                      MapPreviewBox.ClientRectangle.X - btnLaunchGame.ClientRectangle.X - 12,
                                                      MapPreviewBox.ClientRectangle.Height - 23);

            lbChatMessages                 = new ChatListBox(WindowManager);
            lbChatMessages.Name            = "lbChatMessages";
            lbChatMessages.ClientRectangle = new Rectangle(lbMapList.ClientRectangle.Left,
                                                           GameOptionsPanel.ClientRectangle.Y,
                                                           lbMapList.ClientRectangle.Width, GameOptionsPanel.ClientRectangle.Height - 24);
            lbChatMessages.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.LineHeight        = 16;

            tbChatInput                 = new XNASuggestionTextBox(WindowManager);
            tbChatInput.Name            = "tbChatInput";
            tbChatInput.Suggestion      = "Type here to chat..";
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.ClientRectangle.Left,
                                                        lbChatMessages.ClientRectangle.Bottom + 3,
                                                        lbChatMessages.ClientRectangle.Width, 21);
            tbChatInput.MaximumTextLength = 150;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            btnLockGame                 = new XNAClientButton(WindowManager);
            btnLockGame.Name            = "btnLockGame";
            btnLockGame.ClientRectangle = new Rectangle(btnLaunchGame.ClientRectangle.Right + 12,
                                                        btnLaunchGame.ClientRectangle.Y, 133, 23);
            btnLockGame.Text       = "Lock Game";
            btnLockGame.LeftClick += BtnLockGame_LeftClick;

            AddChildToFirstIndex(lbChatMessages);
            AddChildToFirstIndex(tbChatInput);
            AddChild(btnLockGame);

            MapPreviewBox.LocalStartingLocationSelected += MapPreviewBox_LocalStartingLocationSelected;
            MapPreviewBox.StartingLocationApplied       += MapPreviewBox_StartingLocationApplied;

            InitializeWindow();

            sndJoinSound     = new PrioritizedSound("joingame.wav");
            sndLeaveSound    = new PrioritizedSound("leavegame.wav");
            sndMessageSound  = new PrioritizedSound("message.wav");
            sndGetReadySound = new PrioritizedSound("getready.wav", 0.0, 0.0, 5.0f);

            if (SavedGameManager.AreSavedGamesAvailable())
            {
                fsw = new FileSystemWatcher(ProgramConstants.GamePath + "Saved Games", "*.NET");
                fsw.EnableRaisingEvents = false;
                fsw.Created            += fsw_Created;
                fsw.Changed            += fsw_Created;
            }
            else
            {
                Logger.Log("MultiplayerGameLobby: Saved games are not available!");
            }

            CenterOnParent();

            // To move the lblMapAuthor label into its correct position
            // if it was moved in the theme description INI file
            LoadDefaultMap();
        }
Exemple #18
0
        /// <summary>
        /// Changes the game lobby's UI depending on whether the local player is the host.
        /// </summary>
        /// <param name="isHost">Determines whether the local player is the host of the game.</param>
        protected void Refresh(bool isHost)
        {
            IsHost   = isHost;
            switched = false;
            Locked   = false;

            MapPreviewBox.EnableContextMenu = IsHost;

            btnLaunchGame.Text = IsHost ? "Launch Game" : "I'm Ready";

            if (IsHost)
            {
                ShowMapList();

                btnLockGame.Text    = "Lock Game";
                btnLockGame.Enabled = true;
                btnLockGame.Visible = true;

                foreach (GameLobbyDropDown dd in DropDowns)
                {
                    dd.InputEnabled = true;
                }

                foreach (GameLobbyCheckBox checkBox in CheckBoxes)
                {
                    checkBox.InputEnabled = true;
                }

                GenerateGameID();
            }
            else
            {
                HideMapList();

                btnLockGame.Enabled = false;
                btnLockGame.Visible = false;

                foreach (GameLobbyDropDown dd in DropDowns)
                {
                    dd.InputEnabled = false;
                }

                foreach (GameLobbyCheckBox checkBox in CheckBoxes)
                {
                    checkBox.InputEnabled = false;
                }
            }

            LoadDefaultMap();

            lbChatMessages.Clear();
            lbChatMessages.TopIndex = 0;

            if (SavedGameManager.AreSavedGamesAvailable())
            {
                fsw.EnableRaisingEvents = true;
            }

            if (SavedGameManager.GetSaveGameCount() > 0)
            {
                lbChatMessages.AddItem("Multiplayer saved games from a previous match have been detected. " +
                                       "The saved games of the previous match will be deleted if you create new saves during this match.",
                                       Color.Yellow, true);
            }
        }
        /// <summary>
        /// Changes the game lobby's UI depending on whether the local player is the host.
        /// </summary>
        /// <param name="isHost">Determines whether the local player is the host of the game.</param>
        protected void Refresh(bool isHost)
        {
            IsHost = isHost;
            Locked = false;

            UpdateMapPreviewBoxEnabledStatus();
            //MapPreviewBox.EnableContextMenu = IsHost;

            btnLaunchGame.Text = IsHost ? "Launch Game" : "I'm Ready";

            if (IsHost)
            {
                ShowMapList();

                btnLockGame.Text    = "Lock Game";
                btnLockGame.Enabled = true;
                btnLockGame.Visible = true;
                chkAutoReady.Disable();

                foreach (GameLobbyDropDown dd in DropDowns)
                {
                    dd.InputEnabled  = true;
                    dd.SelectedIndex = dd.UserDefinedIndex;
                }

                foreach (GameLobbyCheckBox checkBox in CheckBoxes)
                {
                    checkBox.AllowChanges = true;
                    checkBox.Checked      = checkBox.UserDefinedValue;
                }

                GenerateGameID();
            }
            else
            {
                HideMapList();

                btnLockGame.Enabled = false;
                btnLockGame.Visible = false;
                chkAutoReady.GetAttributes(ThemeIni);

                foreach (GameLobbyDropDown dd in DropDowns)
                {
                    dd.InputEnabled = false;
                }

                foreach (GameLobbyCheckBox checkBox in CheckBoxes)
                {
                    checkBox.AllowChanges = false;
                }
            }

            LoadDefaultMap();

            lbChatMessages.Clear();
            lbChatMessages.TopIndex = 0;

            lbChatMessages.AddItem("Type / to view a list of available chat commands.", Color.Silver, true);

            if (SavedGameManager.GetSaveGameCount() > 0)
            {
                lbChatMessages.AddItem("Multiplayer saved games from a previous match have been detected. " +
                                       "The saved games of the previous match will be deleted if you create new saves during this match.",
                                       Color.Yellow, true);
            }
        }
Exemple #20
0
        public override void Initialize()
        {
            Name              = "GameLoadingLobby";
            ClientRectangle   = new Rectangle(0, 0, 590, 510);
            BackgroundTexture = AssetLoader.LoadTexture("loadmpsavebg.png");

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Name            = "lblDescription";
            lblDescription.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblDescription.Text            = "Wait for all players to join and get ready, then click Load Game to load the saved multiplayer game.";

            panelPlayers = new XNAPanel(WindowManager);
            panelPlayers.ClientRectangle   = new Rectangle(12, 32, 373, 125);
            panelPlayers.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            panelPlayers.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;

            AddChild(lblDescription);
            AddChild(panelPlayers);

            lblPlayerNames = new XNALabel[8];
            for (int i = 0; i < 4; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name            = "lblPlayerName" + i;
                lblPlayerName.ClientRectangle = new Rectangle(9, 9 + 30 * i, 0, 0);
                lblPlayerName.Text            = "Player " + i;
                panelPlayers.AddChild(lblPlayerName);
                lblPlayerNames[i] = lblPlayerName;
            }

            for (int i = 4; i < 8; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name            = "lblPlayerName" + i;
                lblPlayerName.ClientRectangle = new Rectangle(190, 9 + 30 * (i - 4), 0, 0);
                lblPlayerName.Text            = "Player " + i;
                panelPlayers.AddChild(lblPlayerName);
                lblPlayerNames[i] = lblPlayerName;
            }

            lblMapName                 = new XNALabel(WindowManager);
            lblMapName.Name            = "lblMapName";
            lblMapName.FontIndex       = 1;
            lblMapName.ClientRectangle = new Rectangle(panelPlayers.Right + 12,
                                                       panelPlayers.Y, 0, 0);
            lblMapName.Text = "MAP:";

            lblMapNameValue                 = new XNALabel(WindowManager);
            lblMapNameValue.Name            = "lblMapNameValue";
            lblMapNameValue.ClientRectangle = new Rectangle(lblMapName.X,
                                                            lblMapName.Y + 18, 0, 0);
            lblMapNameValue.Text = "Map name";

            lblGameMode                 = new XNALabel(WindowManager);
            lblGameMode.Name            = "lblGameMode";
            lblGameMode.ClientRectangle = new Rectangle(lblMapName.X,
                                                        panelPlayers.Y + 40, 0, 0);
            lblGameMode.FontIndex = 1;
            lblGameMode.Text      = "GAME MODE:";

            lblGameModeValue                 = new XNALabel(WindowManager);
            lblGameModeValue.Name            = "lblGameModeValue";
            lblGameModeValue.ClientRectangle = new Rectangle(lblGameMode.X,
                                                             lblGameMode.Y + 18, 0, 0);
            lblGameModeValue.Text = "Game mode";

            lblSavedGameTime                 = new XNALabel(WindowManager);
            lblSavedGameTime.Name            = "lblSavedGameTime";
            lblSavedGameTime.ClientRectangle = new Rectangle(lblMapName.X,
                                                             panelPlayers.Bottom - 40, 0, 0);
            lblSavedGameTime.FontIndex = 1;
            lblSavedGameTime.Text      = "SAVED GAME:";

            ddSavedGame                 = new XNAClientDropDown(WindowManager);
            ddSavedGame.Name            = "ddSavedGame";
            ddSavedGame.ClientRectangle = new Rectangle(lblSavedGameTime.X,
                                                        panelPlayers.Bottom - 21,
                                                        Width - lblSavedGameTime.X - 12, 21);
            ddSavedGame.SelectedIndexChanged += DdSavedGame_SelectedIndexChanged;

            lbChatMessages      = new ChatListBox(WindowManager);
            lbChatMessages.Name = "lbChatMessages";
            lbChatMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.ClientRectangle   = new Rectangle(12, panelPlayers.Bottom + 12,
                                                             Width - 24,
                                                             Height - panelPlayers.Bottom - 12 - 29 - 34);

            tbChatInput                 = new XNATextBox(WindowManager);
            tbChatInput.Name            = "tbChatInput";
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        lbChatMessages.Bottom + 3, lbChatMessages.Width, 19);
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            btnLoadGame                 = new XNAClientButton(WindowManager);
            btnLoadGame.Name            = "btnLoadGame";
            btnLoadGame.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        tbChatInput.Bottom + 6, 133, 23);
            btnLoadGame.Text       = "Load Game";
            btnLoadGame.LeftClick += BtnLoadGame_LeftClick;

            btnLeaveGame                 = new XNAClientButton(WindowManager);
            btnLeaveGame.Name            = "btnLeaveGame";
            btnLeaveGame.ClientRectangle = new Rectangle(Width - 145,
                                                         btnLoadGame.Y, 133, 23);
            btnLeaveGame.Text       = "Leave Game";
            btnLeaveGame.LeftClick += BtnLeaveGame_LeftClick;

            AddChild(lblMapName);
            AddChild(lblMapNameValue);
            AddChild(lblGameMode);
            AddChild(lblGameModeValue);
            AddChild(lblSavedGameTime);
            AddChild(lbChatMessages);
            AddChild(tbChatInput);
            AddChild(btnLoadGame);
            AddChild(btnLeaveGame);
            AddChild(ddSavedGame);

            base.Initialize();

            sndGetReady     = new EnhancedSoundEffect("getready.wav");
            sndJoinSound    = new EnhancedSoundEffect("joingame.wav");
            sndLeaveSound   = new EnhancedSoundEffect("leavegame.wav");
            sndMessageSound = new EnhancedSoundEffect("message.wav");

            MPColors = MultiplayerColor.LoadColors();

            WindowManager.CenterControlOnScreen(this);

            if (SavedGameManager.AreSavedGamesAvailable())
            {
                fsw = new FileSystemWatcher(ProgramConstants.GamePath + "Saved Games", "*.NET");
                fsw.EnableRaisingEvents = false;
                fsw.Created            += fsw_Created;
                fsw.Changed            += fsw_Created;
            }
        }
Exemple #21
0
        public static void UpdateJumpList()
        {
            //works    GameLog.Print("UpdateJumpList (List of saved games)");
            var savedGames = (
                from savedGame in SavedGameManager.FindSavedGames()
                let file = SavedGameManager.GetSavedGameFile(savedGame)
                           where file.Exists
                           orderby savedGame.Timestamp descending
                           select savedGame
                )
                             .Take(10)
                             .ToList();

            var      jumpListCreated = false;
            JumpList jumpList        = null;

            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Background,
                (Action)
                (() => jumpList = JumpList.GetJumpList(Application.Current)));

            if (jumpList == null)
            {
                jumpList        = new JumpList();
                jumpListCreated = true;
            }
            else
            {
                jumpList.JumpItems.Clear();
            }

            var entryExe = typeof(ClientModule).Assembly.Location;

            var singlePlayerCategory    = ResourceManager.GetString("SAVED_SINGLE_PLAYER_GAMES_CATEGORY");
            var multiplayerCategory     = ResourceManager.GetString("SAVED_MULTIPLAYER_GAMES_CATEGORY");
            var singlePlayerDescription = ResourceManager.GetString("SAVED_SINGLE_PLAYER_GAME_DESCRIPTION");
            var multiplayerDescription  = ResourceManager.GetString("SAVED_MULTIPLAYER_GAME_DESCRIPTION");

            var iconFiles = savedGames
                            .Select(o => o.LocalPlayerEmpireName)
                            .Distinct()
                            .Select(o => new { EmpireName = o, IconFile = FindEmpireShellIcon(o) })
                            .ToDictionary(o => o.EmpireName);

            foreach (var savedGame in savedGames)
            {
                AddToJumpList(
                    jumpList,
                    savedGame,
                    savedGame.IsAutoSave
                        ? _autoSaveGameTitle.Value
                        : Path.GetFileNameWithoutExtension(savedGame.FileName),
                    entryExe,
                    iconFiles[savedGame.LocalPlayerEmpireName].IconFile,
                    savedGame.IsMultiplayerGame ? multiplayerCategory : singlePlayerCategory,
                    savedGame.IsMultiplayerGame ? multiplayerDescription : singlePlayerDescription);
            }

            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Background,
                (Action)
                (() =>
            {
                if (jumpListCreated)
                {
                    JumpList.SetJumpList(
                        Application.Current,
                        jumpList);
                }

                jumpList.Apply();
            }));
        }
Exemple #22
0
 public void Save(string name)
 {
     SavedGameManager.Save(this.model, name);
 }