Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Gameplay.RoundInfo


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
// RoundInfo
// Holds a list of RoundData objects that define the rounds in the level.
// If a RoundData actor is not placed by the user in UnrealEd, one will be spawned on level load for
// multiplayer maps.
class RoundInfo extends Engine.Info
	editinlinenew
	placeable;

var() deepcopy editinline Array<RoundData>	rounds;

var int			currentRoundIdx;
var float		replicatedRemainingDuration;	// for net clients. It would be good to find a lower-bandwidth alternative.
var float		replicatedRemainingCountdown;	// for net clients

replication
{
	reliable if (Role == ROLE_Authority)
		replicatedRemainingDuration, replicatedRemainingCountdown;
}


function bool moreRoundsToPlay()
{
	return currentRoundIdx < rounds.Length - 1;
}

// Call this to start the next round
function startNextRound()
{
	local PlayerCharacterController c;

	// End current round if applicable

	if (currentRoundIdx >= 0 && currentRoundIdx < rounds.Length)
		rounds[currentRoundIdx].end();

	currentRoundIdx++;

	// Reset some variables on all players
	ForEach Level.AllControllers(class'PlayerCharacterController', c)
	{
		if (c.Pawn == None)
			c.bWaitingForRoundEnd = false;

		// Reset livesLeft
		if(currentRound().maxLives > 0)
		{
			c.livesLeft = currentRound().maxLives;
		}
		else
			// Otherwise ensure respawns are disabled for this player
			c.livesLeft = -1;
	}

	cleanupEquipment();

	Log("Starting round "$rounds[currentRoundIdx]);
	rounds[currentRoundIdx].start(Level.TimeSeconds);
}

// needsCountdown
// returns true if the current round requires a warmup
function bool needsCountdown()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
		return false;

	return rounds[currentRoundIdx].countdownDuration > 0;
}

// isCountdown
// returns true if the current round is in the warmup phase
function bool isCountdown()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
		return false;

	return rounds[currentRoundIdx].isCountdown(Level.TimeSeconds);
}

// remainingCountdown
// returns the number of seconds remaining in the warmup phase
function float remainingCountdown()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
		return 0;

	return rounds[currentRoundIdx].playStartTime - Level.TimeSeconds;
}

// isFinished
// returns true if the current round is finished
function bool isFinished()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
	{
		Log("Round finished (no more rounds left)");
		return true;
	}

	return rounds[currentRoundIdx].isFinished(Level);
}

// remainingRoundTime
// returns the number of seconds remaining in the round
function float remainingRoundTime()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
		return 0;

	return (rounds[currentRoundIdx].playStartTime + rounds[currentRoundIdx].duration * 60) - Level.TimeSeconds;
}

// tick
function Tick(float delta)
{
	if (isCountdown())
		replicatedRemainingCountdown = remainingCountdown();
	else
		replicatedRemainingDuration = remainingRoundTime();
}

function RoundData currentRound()
{
	if (currentRoundIdx < 0 || currentRoundIdx >= rounds.Length)
		return None;

	return rounds[currentRoundIdx];
}

function restart()
{
	currentRoundIdx = -1;
	startNextRound();
}

function cleanup()
{
	local int i;

	for (i=0; i<rounds.Length; i++)
	{
		rounds[i].cleanup();
	}
}

// Destroy all dropped equipment and reset equipment spawn points
function cleanupEquipment()
{
	local Equipment e;
	local EquipmentSpawnPoint esp;

	// Destroy dropped equipment, but not deployables
	ForEach DynamicActors(class'Equipment', e)
	{
		if (e.IsInState('AwaitingPickup') && !ClassIsChildOf(e.Class, class'Deployable'))
			e.destroy();
	}

	// Make sure every equipment spawn point spawns its equipment
	ForEach AllActors(class'EquipmentSpawnPoint', esp)
	{
		// Don't check to see if the spawn point has already spawned equipment because even if it had,
		// it would've been deleted in the previous operation
		esp.spawnEquipment();
	}
}

defaultproperties
{
	RemoteRole				= ROLE_DumbProxy
	bAlwaysRelevant			= true
	NetUpdateFrequency		= 1
	currentRoundIdx			= -1
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: �t 9.9.2004 16:25:32.000 - Creation time: st 23.5.2018 00:10:46.816 - Created with UnCodeX