Ejemplo n.º 1
0
 protected abstract void Final(Timer t);
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the match when one is started
        /// </summary>
        private void InitializeMatch()
        {
            // Find all the players
            Controller[] findControllers = FindObjectsOfType<Controller>();
            for (int i = 0; i < findControllers.Length; i++)
            {
                controllers.Add(findControllers[i]);
            }
			// Load the last settings used
			if(settingsName.Contains("Target"))
				currentTargetGameSettings = LoadManager.LoadTargetSettingsXML(settingsName);
			else
				currentGameSettings = LoadManager.LoadGameSettings(settingsName);

			//Find the spawnpoints
			spawnPoints.AddRange(GameObject.FindGameObjectsWithTag("Respawn"));

			StatisticManager.instance.statistics = new Dictionary<PlayerID, Statistic>();

			//If there aren't already players in this scene, we need to create them
			if(controllers.Count == 0) {
				PlayerID currentID = PlayerID.None;
				for (int i = 0; i < ControllerManager.instance.NumPlayers; i++) {
					currentID = (PlayerID)(i + 1);
					GameObject spawnPrefab = ControllerManager.instance.IsAIController(currentID) ? aiPlayerPrefab : playerPrefab;
					GameObject temp = (GameObject)GameObject.Instantiate(spawnPrefab, spawnPoints[i].transform.position, Quaternion.Euler(0,90,0));
					Controller tempController = temp.GetComponent<Controller>();
					controllers.Add(tempController);
					tempController.ProfileComponent = ProfileManager.instance.GetProfile(currentID);
					tempController.ID = currentID;
					StatisticManager.instance.statistics.Add(currentID, new Statistic());
				}
			}

			for (int i = 0; i < ControllerManager.instance.NumPlayers; i++) {
				for (int j = 0; j < ControllerManager.instance.NumPlayers; j++) {
					if(i != j) {
						StatisticManager.instance.statistics[(PlayerID)(i+1)].killedPlayer.Add((PlayerID)(j+1),0);
						StatisticManager.instance.statistics[(PlayerID)(i+1)].killedByPlayer.Add((PlayerID)(j+1),0);
					}
				}
			}

            // Initialize the tokens
            TokenSpawner.instance.Init(currentGameSettings.EnabledTokens);

            for (int i = 0; i < controllers.Count; i++)
            {
                controllers[i].LifeComponent.Lives = currentGameSettings.StockLimit;
            }

            // Set up a timer that counts up for targets
			if (currentTargetGameSettings != null)
            {
				currentTargetGameSettings.TargetsInLevel = FindObjectsOfType<Target>().Length;
                matchTimer = gameObject.AddComponent<Timer>();
                matchTimer.Initialize(Mathf.Infinity, "Match Timer");
            }
            // All other games will have a countdown timer
            else
            {
                // If the timer is enabled in that game type
				if (currentGameSettings.TimeLimit > 0)
                {
					float timeLimit = currentGameSettings.TimeLimit == 0 ? Mathf.Infinity : currentGameSettings.TimeLimit;
					matchTimer = CountdownTimer.CreateTimer(gameObject, timeLimit, "Match Timer", TimeUp);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the match when one is started
        /// </summary>
        private void InitializeMatch()
        {
            // Find all the players
            Controller[] findControllers = FindObjectsOfType<Controller>();
            for (int i = 0; i < findControllers.Length; i++)
            {
                controllers.Add(findControllers[i]);
            }
            // Load the last settings used
            //currentGameSettings = LoadManager.LoadGameSettings(GameSettings.persistentExtension);
            currentGameSettings = LoadManager.LoadGameSettingsXML("Kill");

            // Initialize the tokens
            TokenSpawner.instance.Init(currentGameSettings.EnabledTokens);

            for (int i = 0; i < controllers.Count; i++)
            {
                controllers[i].LifeComponent.Lives = currentGameSettings.StockLimit;
            }

            // Set up a timer that counts up for targets
            if (currentGameSettings.Type.Equals(Enums.GameType.Target))
            {
                currentGameSettings.TargetsInLevel = FindObjectsOfType<Target>().Length;
                matchTimer = gameObject.AddComponent<Timer>();
                matchTimer.Initialize(Mathf.Infinity, "Match Timer");
            }
            // All other games will have a countdown timer
            else
            {
                // If the timer is enabled in that game type
                if (currentGameSettings.TimeLimitEnabled)
                {
                    matchTimer = gameObject.AddComponent<CountdownTimer>();
                    matchTimer.Initialize(currentGameSettings.TimeLimit, "Match Timer");
                    ((CountdownTimer)matchTimer).TimeOut += new CountdownTimer.TimerEvent(TimeUp);
                }
            }
        }
Ejemplo n.º 4
0
 protected void Final(Timer t)
 {
     ReleaseObjects();
     DestroyImmediate(gameObject);
     GravityAttackManager.instance.Reset();
 }