214 lines
7.9 KiB
C#
214 lines
7.9 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using TMPro;
|
||
|
|
using Util;
|
||
|
|
|
||
|
|
public class PreGameManager : MonoBehaviour
|
||
|
|
{
|
||
|
|
public static PreGameManager Instance;
|
||
|
|
[SerializeField] private CharacterPool characterPool;
|
||
|
|
[SerializeField] private Image mapImage;
|
||
|
|
[SerializeField] private TMP_Text mapName;
|
||
|
|
//[SerializeField] private List<Sprite> mapImages;
|
||
|
|
//[SerializeField] private List<string> mapNames;
|
||
|
|
//[SerializeField] private int mapcounter;
|
||
|
|
|
||
|
|
[Space]
|
||
|
|
|
||
|
|
public TextMeshProUGUI CharacterName;
|
||
|
|
public TextMeshProUGUI characterHealthValue;
|
||
|
|
public TextMeshProUGUI characterDamageReductionValue;
|
||
|
|
public TextMeshProUGUI characterReloadSpeedMultipler;
|
||
|
|
public TextMeshProUGUI characterDamageMultiplerValue;
|
||
|
|
public TextMeshProUGUI characterMoveSpeedValue;
|
||
|
|
public TextMeshProUGUI characterSpecialHeader;
|
||
|
|
public TextMeshProUGUI characterSpecialStatDescription;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
Instance = this;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnEnable()
|
||
|
|
{
|
||
|
|
Client.Instance.SetMapNameAndImage(mapName, mapImage);
|
||
|
|
//mapcounter = 0;
|
||
|
|
//Client.Instance.SetMapNameAndImage(mapName, mapImage, mapNames[0], mapImages[0]);
|
||
|
|
|
||
|
|
foreach (var charData in CharacterPool.listOfCharacter)
|
||
|
|
{
|
||
|
|
if (!Player.Instance) break;
|
||
|
|
if (!Player.Instance.PlayerEntity) break;
|
||
|
|
|
||
|
|
if (charData.skinName == Player.Instance.PlayerEntity.GetSkinID())
|
||
|
|
{
|
||
|
|
// Debugger.Logger( $"Last Selected Character is {charData.root.name} index {charData.skinName} name {charData.selectionSkinName}");
|
||
|
|
var index = CharacterPool.ServerToClientIndex[charData.root.name];
|
||
|
|
var ch = $"Character_{index}";
|
||
|
|
PacketManager.sendButtonClick(ch);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetMoveSpeedStat(float scale, float speed)
|
||
|
|
{
|
||
|
|
int percentage = Mathf.RoundToInt(100 * (scale - 1f));
|
||
|
|
string color = percentage < 0 ? "red" : "green";
|
||
|
|
characterMoveSpeedValue.text = scale == 1 ? $"{speed}" : $"<size={17}><color={color}>{percentage:+#;-#;0}%</color></size> {speed}";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetDamageReductionStat(float scale)
|
||
|
|
{
|
||
|
|
int percentage = Mathf.RoundToInt(100 * (scale - 1f));
|
||
|
|
string color = percentage < 0 ? "red" : "green";
|
||
|
|
characterDamageReductionValue.text = scale == 1 ? "1x" : $"<size={17}><color={color}>{percentage:+#;-#;0}%</color></size> {scale}x";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetMaxHealthStat(float maxHealth)
|
||
|
|
{
|
||
|
|
float scale = maxHealth / 1000f;
|
||
|
|
int percentage = Mathf.RoundToInt(100 * (scale - 1f));
|
||
|
|
string color = percentage < 0 ? "red" : "green";
|
||
|
|
characterHealthValue.text = scale == 1 ? $"{maxHealth}" : $"<size={17}><color={color}>{percentage:+#;-#;0}%</color></size> {maxHealth}";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetReloadSpeedStat(float scale)
|
||
|
|
{
|
||
|
|
int percentage = Mathf.RoundToInt(100 * (scale - 1f));
|
||
|
|
string color = percentage < 0 ? "red" : "green";
|
||
|
|
characterReloadSpeedMultipler.text = scale == 1 ? "1x" : $"<size={17}><color={color}>{percentage:+#;-#;0}%</color></size> {scale}x";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetDamageStat(float scale)
|
||
|
|
{
|
||
|
|
int percentage = Mathf.RoundToInt(100 * (scale - 1f));
|
||
|
|
string color = percentage < 0 ? "red" : "green";
|
||
|
|
characterDamageMultiplerValue.text = scale == 1 ? "1x" : $"<size={17}><color={color}>{percentage:+#;-#;0}%</color></size> {scale}x";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetSpecialStat(string skin)
|
||
|
|
{
|
||
|
|
string specialStatHeader = "";
|
||
|
|
string specialStatDesc;
|
||
|
|
switch (skin)
|
||
|
|
{
|
||
|
|
case CharacterNames.BONNIE:
|
||
|
|
specialStatHeader = "Nade Happy:";
|
||
|
|
specialStatDesc = "Start game with a grenade";
|
||
|
|
break;
|
||
|
|
case CharacterNames.FLAMMA:
|
||
|
|
specialStatHeader = "Locked 'n Loaded:";
|
||
|
|
specialStatDesc = "Increase reserve ammo by 50.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.KORAKA:
|
||
|
|
specialStatHeader = "Heavy Footed:";
|
||
|
|
specialStatDesc = "Immune To Knockback.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.MUSASHI:
|
||
|
|
specialStatHeader = "Samurai's Way:";
|
||
|
|
specialStatDesc = "Using a heal potion heals other players a portion.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.NAKANO:
|
||
|
|
specialStatHeader = "Heal Aura:";
|
||
|
|
specialStatDesc = "+20hp every 10 seconds.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.SHIYANG:
|
||
|
|
specialStatHeader = "Full Metal Jacket:";
|
||
|
|
specialStatDesc = "First shot on enemy deals double damage. (Max +100).";
|
||
|
|
break;
|
||
|
|
case CharacterNames.JEANETTE:
|
||
|
|
specialStatHeader = "Defenders Might:";
|
||
|
|
specialStatDesc = "Potions heal extra 200HP.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.BUTCH:
|
||
|
|
specialStatHeader = "Criminal Justice:";
|
||
|
|
specialStatDesc = "Each kill heals you for 10hp.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.KNIGHT:
|
||
|
|
specialStatHeader = "Heavy Footed:";
|
||
|
|
specialStatDesc = "Immune To Knockback.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.BRUISER:
|
||
|
|
specialStatHeader = "Full Metal Jacket:";
|
||
|
|
specialStatDesc = "First shot on enemy deals double damage. (Max +50).";
|
||
|
|
break;
|
||
|
|
case CharacterNames.TACTICIAN:
|
||
|
|
specialStatHeader = "Nade Happy:";
|
||
|
|
specialStatDesc = "Start game with 2 grenades.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.DRUID:
|
||
|
|
specialStatHeader = "Heal Aura";
|
||
|
|
specialStatDesc = "+10hp every 10 seconds.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.KING:
|
||
|
|
specialStatHeader = "Locked 'n Loaded:";
|
||
|
|
specialStatDesc = "Increase reserve ammo by 100.";
|
||
|
|
break;
|
||
|
|
case CharacterNames.QUEEN:
|
||
|
|
specialStatHeader = "Revitalize:";
|
||
|
|
specialStatDesc = "Using a heal potion heals other players a portion.";
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
specialStatDesc = "None.";
|
||
|
|
specialStatHeader = "";
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
characterSpecialHeader.text = specialStatHeader;
|
||
|
|
characterSpecialStatDescription.text = specialStatDesc;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetCharacterName(string characterName)
|
||
|
|
{
|
||
|
|
CharacterName.SetText(characterName);
|
||
|
|
}
|
||
|
|
//public void NextMapButton()
|
||
|
|
//{
|
||
|
|
// if (mapcounter == mapNames.Count-1)
|
||
|
|
// {
|
||
|
|
// mapcounter = 0;
|
||
|
|
// mapImage.sprite = mapImages[mapcounter];
|
||
|
|
// mapName.text = mapNames[mapcounter];
|
||
|
|
// //Client.Instance.SetMapNameAndImage(mapName, mapImage, mapNames[mapcounter], mapImages[mapcounter]);
|
||
|
|
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// mapcounter++;
|
||
|
|
// mapImage.sprite = mapImages[mapcounter];
|
||
|
|
// mapName.text = mapNames[mapcounter];
|
||
|
|
// //Client.Instance.SetMapNameAndImage(mapName, mapImage, mapNames[mapcounter], mapImages[mapcounter]);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// }
|
||
|
|
|
||
|
|
//}
|
||
|
|
//public void PreviousMapButton()
|
||
|
|
//{
|
||
|
|
// if (mapcounter == 0)
|
||
|
|
// {
|
||
|
|
// mapcounter = mapNames.Count-1;
|
||
|
|
// mapImage.sprite = mapImages[mapcounter];
|
||
|
|
// mapName.text = mapNames[mapcounter];
|
||
|
|
// //Client.Instance.SetMapNameAndImage(mapName, mapImage, mapNames[mapcounter], mapImages[mapcounter]);
|
||
|
|
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// mapcounter--;
|
||
|
|
// mapImage.sprite = mapImages[mapcounter];
|
||
|
|
// mapName.text = mapNames[mapcounter];
|
||
|
|
// //Client.Instance.SetMapNameAndImage(mapName, mapImage, mapNames[mapcounter], mapImages[mapcounter]);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// }
|
||
|
|
|
||
|
|
//}
|
||
|
|
}
|