A quick update - I've done a whole load of work on the player class selection; I've written the base for the menu class, which allows you to select
a) whether you are a Rocket Rider, Silent Sentinel or Double Damage.
b) whether you are armed with the Super-Sniper, Mega-Link or Uber-Rox.
c) whether you want a boost in health, armour or speed.
Here's some code:
UR_ClassMenu - a UIScene that can be opened in game to let player choose class - at the moment it is only on death; but it should also be on game start too. I took the colour code from a previous code experiment. If you're interested in the maths, Wikipedia has an article on HSV colour. The SetAndRespawnPlayer function is temporary; it needs to move into the playercontroller, so that it can be stored, so the player doesn't have to reselect all their options every time they spawn.
class UR_ClassMenu extends UTUIScene;
var transient UILabelButton ButClassSurfer, ButClassStealth, ButClassAkimbo, ButWeaponSniper, ButWeaponLink, ButWeaponRox, ButPerkHealth, ButPerkArmour, ButPerkSpeed, ButRespawn;
var transient UTUISlider SliWeaponEffects;
var UR_PlayerController PC;
enum PlayerClass
{
eSurfer,
eStealth,
eAkimbo
};
enum PlayerWeapon
{
eSniper,
eLink,
eRox
};
enum PlayerPerk
{
eHealth,
eArmour,
eSpeed
};
struct PlayerDetails
{
var PlayerClass PlayerClass;
var PlayerWeapon PlayerWeapon;
var PlayerPerk PlayerPerk;
};
var PlayerDetails PlayerSelection;
event PostInitialize()
{
ButClassSurfer = UILabelButton(FindChild('ButClassSurfer', true));
ButClassStealth = UILabelButton(FindChild('ButClassStealth', true));
ButClassAkimbo = UILabelButton(FindChild('ButClassAkimbo', true));
ButWeaponSniper = UILabelButton(FindChild('ButWeaponSniper', true));
ButWeaponLink = UILabelButton(FindChild('ButWeaponLink', true));
ButWeaponRox = UILabelButton(FindChild('ButWeaponRox', true));
ButPerkHealth = UILabelButton(FindChild('ButPerkHealth', true));
ButPerkArmour = UILabelButton(FindChild('ButPerkArmour', true));
ButPerkSpeed = UILabelButton(FindChild('ButPerkSpeed', true));
ButRespawn = UILabelButton(FindChild('ButRespawn', true));
SliWeaponEffects = UTUISlider(FindChild('SliEffects', true));
SliWeaponEffects.SliderValue.CurrentValue = 0.f;
SliWeaponEffects.SliderValue.MinValue = 0.f;
SliWeaponEffects.SliderValue.MaxValue = 360.f;
SliWeaponEffects.SliderValue.NudgeValue = 10.f;
SliWeaponEffects.SliderValue.bIntRange = true;
ButClassSurfer.OnClicked = OnClickedDelegate;
ButClassStealth.OnClicked = OnClickedDelegate;
ButClassAkimbo.OnClicked = OnClickedDelegate;
ButWeaponSniper.OnClicked = OnClickedDelegate;
ButWeaponLink.OnClicked = OnClickedDelegate;
ButWeaponRox.OnClicked = OnClickedDelegate;
ButPerkHealth.OnClicked = OnClickedDelegate;
ButPerkArmour.OnClicked = OnClickedDelegate;
ButPerkSpeed.OnClicked = OnClickedDelegate;
ButRespawn.OnClicked = OnClickedDelegate;
super.PostInitialize();
}
function bool OnClickedDelegate(UIScreenObject EventObject, int PlayerIndex)
{
switch(EventObject)
{
case ButClassSurfer:
PlayerSelection.PlayerClass = eSurfer;
return true;
case ButClassStealth:
PlayerSelection.PlayerClass = eStealth;
return true;
case ButClassAkimbo:
PlayerSelection.PlayerClass = eAkimbo;
return true;
case ButWeaponSniper:
PlayerSelection.PlayerWeapon = eSniper;
return true;
case ButWeaponLink:
PlayerSelection.PlayerWeapon = eLink;
return true;
case ButWeaponRox:
PlayerSelection.PlayerWeapon = eRox;
return true;
case ButPerkHealth:
PlayerSelection.PlayerPerk = eHealth;
return true;
case ButPerkArmour:
PlayerSelection.PlayerPerk = eArmour;
return true;
case ButPerkSpeed:
PlayerSelection.PlayerPerk = eSpeed;
return true;
case ButRespawn:
SetAndRespawnPlayer();
return true;
Default:
`log("Event Object was not caught in OnClickedDelegate: " $ EventObject);
return true;
}
return false;
}
static simulated function LinearColor CalculateRBGfromHue(float PreucilAngle)
{
local LinearColor ColourToUse;
local float DensityMax, DensityMin, Red,Green,Blue,Hue,Saturation,Value,EuclidianDistance,ComponentX,ComponentY,Comp
onentZ;
local int Ordering;
ColourToUse = MakeLinearColor(255,1,1,1);
Red =ColourToUse.R;///255.0;
Green = ColourToUse.G;///255.0;
Blue = ColourToUse.B;///255.0;
if(Red == Green && Green == Blue)
{
return ColourToUse;
}
DensityMax = FMax(Red,FMax(Green,Blue));
DensityMin = FMin(Red,FMin(Green,Blue));
if(DensityMax == Red)
{
if(Green >= Blue)
{
Hue = 60.0*(Green-Blue)/(DensityMax-DensityMin);
}
else
{
Hue = 60.0*(Green-Blue)/(DensityMax-DensityMin)+360.0;
}
}
else if(DensityMax == Green)
{
Hue = 60.0*(Blue-Red)/(DensityMax-DensityMin)+120.0;
}
else
{
Hue = 60.0*(Red-Green)/(DensityMax-DensityMin)+240.0;
}
if(DensityMax == 0.0)
{
Saturation = 0.0;
}
else
{
Saturation = 1.0-DensityMin/DensityMax;
}
Value = DensityMax;
Hue = (Hue + PreucilAngle)%360;
Ordering = int(Hue/60)%6;
EuclidianDistance = Hue/60.0-Ordering;
ComponentX = Value*(1-Saturation);
ComponentY = Value*(1-EuclidianDistance*Saturation);
ComponentZ = Value*(1-(1-EuclidianDistance)*Saturation);
switch (Ordering)
{ case 0: return MakeLinearColor(Value,ComponentZ,ComponentX,1);
case 1: return MakeLinearColor(ComponentY,Value,ComponentX,1);
case 2: return MakeLinearColor(ComponentX,Value,ComponentZ,1);
case 3: return MakeLinearColor(ComponentX,ComponentY,Value,1);
case 4: return MakeLinearColor(ComponentZ,ComponentX,Value,1);
case 5: return MakeLinearColor(Value,ComponentX,ComponentY,1);
}
return ColourToUse;
}
function ExitMenu()
{
CloseScene(self);
}
function bool HandleInputKey( const out InputEventParameters EventParms )
{
local bool bResult;
bResult=false;
if(EventParms.EventType==IE_Released)
{
if(EventParms.InputKeyName=='Escape')
{
ExitMenu();
bResult=true;
}
}
return bResult;
}
function SetAndRespawnPlayer()
{
//PC.Pawn.Health = 200;
switch(PlayerSelection.PlayerClass)
{
case eSurfer:
PC.Pawn.Health = 100;
PC.Pawn.GroundSpeed = 440;
PC.Pawn.WaterSpeed = 220;
PC.Pawn.AirSpeed = 440;
PC.Pawn.JumpZ = 322;
break;
case eStealth:
PC.Pawn.Health = 50;
PC.Pawn.GroundSpeed = 330;
PC.Pawn.WaterSpeed = 220;
PC.Pawn.AirSpeed = 330;
PC.Pawn.JumpZ = 322;
break;
case eAkimbo:
PC.Pawn.Health = 150;
PC.Pawn.GroundSpeed = 330;
PC.Pawn.WaterSpeed = 110;
PC.Pawn.AirSpeed = 220;
PC.Pawn.JumpZ = 200;
break;
default:
`log("Class selection failed in SetAndRespawnPlayer");
}
switch(PlayerSelection.PlayerPerk)
{
case eHealth:
PC.Pawn.Health += 50;
break;
case eArmour:
UR_Pawn(PC.Pawn).VestArmor += 50;
break;
case eSpeed:
PC.Pawn.GroundSpeed += 100;
PC.Pawn.WaterSpeed += 50;
PC.Pawn.AirSpeed += 75;
PC.Pawn.JumpZ += 75;
break;
default:
`log("Perk selection failed in SetAndRespawnPlayer");
}
switch(PlayerSelection.PlayerWeapon)
{
case eSniper:
//PC.Pawn.InvManager.AddInventory(class'UnrealRider.UR_Weap_Xark', true)
break;
case eLink:
//PC.Pawn.InvManager.AddInventory(class'UnrealRider.UR_Weap_MegaLink', true)
break;
case eRox:
//PC.Pawn.InvManager.AddInventory(class'UnrealRider.UR_Weap_MegaRox', true)
break;
default:
`log("Weapon selection failed in SetAndRespawnPlayer");
}
ExitMenu();
}
UR_Pawn - this doesn't look like much, but that EffectsColour can potentially be looked up by every weapon and used as a parameter and passed to particle systems and materials relating to the player.
class UR_Pawn extends UTPawn;
var LinearColor EffectsColour;
DefaultProperties
{
EffectsColour = (R=255,G=0,B=0,A=255);
}
The controller, and how it opens the special menu. The Exec function can be typed into the console at any time.
class UR_PlayerController extends UTPlayerController;
exec function ShowClassMenu()
{
DynamicOpenMenu("LP_UR_Assets.ClassMenu");
}
simulated function DynamicOpenMenu( string MenuPath, optional int PlayerIndex=INDEX_NONE )
{
local UIScene Scene;
local GameUISceneClient GS;
GS = UTGameUISceneClient(class'UIRoot'.static.GetSceneClient());
Scene = UIScene(DynamicLoadObject(MenuPath, class'UIScene'));
UR_ClassMenu(Scene).PC = self;
if ( !GS.OpenScene(Scene) )
{
`Log("Failed to load menu '" $ MenuPath $"'");
}
}
state Dead
{
exec function StartFire( optional byte FireModeNum )
{
if ( bFrozen )
{
if ( !IsTimerActive() || GetTimerCount() > MinRespawnDelay )
{
bFrozen = false;
}
return;
}
ServerReStartPlayer();
if (FireModeNum == 1)
{
ShowClassMenu();
}
}
}
DefaultProperties
{
}
Edited by ambershee, 07 June 2008 - 10:55 PM.