Compare commits
No commits in common. "3dbcb69b7fdadf16c3525d228145d2535a536081" and "a23b68cc51e98ed869112610fe54ea5c1fa4dced" have entirely different histories.
3dbcb69b7f
...
a23b68cc51
@ -12,7 +12,6 @@ GameObject:
|
|||||||
- component: {fileID: 3310727599597512245}
|
- component: {fileID: 3310727599597512245}
|
||||||
- component: {fileID: 7696877450501702533}
|
- component: {fileID: 7696877450501702533}
|
||||||
- component: {fileID: 6827936618995316794}
|
- component: {fileID: 6827936618995316794}
|
||||||
- component: {fileID: 4008460033671928136}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Boost Sound 1
|
m_Name: Boost Sound 1
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -172,26 +171,3 @@ AudioLowPassFilter:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
--- !u!164 &4008460033671928136
|
|
||||||
AudioReverbFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4479628772504131522}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_DryLevel: 0
|
|
||||||
m_Room: -1000
|
|
||||||
m_RoomHF: -476
|
|
||||||
m_DecayTime: 4.32
|
|
||||||
m_DecayHFRatio: 0.59
|
|
||||||
m_ReflectionsLevel: -789
|
|
||||||
m_ReverbLevel: -289
|
|
||||||
m_ReverbDelay: 0.03
|
|
||||||
m_Diffusion: 100
|
|
||||||
m_Density: 100
|
|
||||||
m_HFReference: 5000
|
|
||||||
m_RoomLF: 0
|
|
||||||
m_LFReference: 250
|
|
||||||
m_ReflectionsDelay: 0
|
|
||||||
m_ReverbPreset: 7
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ GameObject:
|
|||||||
- component: {fileID: 6423719894035945655}
|
- component: {fileID: 6423719894035945655}
|
||||||
- component: {fileID: 3310727599597512245}
|
- component: {fileID: 3310727599597512245}
|
||||||
- component: {fileID: 7696877450501702533}
|
- component: {fileID: 7696877450501702533}
|
||||||
- component: {fileID: -1754416925767846858}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Zone Change In
|
m_Name: Zone Change In
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -62,7 +61,7 @@ AudioSource:
|
|||||||
OutputAudioMixerGroup: {fileID: 0}
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
m_audioClip: {fileID: 8300000, guid: 7144b46ba00d9fe4183b81b9b2781765, type: 3}
|
m_audioClip: {fileID: 8300000, guid: 7144b46ba00d9fe4183b81b9b2781765, type: 3}
|
||||||
m_PlayOnAwake: 0
|
m_PlayOnAwake: 0
|
||||||
m_Volume: 0.2
|
m_Volume: 0.25
|
||||||
m_Pitch: 0.6
|
m_Pitch: 0.6
|
||||||
Loop: 0
|
Loop: 0
|
||||||
Mute: 0
|
Mute: 0
|
||||||
@ -146,26 +145,3 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
--- !u!164 &-1754416925767846858
|
|
||||||
AudioReverbFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4479628772504131522}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_DryLevel: 0
|
|
||||||
m_Room: -1000
|
|
||||||
m_RoomHF: -3300
|
|
||||||
m_DecayTime: 1.49
|
|
||||||
m_DecayHFRatio: 0.54
|
|
||||||
m_ReflectionsLevel: -2560
|
|
||||||
m_ReverbLevel: -229
|
|
||||||
m_ReverbDelay: 0.088
|
|
||||||
m_Diffusion: 79
|
|
||||||
m_Density: 100
|
|
||||||
m_HFReference: 5000
|
|
||||||
m_RoomLF: 0
|
|
||||||
m_LFReference: 250
|
|
||||||
m_ReflectionsDelay: 0
|
|
||||||
m_ReverbPreset: 16
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ GameObject:
|
|||||||
- component: {fileID: 6423719894035945655}
|
- component: {fileID: 6423719894035945655}
|
||||||
- component: {fileID: 3310727599597512245}
|
- component: {fileID: 3310727599597512245}
|
||||||
- component: {fileID: 7696877450501702533}
|
- component: {fileID: 7696877450501702533}
|
||||||
- component: {fileID: -1684086232817475425}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Zone Change Out
|
m_Name: Zone Change Out
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -62,8 +61,8 @@ AudioSource:
|
|||||||
OutputAudioMixerGroup: {fileID: 0}
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
m_audioClip: {fileID: 8300000, guid: fad7b8b8149e035499ded4af2227b5aa, type: 3}
|
m_audioClip: {fileID: 8300000, guid: fad7b8b8149e035499ded4af2227b5aa, type: 3}
|
||||||
m_PlayOnAwake: 0
|
m_PlayOnAwake: 0
|
||||||
m_Volume: 0.2
|
m_Volume: 0.25
|
||||||
m_Pitch: 0.65
|
m_Pitch: 0.8
|
||||||
Loop: 0
|
Loop: 0
|
||||||
Mute: 0
|
Mute: 0
|
||||||
Spatialize: 0
|
Spatialize: 0
|
||||||
@ -146,26 +145,3 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
--- !u!164 &-1684086232817475425
|
|
||||||
AudioReverbFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4479628772504131522}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_DryLevel: 0
|
|
||||||
m_Room: -1000
|
|
||||||
m_RoomHF: -3300
|
|
||||||
m_DecayTime: 1.49
|
|
||||||
m_DecayHFRatio: 0.54
|
|
||||||
m_ReflectionsLevel: -2560
|
|
||||||
m_ReverbLevel: -229
|
|
||||||
m_ReverbDelay: 0.088
|
|
||||||
m_Diffusion: 79
|
|
||||||
m_Density: 100
|
|
||||||
m_HFReference: 5000
|
|
||||||
m_RoomLF: 0
|
|
||||||
m_LFReference: 250
|
|
||||||
m_ReflectionsDelay: 0
|
|
||||||
m_ReverbPreset: 16
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -13,11 +13,11 @@ MonoBehaviour:
|
|||||||
m_Name: BlueShip
|
m_Name: BlueShip
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
shipObject: {fileID: 1372816401649438144, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
shipObject: {fileID: 1372816401649438144, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||||
shipName: Blue Blitz
|
shipName: BlueBlitz
|
||||||
thrustAcceleration: 1275
|
thrustAcceleration: 1500
|
||||||
steerVelocity: 300
|
steerVelocity: 300
|
||||||
normalMaxVelocity: 22
|
normalMaxVelocity: 25
|
||||||
absolutMaxVelocity: 40
|
absolutMaxVelocity: 45
|
||||||
antiDriftAmount: 6
|
antiDriftAmount: 6
|
||||||
minAntiDriftFactor: 0.1
|
minAntiDriftFactor: 0.1
|
||||||
normalDrag: 3
|
normalDrag: 3
|
||||||
@ -32,4 +32,4 @@ MonoBehaviour:
|
|||||||
tackleCriticalStunTime: 0.6
|
tackleCriticalStunTime: 0.6
|
||||||
tackleBodyStunTime: 0.2
|
tackleBodyStunTime: 0.2
|
||||||
criticalTacklePowerFactor: 60
|
criticalTacklePowerFactor: 60
|
||||||
normalTacklePowerFactor: 30
|
normalTacklePowerFactor: 20
|
||||||
|
|||||||
@ -13,11 +13,11 @@ MonoBehaviour:
|
|||||||
m_Name: RedShip
|
m_Name: RedShip
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
shipObject: {fileID: 1372816401649438144, guid: 46f84e56340e83e4ba7c6abbccd2ae3f, type: 3}
|
shipObject: {fileID: 1372816401649438144, guid: 46f84e56340e83e4ba7c6abbccd2ae3f, type: 3}
|
||||||
shipName: Red Menace
|
shipName: RedMenace
|
||||||
thrustAcceleration: 1300
|
thrustAcceleration: 1500
|
||||||
steerVelocity: 300
|
steerVelocity: 300
|
||||||
normalMaxVelocity: 25
|
normalMaxVelocity: 25
|
||||||
absolutMaxVelocity: 42
|
absolutMaxVelocity: 45
|
||||||
antiDriftAmount: 9
|
antiDriftAmount: 9
|
||||||
minAntiDriftFactor: 0.01
|
minAntiDriftFactor: 0.01
|
||||||
normalDrag: 3
|
normalDrag: 3
|
||||||
@ -31,5 +31,5 @@ MonoBehaviour:
|
|||||||
stunLooseControlFactor: 0.1
|
stunLooseControlFactor: 0.1
|
||||||
tackleCriticalStunTime: 0.6
|
tackleCriticalStunTime: 0.6
|
||||||
tackleBodyStunTime: 0.2
|
tackleBodyStunTime: 0.2
|
||||||
criticalTacklePowerFactor: 65
|
criticalTacklePowerFactor: 60
|
||||||
normalTacklePowerFactor: 32
|
normalTacklePowerFactor: 20
|
||||||
|
|||||||
@ -13,7 +13,7 @@ MonoBehaviour:
|
|||||||
m_Name: DefaultRule
|
m_Name: DefaultRule
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
winCondition: 0
|
winCondition: 0
|
||||||
rounds: 3
|
rounds: 1
|
||||||
lives: 1
|
lives: 1
|
||||||
score: 0
|
score: 0
|
||||||
time: -1
|
time: -1
|
||||||
|
|||||||
@ -189,7 +189,7 @@ namespace Managers
|
|||||||
{
|
{
|
||||||
MatchManager.LoadMatchRules(0);
|
MatchManager.LoadMatchRules(0);
|
||||||
MatchManager.LoadArenaProperties(0);
|
MatchManager.LoadArenaProperties(0);
|
||||||
PlayerManager.LocalMatchJoinPlayers(MatchManager.ArenaProperties.minPlayerCount);
|
PlayerManager.LocalMatchJoinPlayers(MatchManager.arenaProperties.minPlayerCount);
|
||||||
// TODO: This is in place of a character choosing menu etc.
|
// TODO: This is in place of a character choosing menu etc.
|
||||||
foreach (Player p in PlayerManager.localPlayers)
|
foreach (Player p in PlayerManager.localPlayers)
|
||||||
{
|
{
|
||||||
@ -231,7 +231,7 @@ namespace Managers
|
|||||||
yield return null;
|
yield return null;
|
||||||
MatchManager.LoadMatchRules(0);
|
MatchManager.LoadMatchRules(0);
|
||||||
MatchManager.LoadArenaProperties(0);
|
MatchManager.LoadArenaProperties(0);
|
||||||
PlayerManager.LocalMatchJoinPlayers(MatchManager.ArenaProperties.minPlayerCount);
|
PlayerManager.LocalMatchJoinPlayers(MatchManager.arenaProperties.minPlayerCount);
|
||||||
foreach (Player p in PlayerManager.localPlayers)
|
foreach (Player p in PlayerManager.localPlayers)
|
||||||
{
|
{
|
||||||
CharacterManager.AssignShipFixed(p);
|
CharacterManager.AssignShipFixed(p);
|
||||||
|
|||||||
@ -40,7 +40,6 @@ public class MatchConditionUpdate
|
|||||||
public class MatchPlayerStatistic
|
public class MatchPlayerStatistic
|
||||||
{
|
{
|
||||||
public bool IsOut { get; set; }
|
public bool IsOut { get; set; }
|
||||||
public int RoundsWon { get; set; }
|
|
||||||
public int Lives { get; set; }
|
public int Lives { get; set; }
|
||||||
public int Score { get; set; }
|
public int Score { get; set; }
|
||||||
public int Time { get; set; }
|
public int Time { get; set; }
|
||||||
@ -55,9 +54,8 @@ namespace Managers
|
|||||||
{
|
{
|
||||||
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private static readonly string arenaAssetsPath = "Assets/ScriptedAssets/Arenas";
|
private static string arenaAssetsPath = "Assets/ScriptedAssets/Arenas";
|
||||||
private static readonly string ruleAssetsPath = "Assets/ScriptedAssets/Rules";
|
private static string ruleAssetsPath = "Assets/ScriptedAssets/Rules";
|
||||||
private GameResult CurrentMatchResult;
|
|
||||||
|
|
||||||
public GameObject MatchArena;
|
public GameObject MatchArena;
|
||||||
public GameObject MatchCamera;
|
public GameObject MatchCamera;
|
||||||
@ -74,29 +72,29 @@ namespace Managers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The players participating in the match.
|
/// The players participating in the match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Player> MatchPlayers { get; private set; } =
|
public List<Player> matchPlayers { get; private set; } =
|
||||||
new List<Player>();
|
new List<Player>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The statistics regarding the current match mapped to the players.
|
/// The statistics regarding the current match mapped to the players.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<Player, MatchPlayerStatistic> MatchPlayerStatistics { get; set; } =
|
public Dictionary<Player, MatchPlayerStatistic> matchPlayerStatistics { get; set; } =
|
||||||
new Dictionary<Player, MatchPlayerStatistic>();
|
new Dictionary<Player, MatchPlayerStatistic>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bundle of properties regarding the arena.
|
/// Bundle of properties regarding the arena.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Arena ArenaProperties { get; private set; }
|
public Arena arenaProperties { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The rules under which this match takes place.
|
/// The rules under which this match takes place.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatchRule MatchRule { get; private set; }
|
public MatchRule matchRule { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all the arenas in the assets.
|
/// List of all the arenas in the assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Arena> AvailableArenas { get; private set; } = new List<Arena>();
|
public List<Arena> availableArenas { get; private set; } = new List<Arena>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all the rules/game modes in the assets.
|
/// List of all the rules/game modes in the assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<MatchRule> AvailableRules { get; private set; } = new List<MatchRule>();
|
public List<MatchRule> availableRules { get; private set; } = new List<MatchRule>();
|
||||||
|
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
@ -118,7 +116,7 @@ namespace Managers
|
|||||||
public void UpdateMatchCondition(MatchConditionUpdate update)
|
public void UpdateMatchCondition(MatchConditionUpdate update)
|
||||||
{
|
{
|
||||||
Player updatedPlayer = null;
|
Player updatedPlayer = null;
|
||||||
foreach (Player p in MatchPlayers)
|
foreach (Player p in matchPlayers)
|
||||||
{
|
{
|
||||||
if (p.character.shipName == update.Ship.props.shipName)
|
if (p.character.shipName == update.Ship.props.shipName)
|
||||||
{
|
{
|
||||||
@ -126,29 +124,19 @@ namespace Managers
|
|||||||
Log.Debug($"Players: {p.name} match statistic will be updated.");
|
Log.Debug($"Players: {p.name} match statistic will be updated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updatedPlayer == null)
|
// TODO: Match Result should contain progression over multiple rounds.
|
||||||
{
|
MatchResult result = MatchLogic.UpdateMatchResult(updatedPlayer, update, matchPlayerStatistics);
|
||||||
Log.Error($"Ship: {update.Ship.props.shipName} does not belong to a player in this match."
|
if (updatedPlayer != null && result != null)
|
||||||
+ " Can't update match.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (CurrentMatchResult == null)
|
|
||||||
{
|
|
||||||
Log.Error("Match has no result statistics attached and was set up incorrectly!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MatchLogic.UpdateMatchResult(updatedPlayer, update, MatchPlayerStatistics, CurrentMatchResult);
|
|
||||||
if (CurrentMatchResult.IsMatchWon)
|
|
||||||
{
|
{
|
||||||
|
matchState = MatchState.End;
|
||||||
Log.Info("Match has ended, winner will be declared.");
|
Log.Info("Match has ended, winner will be declared.");
|
||||||
AnnounceMatchWinner(CurrentMatchResult);
|
// TODO: Take player decisions into account before restarting the match
|
||||||
}
|
// TODO: Include the statistics and match round progression in announcements
|
||||||
else
|
AnnounceWinner(result);
|
||||||
{
|
return;
|
||||||
Log.Info($"Round {CurrentMatchResult.RoundsPlayed} of {MatchRule.rounds} has ended." +
|
|
||||||
$"{CurrentMatchResult.Winner.name} won this round.");
|
|
||||||
AnnounceRoundWinner(CurrentMatchResult);
|
|
||||||
}
|
}
|
||||||
|
Log.Error($"Ship: {update.Ship.props.shipName} does not belong to a player in this match."
|
||||||
|
+ " Can't update match.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -161,7 +149,7 @@ namespace Managers
|
|||||||
SearchOption.TopDirectoryOnly);
|
SearchOption.TopDirectoryOnly);
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
AvailableArenas.Add(AssetDatabase.LoadAssetAtPath<Arena>(file));
|
availableArenas.Add(AssetDatabase.LoadAssetAtPath<Arena>(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +163,7 @@ namespace Managers
|
|||||||
SearchOption.TopDirectoryOnly);
|
SearchOption.TopDirectoryOnly);
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
AvailableRules.Add(AssetDatabase.LoadAssetAtPath<MatchRule>(file));
|
availableRules.Add(AssetDatabase.LoadAssetAtPath<MatchRule>(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,17 +172,17 @@ namespace Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetupMatchPlayerStatistics()
|
public void SetupMatchPlayerStatistics()
|
||||||
{
|
{
|
||||||
MatchPlayerStatistics.Clear();
|
matchPlayerStatistics.Clear();
|
||||||
foreach (Player p in MatchPlayers)
|
foreach (Player p in matchPlayers)
|
||||||
{
|
{
|
||||||
MatchPlayerStatistic mps = new MatchPlayerStatistic
|
MatchPlayerStatistic mps = new MatchPlayerStatistic
|
||||||
{
|
{
|
||||||
IsOut = false,
|
IsOut = false,
|
||||||
Lives = MatchRule.lives,
|
Lives = matchRule.lives,
|
||||||
Score = MatchRule.score,
|
Score = matchRule.score,
|
||||||
Time = MatchRule.time
|
Time = matchRule.time
|
||||||
};
|
};
|
||||||
if (!MatchPlayerStatistics.TryAdd(p, mps))
|
if (!matchPlayerStatistics.TryAdd(p, mps))
|
||||||
{
|
{
|
||||||
Log.Info($"Player {p.name} already has statistics set up.");
|
Log.Info($"Player {p.name} already has statistics set up.");
|
||||||
}
|
}
|
||||||
@ -208,13 +196,13 @@ namespace Managers
|
|||||||
/// <param name="arenaIndex">Index of the arena (arenas scripted asset folder order from 0)</param>
|
/// <param name="arenaIndex">Index of the arena (arenas scripted asset folder order from 0)</param>
|
||||||
public void LoadArenaProperties(int arenaIndex)
|
public void LoadArenaProperties(int arenaIndex)
|
||||||
{
|
{
|
||||||
if (AvailableArenas.Count - 1 < arenaIndex)
|
if (availableArenas.Count - 1 < arenaIndex)
|
||||||
{
|
{
|
||||||
Log.Error($"There are only: {AvailableArenas.Count} arenas loaded."
|
Log.Error($"There are only: {availableArenas.Count} arenas loaded."
|
||||||
+ $" Couldn't load arena number: {arenaIndex + 1}");
|
+ $" Couldn't load arena number: {arenaIndex + 1}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArenaProperties = AvailableArenas[arenaIndex];
|
arenaProperties = availableArenas[arenaIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -224,14 +212,14 @@ namespace Managers
|
|||||||
/// (rules scripted asset folder order from 0)</param>
|
/// (rules scripted asset folder order from 0)</param>
|
||||||
public void LoadMatchRules(int ruleIndex)
|
public void LoadMatchRules(int ruleIndex)
|
||||||
{
|
{
|
||||||
if (AvailableArenas.Count - 1 < ruleIndex)
|
if (availableArenas.Count - 1 < ruleIndex)
|
||||||
{
|
{
|
||||||
Log.Error($"There are only: {AvailableArenas.Count} rules loaded."
|
Log.Error($"There are only: {availableArenas.Count} rules loaded."
|
||||||
+ $" Couldn't load match rule number: {ruleIndex + 1}");
|
+ $" Couldn't load match rule number: {ruleIndex + 1}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MatchRule = AvailableRules[ruleIndex];
|
matchRule = availableRules[ruleIndex];
|
||||||
MatchLogic.currentRule = MatchRule;
|
MatchLogic.currentRule = matchRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -244,55 +232,22 @@ namespace Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Announcement of who won the match.
|
/// Announcement of who won.
|
||||||
|
/// TODO: Also restarts the match right now, no matter what.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mr">Result data of the completed match.</param>
|
/// <param name="mr">Result data of the completed match.</param>
|
||||||
async public void AnnounceMatchWinner(GameResult mr)
|
async public void AnnounceWinner(MatchResult mr)
|
||||||
{
|
{
|
||||||
UIManager.G.Announcments.QueueAnnounceText($"{mr.Winner.playerName}" +
|
UIManager.G.announcments.QueueAnnounceText($"{mr.Winner.playerName}" +
|
||||||
" has won the match!", 2f);
|
" has won the match!", 1.618f);
|
||||||
await Tween.Delay(2f * 0.33f);
|
await Tween.Delay(1.618f);
|
||||||
matchState = MatchState.End;
|
|
||||||
await Tween.Delay(2f * 0.66f);
|
|
||||||
|
|
||||||
UIManager.G.ShowMatchEndMenu(MatchArena.transform);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async public void StartRematch()
|
|
||||||
{
|
|
||||||
ResetMatch();
|
ResetMatch();
|
||||||
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting rematch.", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Restarting.", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting rematch..", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Restarting..", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting rematch...", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Restarting...", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("GO!", 0.5f);
|
UIManager.G.announcments.QueueAnnounceText("GO!", 0.5f);
|
||||||
await Tween.Delay(0.9f);
|
|
||||||
matchState = MatchState.Match;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Announcement of who won the Round.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mr">Result data of the completed match.</param>
|
|
||||||
async public void AnnounceRoundWinner(GameResult mr)
|
|
||||||
{
|
|
||||||
var winnerStats = MatchPlayerStatistics[mr.Winner];
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText($"{mr.Winner.playerName}" +
|
|
||||||
" has won the Round! \n" +
|
|
||||||
$"They won {winnerStats.RoundsWon} out of {MatchRule.rounds}.",
|
|
||||||
1.618f);
|
|
||||||
|
|
||||||
await Tween.Delay(1.618f * 0.33f);
|
|
||||||
matchState = MatchState.Pause;
|
|
||||||
await Tween.Delay(1.618f * 0.66f);
|
|
||||||
|
|
||||||
ResetMatchCharacters();
|
|
||||||
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting next round.", 0.3f);
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting next round..", 0.3f);
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Starting next round...", 0.3f);
|
|
||||||
UIManager.G.Announcments.QueueAnnounceText("GO!", 0.5f);
|
|
||||||
await Tween.Delay(0.9f);
|
await Tween.Delay(0.9f);
|
||||||
|
|
||||||
matchState = MatchState.Match;
|
matchState = MatchState.Match;
|
||||||
@ -303,7 +258,6 @@ namespace Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ResetMatch()
|
public void ResetMatch()
|
||||||
{
|
{
|
||||||
CurrentMatchResult = new GameResult();
|
|
||||||
ResetMatchCharacters();
|
ResetMatchCharacters();
|
||||||
SetupMatchPlayerStatistics();
|
SetupMatchPlayerStatistics();
|
||||||
}
|
}
|
||||||
@ -314,13 +268,12 @@ namespace Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
async public void StartMatch()
|
async public void StartMatch()
|
||||||
{
|
{
|
||||||
foreach (Player p in MatchPlayers)
|
foreach (Player p in matchPlayers)
|
||||||
{
|
{
|
||||||
p.spawnedCharacter.transform.localPosition =
|
p.spawnedCharacter.transform.localPosition =
|
||||||
ArenaProperties.spawnPositions[p.playerNumber - 1];
|
arenaProperties.spawnPositions[p.playerNumber - 1];
|
||||||
}
|
}
|
||||||
SetupMatchPlayerStatistics();
|
SetupMatchPlayerStatistics();
|
||||||
CurrentMatchResult = new GameResult();
|
|
||||||
|
|
||||||
matchState = MatchState.Starting;
|
matchState = MatchState.Starting;
|
||||||
UIManager.G.ShowMatchStartPrompt();
|
UIManager.G.ShowMatchStartPrompt();
|
||||||
@ -333,10 +286,10 @@ namespace Managers
|
|||||||
OnStartPressed = null;
|
OnStartPressed = null;
|
||||||
|
|
||||||
UIManager.G.HideAnnouncement();
|
UIManager.G.HideAnnouncement();
|
||||||
UIManager.G.Announcments.QueueAnnounceText("3", 1);
|
UIManager.G.announcments.QueueAnnounceText("3", 1);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("2", 1);
|
UIManager.G.announcments.QueueAnnounceText("2", 1);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("1", 1);
|
UIManager.G.announcments.QueueAnnounceText("1", 1);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("GO!", 0.5f);
|
UIManager.G.announcments.QueueAnnounceText("GO!", 0.5f);
|
||||||
await Tween.Delay(3);
|
await Tween.Delay(3);
|
||||||
|
|
||||||
matchState = MatchState.Match;
|
matchState = MatchState.Match;
|
||||||
@ -344,13 +297,12 @@ namespace Managers
|
|||||||
|
|
||||||
public void StartTestMatch()
|
public void StartTestMatch()
|
||||||
{
|
{
|
||||||
foreach (Player p in MatchPlayers)
|
foreach (Player p in matchPlayers)
|
||||||
{
|
{
|
||||||
p.spawnedCharacter.transform.localPosition =
|
p.spawnedCharacter.transform.localPosition =
|
||||||
ArenaProperties.spawnPositions[p.playerNumber - 1];
|
arenaProperties.spawnPositions[p.playerNumber - 1];
|
||||||
}
|
}
|
||||||
SetupMatchPlayerStatistics();
|
SetupMatchPlayerStatistics();
|
||||||
CurrentMatchResult = new GameResult();
|
|
||||||
matchState = MatchState.Match;
|
matchState = MatchState.Match;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,10 +346,10 @@ namespace Managers
|
|||||||
|
|
||||||
async private void ContinueMatch()
|
async private void ContinueMatch()
|
||||||
{
|
{
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Get Ready.", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Get Ready.", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Get Ready..", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Get Ready..", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("Get Ready...", 0.3f);
|
UIManager.G.announcments.QueueAnnounceText("Get Ready...", 0.3f);
|
||||||
UIManager.G.Announcments.QueueAnnounceText("GO!", 0.5f);
|
UIManager.G.announcments.QueueAnnounceText("GO!", 0.5f);
|
||||||
await Tween.Delay(0.9f);
|
await Tween.Delay(0.9f);
|
||||||
matchState = MatchState.Match;
|
matchState = MatchState.Match;
|
||||||
}
|
}
|
||||||
@ -432,11 +384,11 @@ namespace Managers
|
|||||||
ship.cameraOperator = MatchCamera.GetComponent<CameraOperator>();
|
ship.cameraOperator = MatchCamera.GetComponent<CameraOperator>();
|
||||||
shipObject.transform.SetParent(MatchArena.transform, false);
|
shipObject.transform.SetParent(MatchArena.transform, false);
|
||||||
shipObject.transform.localPosition =
|
shipObject.transform.localPosition =
|
||||||
ArenaProperties.spawnPositions[p.playerNumber - 1];
|
arenaProperties.spawnPositions[p.playerNumber - 1];
|
||||||
|
|
||||||
shipObject.transform.localScale = new Vector3();
|
shipObject.transform.localScale = new Vector3();
|
||||||
Tween.Scale(shipObject.transform, new Vector3(0.7f, 0.7f, 0.7f), 1f);
|
Tween.Scale(shipObject.transform, new Vector3(0.7f, 0.7f, 0.7f), 1f);
|
||||||
MatchPlayers.Add(p);
|
matchPlayers.Add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,18 +397,15 @@ namespace Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ResetMatchCharacters()
|
public void ResetMatchCharacters()
|
||||||
{
|
{
|
||||||
foreach (Player mp in MatchPlayers)
|
foreach (Player mp in matchPlayers)
|
||||||
{
|
{
|
||||||
GameObject shipGO = mp.spawnedCharacter;
|
GameObject shipGO = mp.spawnedCharacter;
|
||||||
shipGO.TryGetComponent(out Ship ship);
|
shipGO.TryGetComponent(out Ship ship);
|
||||||
shipGO.TryGetComponent(out Rigidbody body);
|
|
||||||
|
|
||||||
ship.state.boostCapacity = ship.props.maxBoostCapacity;
|
ship.state.boostCapacity = ship.props.maxBoostCapacity;
|
||||||
|
|
||||||
body.velocity = Vector3.zero;
|
|
||||||
|
|
||||||
shipGO.transform.localPosition =
|
shipGO.transform.localPosition =
|
||||||
ArenaProperties.spawnPositions[mp.playerNumber - 1];
|
arenaProperties.spawnPositions[mp.playerNumber - 1];
|
||||||
shipGO.transform.rotation = shipGO.transform.parent.rotation;
|
shipGO.transform.rotation = shipGO.transform.parent.rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,8 @@ namespace Managers
|
|||||||
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
[SerializeField] public bool IsUIActiveScene { get; set; }
|
[SerializeField] public bool IsUIActiveScene { get; set; }
|
||||||
public HUD hUD { get; private set; }
|
public HUD hUD { get; private set; }
|
||||||
public Announcments Announcments { get; private set; }
|
public Announcments announcments { get; private set; }
|
||||||
public PauseMenu PauseMenu { get; private set; }
|
public PauseMenu pauseMenu { get; private set; }
|
||||||
public MatchEndMenu MatchEndMenu { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Globally accessible member to use manager with.
|
/// Globally accessible member to use manager with.
|
||||||
@ -31,7 +30,7 @@ namespace Managers
|
|||||||
public bool StartManagingMatchUI()
|
public bool StartManagingMatchUI()
|
||||||
{
|
{
|
||||||
if (!StartManagingHUD() || !StartManagingAnnouncements()
|
if (!StartManagingHUD() || !StartManagingAnnouncements()
|
||||||
|| !StartManagingPauseMenu() || !StartManagingMatchEndMenu())
|
|| !StartManagingPauseMenu())
|
||||||
{
|
{
|
||||||
Log.Error("Problems when starting in game match UI.");
|
Log.Error("Problems when starting in game match UI.");
|
||||||
return false;
|
return false;
|
||||||
@ -56,7 +55,7 @@ namespace Managers
|
|||||||
|
|
||||||
public bool StartManagingPauseMenu()
|
public bool StartManagingPauseMenu()
|
||||||
{
|
{
|
||||||
if (PauseMenu == null)
|
if (pauseMenu == null)
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.Find("Paused Menu");
|
GameObject go = GameObject.Find("Paused Menu");
|
||||||
if (go == null)
|
if (go == null)
|
||||||
@ -64,29 +63,14 @@ namespace Managers
|
|||||||
Log.Error("Could not find Pause Menu GameObject in loaded scenes!");
|
Log.Error("Could not find Pause Menu GameObject in loaded scenes!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PauseMenu = go.GetComponent<PauseMenu>();
|
pauseMenu = go.GetComponent<PauseMenu>();
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StartManagingMatchEndMenu()
|
|
||||||
{
|
|
||||||
if (MatchEndMenu == null)
|
|
||||||
{
|
|
||||||
GameObject go = GameObject.Find("Match End Menu");
|
|
||||||
if (go == null)
|
|
||||||
{
|
|
||||||
Log.Error("Could not find Match End Menu GameObject in loaded scenes!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MatchEndMenu = go.GetComponent<MatchEndMenu>();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StartManagingAnnouncements()
|
public bool StartManagingAnnouncements()
|
||||||
{
|
{
|
||||||
if (Announcments == null)
|
if (announcments == null)
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.Find("Announcer UI");
|
GameObject go = GameObject.Find("Announcer UI");
|
||||||
if (go == null)
|
if (go == null)
|
||||||
@ -94,7 +78,7 @@ namespace Managers
|
|||||||
Log.Error("Could not find Pause Menu GameObject in loaded scenes!");
|
Log.Error("Could not find Pause Menu GameObject in loaded scenes!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Announcments = go.GetComponent<Announcments>();
|
announcments = go.GetComponent<Announcments>();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -120,30 +104,21 @@ namespace Managers
|
|||||||
|
|
||||||
public void ShowMatchStartPrompt()
|
public void ShowMatchStartPrompt()
|
||||||
{
|
{
|
||||||
Announcments.AnnounceText("Press Start/Enter \n to start the match!");
|
announcments.AnnounceText("Press Start/Enter \n to start the match!");
|
||||||
}
|
}
|
||||||
public void HideAnnouncement()
|
public void HideAnnouncement()
|
||||||
{
|
{
|
||||||
Announcments.StopAnnouncement();
|
announcments.StopAnnouncement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowPauseMenu(Transform transform)
|
public void ShowPauseMenu(Transform transform)
|
||||||
{
|
{
|
||||||
PauseMenu?.Show(transform);
|
pauseMenu?.Show(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HidePauseMenu()
|
public void HidePauseMenu()
|
||||||
{
|
{
|
||||||
PauseMenu?.Hide();
|
pauseMenu?.Hide();
|
||||||
}
|
|
||||||
public void ShowMatchEndMenu(Transform transform)
|
|
||||||
{
|
|
||||||
MatchEndMenu?.Show(transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HideMatchEndMenu()
|
|
||||||
{
|
|
||||||
MatchEndMenu?.Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideHUD()
|
public void HideHUD()
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
@ -20,8 +19,7 @@ namespace GameLogic
|
|||||||
/// <param name="args">Update to the matches conditions</param>
|
/// <param name="args">Update to the matches conditions</param>
|
||||||
/// <param name="mps">Dictionary of the players in the match and their current stats</param>
|
/// <param name="mps">Dictionary of the players in the match and their current stats</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static void UpdateMatchResult(Player p, MatchConditionUpdate args,
|
public static MatchResult UpdateMatchResult(Player p, MatchConditionUpdate args, Dictionary<Player, MatchPlayerStatistic> mps)
|
||||||
Dictionary<Player, MatchPlayerStatistic> mps, GameResult result)
|
|
||||||
{
|
{
|
||||||
switch (args.Condition)
|
switch (args.Condition)
|
||||||
{
|
{
|
||||||
@ -35,7 +33,7 @@ namespace GameLogic
|
|||||||
UpdateTime(mps[p], args.Count);
|
UpdateTime(mps[p], args.Count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.UpdateGameResult(mps, currentRule);
|
return DetectMatchResult(mps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateLives(MatchPlayerStatistic mps, int count)
|
public static void UpdateLives(MatchPlayerStatistic mps, int count)
|
||||||
@ -57,53 +55,36 @@ namespace GameLogic
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Detects if a match has concluded.
|
||||||
|
/// Currently only checks if all but on player is out.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mps">Dictonary of the players and their match data.</param>
|
||||||
|
/// <returns>Match result object, if the match has concluded</returns>
|
||||||
|
private static MatchResult DetectMatchResult(Dictionary<Player, MatchPlayerStatistic> mps)
|
||||||
|
{
|
||||||
|
int outPlayers = mps.Count(p => p.Value.IsOut);
|
||||||
|
if (outPlayers == mps.Count - 1)
|
||||||
|
{
|
||||||
|
return new MatchResult(mps);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data class which records the results of a Match
|
/// Data class which records the results of a Match
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameResult
|
public class MatchResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Indicates whether a round or the whole match was won
|
|
||||||
/// </summary>
|
|
||||||
public bool IsMatchWon { get; private set; }
|
|
||||||
public int RoundsPlayed { get; private set; }
|
|
||||||
public Player Winner { get; private set; }
|
public Player Winner { get; private set; }
|
||||||
public List<Player> Opponents { get; private set; }
|
public List<Player> Opponents { get; private set; }
|
||||||
public GUID GameID { get; private set; }
|
public GUID GameID { get; private set; }
|
||||||
public GameResult()
|
public MatchResult(Dictionary<Player, MatchPlayerStatistic> mps)
|
||||||
{
|
{
|
||||||
GameID = GUID.Generate();
|
GameID = GUID.Generate();
|
||||||
}
|
Winner = mps.First(p => p.Value.IsOut != true).Key;
|
||||||
/// <summary>
|
Opponents = mps.Keys.Where(player => player != Winner).ToList();
|
||||||
/// Checks whether a round is won and if that round decided the match.
|
|
||||||
/// Sets the class properties accordingly.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mps">Dictionary of players with their statistics for this match</param>
|
|
||||||
/// <param name="rules">The rules for this match</param>
|
|
||||||
public void UpdateGameResult(Dictionary<Player, MatchPlayerStatistic> mps, MatchRule rules)
|
|
||||||
{
|
|
||||||
int outPlayers = mps.Count(p => p.Value.IsOut);
|
|
||||||
if (outPlayers == mps.Count - 1)
|
|
||||||
{
|
|
||||||
Winner = mps.First(p => p.Value.IsOut != true).Key;
|
|
||||||
Opponents = mps.Keys.Where(player => player != Winner).ToList();
|
|
||||||
mps[Winner].RoundsWon += 1;
|
|
||||||
RoundsPlayed += 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Winner = null;
|
|
||||||
}
|
|
||||||
// TODO: this is wrong winning 2 rounds can decide the match
|
|
||||||
if (RoundsPlayed == rules.rounds)
|
|
||||||
{
|
|
||||||
IsMatchWon = true;
|
|
||||||
Winner = mps.Aggregate((p1, p2) =>
|
|
||||||
p1.Value.RoundsWon > p2.Value.RoundsWon ? p1 : p2).Key;
|
|
||||||
Opponents = mps.Keys.Where(player => player != Winner).ToList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,7 +3,10 @@ using UnityEngine;
|
|||||||
using static AffectingForcesManager;
|
using static AffectingForcesManager;
|
||||||
using ShipHandling;
|
using ShipHandling;
|
||||||
using Managers;
|
using Managers;
|
||||||
|
using GameLogic;
|
||||||
|
using Unity.VisualScripting;
|
||||||
using Unity.Mathematics;
|
using Unity.Mathematics;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
public class Ship : MonoBehaviour
|
public class Ship : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,76 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using Managers;
|
|
||||||
using SlimUI.ModernMenu;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
public class MatchEndMenu : MonoBehaviour
|
|
||||||
{
|
|
||||||
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
private Canvas Canvas;
|
|
||||||
public GameObject Camera;
|
|
||||||
public GameObject UIEventSystem;
|
|
||||||
public GameObject MenuButtons;
|
|
||||||
public GameObject FocusButtonRematch;
|
|
||||||
|
|
||||||
private EventSystem eventSystem;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
Canvas = gameObject.GetComponent<Canvas>();
|
|
||||||
Canvas.enabled = false;
|
|
||||||
MenuButtons.SetActive(false);
|
|
||||||
eventSystem = UIEventSystem.GetComponent<EventSystem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Show(Transform transform)
|
|
||||||
{
|
|
||||||
gameObject.transform.position = transform.position;
|
|
||||||
gameObject.transform.rotation = transform.rotation;
|
|
||||||
Canvas.enabled = true;
|
|
||||||
Camera.SetActive(true);
|
|
||||||
UIEventSystem.SetActive(true);
|
|
||||||
MenuButtons.SetActive(true);
|
|
||||||
eventSystem.SetSelectedGameObject(FocusButtonRematch, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Hide()
|
|
||||||
{
|
|
||||||
Canvas.enabled = false;
|
|
||||||
Camera.SetActive(false);
|
|
||||||
UIEventSystem.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnRematch()
|
|
||||||
{
|
|
||||||
MatchManager.G.StartRematch();
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnMainMenu()
|
|
||||||
{
|
|
||||||
StartCoroutine(StartSceneTransition());
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator StartSceneTransition()
|
|
||||||
{
|
|
||||||
Canvas.enabled = false;
|
|
||||||
SceneManager.LoadScene((int)Scenes.MainMenu, LoadSceneMode.Additive);
|
|
||||||
yield return new WaitForSeconds(0.2f);
|
|
||||||
GameObject menu = GameObject.Find("Main Menu Camera");
|
|
||||||
if (menu != null && menu.TryGetComponent(out SlimUIMainMenu menuScript))
|
|
||||||
{
|
|
||||||
UIManager.G.HideHUD();
|
|
||||||
menuScript.MenuTransition(Camera.GetComponent<Camera>().transform);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Error("Can't transition back to main menu. Menu camera or script not found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b892c3598ac2a8c4e827dbfeee948246
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -24,7 +24,6 @@ public class PauseMenu : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Canvas = gameObject.GetComponent<Canvas>();
|
Canvas = gameObject.GetComponent<Canvas>();
|
||||||
Canvas.enabled = false;
|
Canvas.enabled = false;
|
||||||
PauseMenuButtons.SetActive(false);
|
|
||||||
eventSystem = UIEventSystem.GetComponent<EventSystem>();
|
eventSystem = UIEventSystem.GetComponent<EventSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user