Ranked done, Shop done and many fixes

This commit is contained in:
Sewmina 2022-09-20 00:16:35 +05:30
parent 4194d2decc
commit f4e5b60bbf
166 changed files with 15171 additions and 1586 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44402248, g: 0.49316555, b: 0.5722324, a: 1}
m_IndirectSpecularColor: {r: 0.4465791, g: 0.4964133, b: 0.57481784, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -123,49 +123,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &5820110
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5820111}
- component: {fileID: 5820112}
m_Layer: 0
m_Name: SpawnPoint (10)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5820111
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5820110}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -202, y: -89, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5820112
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5820110}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &7902094
GameObject:
m_ObjectHideFlags: 0
@ -5211,7 +5168,7 @@ MonoBehaviour:
authenticator: {fileID: 0}
playerPrefab: {fileID: 5431987895376475548, guid: e811a838f2ebb2f4fb8055331ed295e9, type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 0
playerSpawnMethod: 1
spawnPrefabs:
- {fileID: 5339383961425506408, guid: ad54ea1b437d2b344add56c18d1efb3e, type: 3}
- {fileID: 8298505072154104440, guid: 8cfd89c315493e64782e167885b4b498, type: 3}
@ -5256,6 +5213,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
isClient: 1
isRanked: 0
transport: {fileID: 0}
--- !u!1 &43679075
GameObject:
m_ObjectHideFlags: 0
@ -5959,6 +5918,7 @@ MonoBehaviour:
metalEarnings: {fileID: 5001849304093201857}
survivalTimeTxt: {fileID: 139961636}
mostTimeTxt: {fileID: 2120458708}
gameOverTxt: {fileID: 0}
boostBtn: {fileID: 2133876932}
timerTxt: {fileID: 297250423}
--- !u!4 &332697609
@ -5989,9 +5949,14 @@ MonoBehaviour:
m_EditorClassIdentifier:
syncMode: 0
syncInterval: 0.1
mapRadius: 500
maxMoons: 700
maxStars: 1000
isRanked: 0
RankedGameStarted: 0
winnerId: -1
waitingScreen: {fileID: 0}
rankedSummary: {fileID: 0}
mapRadius: 250
maxMoons: 350
maxStars: 500
pickupItemsParent: {fileID: 41572335}
moon: {fileID: 5339383961425506408, guid: ad54ea1b437d2b344add56c18d1efb3e, type: 3}
star: {fileID: 8298505072154104440, guid: 8cfd89c315493e64782e167885b4b498, type: 3}
@ -6579,7 +6544,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 494509960}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -678, y: -58, z: 0}
m_LocalPosition: {x: -439, y: -244, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -6969,7 +6934,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 613727044}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -571, y: -748, z: 0}
m_LocalPosition: {x: -308, y: -341, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -7229,7 +7194,7 @@ Transform:
m_GameObject: {fileID: 725845372}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 32.2, y: 32.2, z: 1}
m_LocalScale: {x: 16.1, y: 16.1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
@ -8011,7 +7976,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871230063}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -264, y: -527, z: 0}
m_LocalPosition: {x: -356, y: -562, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -8239,7 +8204,6 @@ Transform:
- {fileID: 1837953384}
- {fileID: 494509961}
- {fileID: 1398901127}
- {fileID: 5820111}
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -8588,6 +8552,7 @@ MonoBehaviour:
- {fileID: 37150598}
- {fileID: 2145051021}
updateInterval: 0.5
isRanked: 0
--- !u!1 &1118240007
GameObject:
m_ObjectHideFlags: 0
@ -9280,7 +9245,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1398901126}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -642, y: -349, z: 0}
m_LocalPosition: {x: -328, y: -556, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -9398,7 +9363,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1474265870}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -270, y: -746, z: 0}
m_LocalPosition: {x: -250, y: -411, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -9915,7 +9880,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1837953383}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -356, y: -510, z: 0}
m_LocalPosition: {x: -382, y: -597, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -9958,7 +9923,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1853399998}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -472, y: -531, z: 0}
m_LocalPosition: {x: -572, y: -423, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 945516891}
@ -10440,7 +10405,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &2133876931
RectTransform:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9874c3508c7e3534ab371989fd8cf992
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,6 +11,7 @@ public class ChestOpener : MonoBehaviour
public GameObject chestOpenPopup;
public bool active => chestOpenPopup.activeSelf;
public Animator chestAnim;
public GameObject gemsDrop;
public GameObject goldDrop;
@ -24,10 +25,10 @@ public class ChestOpener : MonoBehaviour
instance = this;
}
public async void OpenChest(){
public async void OpenChest(int minLuck, int maxLuck){
chestOpenPopup.SetActive(true);
okButton.SetActive(false);
int luckiness= Random.Range(0,100);
int luckiness= Random.Range(minLuck,maxLuck);
List<SkinShopItemData> baseSkins = new List<SkinShopItemData>();
List<SkinShopItemData> rareSkins = new List<SkinShopItemData>();
List<SkinShopItemData> legendarySkins = new List<SkinShopItemData>();

View File

@ -10,7 +10,7 @@ using System.Net;
using System.Net.Sockets;
public class DBmanager : MonoBehaviour
{
public static string phpRoot = "http://vps.playpoolstudios.com/upf/";
public static string phpRoot = "http://vmi1005083.contaboserver.net/upf/";
public static string username = null;
@ -22,6 +22,7 @@ public class DBmanager : MonoBehaviour
private static int trophies = 0;
private static int mostTime=0;
private static int doubleKills,tripleKills,quadKills,pentaKills = 0;
private static DateTime lastCollectedDailyChest;
private static List<InventoryEntry> inventory;
private static List<int> expPassCollected = new List<int>();
@ -39,6 +40,7 @@ public class DBmanager : MonoBehaviour
public static int TripleKills => tripleKills;
public static int QuadKills => quadKills;
public static int PentaKills => pentaKills;
public static DateTime LastCollectedDailyChest => lastCollectedDailyChest;
public static float Level => level;
public static int LevelInt => Mathf.CeilToInt(level);
public static List<int> ExpPassCollected => expPassCollected;
@ -218,7 +220,9 @@ public class DBmanager : MonoBehaviour
WWWForm form = new WWWForm();
form.AddField("name", username);
form.AddField("gems", newValue);
if (justOffline) { gems = newValue; return; }
int oldVal = Gems;
gems = newValue;
if (justOffline) {return; }
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "set_gems.php", form))
{
var operation = www.SendWebRequest();
@ -235,6 +239,7 @@ public class DBmanager : MonoBehaviour
{
Debug.Log("Response : " + www.downloadHandler.text);
Debug.LogWarning("Failed to set gems to " + newValue);
gems = oldVal;
}
}
@ -247,7 +252,9 @@ public class DBmanager : MonoBehaviour
WWWForm form = new WWWForm();
form.AddField("name", username);
form.AddField("metal", newValue);
if (justOffline) { metal = newValue; return; }
int oldVal = metal;
metal = newValue;
if (justOffline) { return; }
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "set_metal.php", form))
{
var operation = www.SendWebRequest();
@ -265,6 +272,7 @@ public class DBmanager : MonoBehaviour
{
Debug.Log("Response : " + www.downloadHandler.text);
Debug.LogWarning("Failed to set metal to " + newValue);
metal = oldVal;
}
}
@ -461,6 +469,40 @@ public class DBmanager : MonoBehaviour
OnStateChanged.Invoke();
}
public async static void SetLastCollectedDailyChest(string newValue, bool justOffline = false)
{
WWWForm form = new WWWForm();
form.AddField("name", username);
form.AddField("value", newValue);
DateTime oldValue = lastCollectedDailyChest;
lastCollectedDailyChest = DateTime.Parse(newValue);
Debug.Log(newValue + ":"+lastCollectedDailyChest);
if (justOffline) { return; }
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "set_daily_chest_collected.php", form))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
if (www.downloadHandler.text == "0")
{
}
else
{
lastCollectedDailyChest = oldValue;
Debug.Log("Response : " + www.downloadHandler.text);
Debug.LogWarning("Failed to set lastCollectedDailyChest to " + newValue);
}
}
GameManager.Refresh();
OnStateChanged.Invoke();
}
public static void SetExpPassCollected(string rawData, bool justOffline = false)
{
try

View File

@ -132,5 +132,33 @@ public class GameManager : MonoBehaviour
public void LoadRanked(){
LoadingScreen.instance.LoadLevel("MinigameMatchmaking");
}
public void Signout(){
PlayerPrefs.DeleteAll();
PlayerPrefs.Save();
LoadingScreen.instance.LoadLevel("Login");
}
public void BuyChest(ChestButton button){
if(DBmanager.Gems < button.Price){
MessageDialog.instance.ShowDialog("Failed", "Insufficient Gems to complete the purchase");
return;
}
DBmanager.SetGems(DBmanager.Gems-button.Price);
ChestOpener.instance.OpenChest((int)button.minLuck, (int)button.maxLuck);
}
public void BuyGold(GoldPackButton button){
if(DBmanager.Gems < button.Price){
MessageDialog.instance.ShowDialog("Failed", "Insufficient Gems to complete the purchase");
return;
}
DBmanager.SetGems(DBmanager.Gems-button.Price);
DBmanager.SetCoins(DBmanager.Coins + button.Amount);
}
}

View File

@ -9,6 +9,8 @@ public class LoadingScreen : MonoBehaviour
CanvasGroup canvasGroup;
public Slider loadingProgress;
public TMPro.TMP_Text loadingProgressTxt;
private static bool loading;
public static bool Loading => loading;
void Awake(){
instance =this;
@ -20,10 +22,12 @@ public class LoadingScreen : MonoBehaviour
}
public void LoadLevel(string levelName){
if(loading){return;}loading=true;
StartCoroutine(loadlLevel(levelName));
}
IEnumerator loadlLevel(string levelName){
loading=true;
canvasGroup.alpha=0;
canvasGroup.blocksRaycasts=true;
SetProgress(0);
@ -53,10 +57,11 @@ public class LoadingScreen : MonoBehaviour
canvasGroup.alpha-=0.03f;
yield return new WaitForFixedUpdate();
}
loading=false;
}
void SetProgress(float value){
loadingProgress.value = value;
loadingProgressTxt.text = (int)(value*100) + "%";
loadingProgress.value = value;
loadingProgressTxt.text = (int)(value*100) + "%";
}
}

View File

@ -81,6 +81,7 @@ public class LoginManager : MonoBehaviour
PlayerPrefs.Save();}
DBmanager.username = login_username.text;
DBmanager.SetLastCollectedDailyChest(www.text.Split('\t')[15],true);
DBmanager.SetPentaKills(int.Parse(www.text.Split('\t')[14]),true);
DBmanager.SetQuadKills(int.Parse(www.text.Split('\t')[13]),true);
DBmanager.SetTripleKills(int.Parse(www.text.Split('\t')[12]),true);

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
@ -20,6 +21,7 @@ public class MessageDialog : MonoBehaviour
m_instance = this;
actionBtn.onClick.AddListener(OnAction);
SetActive(false);
DontDestroyOnLoad(gameObject);
}
void OnAction(){
@ -28,11 +30,19 @@ public class MessageDialog : MonoBehaviour
}
}
public void ShowDialog(string title, string message){
public async void ShowDialog(string title, string message){
titleTxt.text = title;
messageTxt.text = message;
SetActive(true);
Canvas.ForceUpdateCanvases();
GetComponentInChildren<VerticalLayoutGroup>().enabled=false;
GetComponentInChildren<VerticalLayoutGroup>().enabled=true;
// messageTxt.gameObject.SetActive(true);
}
public void SetActive(bool value){

View File

@ -6,56 +6,120 @@ using LightReflectiveMirror;
public class AutoConnect : MonoBehaviour
{
public bool isClient;
public static bool isRankedServer;
public static string serverName;
public static int serverPort;
public bool isRanked;
public LightReflectiveMirrorTransport lrm;
public kcp2k.KcpTransport transport;
void Start()
{
if(isRanked){
if (isRanked)
{
if(!isRankedServer){
lrm.serverListUpdated.AddListener(OnServerListUpdated);
StartCoroutine(refreshList());
}else{
StartCoroutine(startHost());
// if(!isRankedServer){
// lrm.serverListUpdated.AddListener(OnServerListUpdated);
// StartCoroutine(refreshList());
// }else{
// StartCoroutine(startHost());
// }
string[] args = System.Environment.GetCommandLineArgs();
string input = "";
for (int i = 0; i < args.Length; i++)
{
// Debug.Log("ARG " + i + ": " + args[i]);
if (args[i] == "-port")
{
input = args[i + 1];
}
}
ushort port = 7777;
try
{
port = ushort.Parse(input);
}
catch
{
}
}else{
if(isClient){
if(!isClient){
Debug.Log("Setting port to " + port);
transport.Port = port;
NetworkManager.singleton.StartServer();
}else{
NetworkManager.singleton.networkAddress = RegionManager.selectedServer.ip;
transport.Port = (ushort)serverPort;
NetworkManager.singleton.StartClient();
}
}
else
{
if (isClient)
{
FindObjectOfType<NetworkManager>().networkAddress = RegionManager.selectedServer.ip;
FindObjectOfType<NetworkManager>().StartClient();
}
}
}
IEnumerator startHost(){
while(!lrm.isConnectedToRelay){
yield return new WaitForSeconds(1);
}
lrm.serverName = serverName;
lrm.isPublicServer=true;
NetworkManager.singleton.StartHost();
}
IEnumerator refreshList(){
while(!lrm.isConnectedToRelay){
yield return new WaitForSeconds(1);
}
while(!NetworkManager.singleton.isNetworkActive){
yield return new WaitForSeconds(1);
lrm.RequestServerList();
}
}
void OnServerListUpdated(){
Debug.Log("Got new server list of " + lrm.relayServerList.Count);
foreach(Room room in lrm.relayServerList){
if(room.serverName == serverName){
Debug.Log("Found server for me! Joining now");
NetworkManager.singleton.networkAddress = room.serverId;
NetworkManager.singleton.StartClient();
float t;
void Update(){
if(isRanked && !isClient){
//timer
t += Time.deltaTime;
if(t > 30 && FindObjectsOfType<SpaceshipController>().Length ==0){
//No players joined, or they left, gotta close my self
t=0;
StartCoroutine(CloseRoom());
}
}
}
IEnumerator CloseRoom(){
WWWForm form = new WWWForm();
form.AddField("port", serverPort);
WWW req = new WWW(DBmanager.phpRoot+"clear_ranked_room.php",form);
yield return req;
Application.Quit();
}
// IEnumerator startHost()
// {
// while (!lrm.isConnectedToRelay)
// {
// yield return new WaitForSeconds(1);
// }
// lrm.serverName = serverName;
// lrm.isPublicServer = true;
// NetworkManager.singleton.StartHost();
// }
// IEnumerator refreshList()
// {
// while (!lrm.isConnectedToRelay)
// {
// yield return new WaitForSeconds(1);
// }
// while (!NetworkManager.singleton.isNetworkActive)
// {
// yield return new WaitForSeconds(1);
// lrm.RequestServerList();
// }
// }
// void OnServerListUpdated()
// {
// Debug.Log("Got new server list of " + lrm.relayServerList.Count);
// foreach (Room room in lrm.relayServerList)
// {
// if (room.serverName == serverName)
// {
// Debug.Log("Found server for me! Joining now");
// NetworkManager.singleton.networkAddress = room.serverId;
// NetworkManager.singleton.StartClient();
// }
// }
// }
}

View File

@ -36,7 +36,7 @@ public class Leaderboard : MonoBehaviour
{
for (int i = 0; i <= players.Length - 2; i++)
{
if ( (isRanked ? players[i].moonsCollected : players[i].Scores) > (isRanked? players[i+1].moonsCollected : players[i + 1].Scores))
if ( (!isRanked ? players[i].moonsCollected : players[i].Scores) > (!isRanked? players[i+1].moonsCollected : players[i + 1].Scores))
{
temp = players[i + 1];
players[i + 1] = players[i];
@ -51,7 +51,7 @@ public class Leaderboard : MonoBehaviour
SpaceshipController thisPlayer = players[players.Length-i-1];
leaderboardItems[i].gameObject.SetActive(true);
leaderboardItems[i].text = (i+1) + ". " +thisPlayer.pname;
if(isRanked){
if(!isRanked){
leaderboardItems[i].transform.GetChild(0).GetComponent<Text>().text = thisPlayer.Scores.ToString();
}else{
leaderboardItems[i].transform.GetChild(0).GetComponent<Text>().text = (((float)Mathf.Clamp(thisPlayer.moonsCollected,0,30)/ 30f)*100f).ToString("n1") + " %";

View File

@ -14,7 +14,6 @@ public class MatchMaker : MonoBehaviour
public TMP_Text timerTxt;
public Button btn_cancel;
float timer;
public string serverName;
void Start()
{
if(!DBmanager.LoggedIn){
@ -47,8 +46,6 @@ public class MatchMaker : MonoBehaviour
}
}
bool isServer =false;
IEnumerator FetchMatchmake(){
WWWForm form = new WWWForm();
@ -58,19 +55,31 @@ public class MatchMaker : MonoBehaviour
WWW req = new WWW(DBmanager.phpRoot+"matchmake.php", form);
yield return req;
Debug.Log(req.text);
if(req.text.Contains(DBmanager.username) && !loadedScene){
//Room created!
isServer= req.text.Substring(0,DBmanager.username.Length) == DBmanager.username;
serverName=req.text;
AutoConnect.serverName = serverName;
AutoConnect.isRankedServer = isServer;
// AutoConnect.isRanked = true;
Debug.Log($"Room created! [{req.text}] am I the server? : " + isServer);
// if(req.text.Contains(DBmanager.username) && !loadedScene){
// int port
// //Room created!
// // isServer= req.text.Substring(0,DBmanager.username.Length) == DBmanager.username;
// // serverName=req.text;
// // AutoConnect.serverName = serverName;
// // AutoConnect.isRankedServer = isServer;
// // AutoConnect.isRanked = true;
// Debug.Log($"Room created! [{req.text}] am I the server? : ");
LoadingScreen.instance.LoadLevel("MinigameRanked");
// LoadingScreen.instance.LoadLevel("MinigameRanked");
// }else{
// //Waiting
// }
try{
int port = int.Parse(req.text);
if(port > 5000){
Debug.Log("Got the port, Lets go!");
AutoConnect.serverPort = port;
LoadingScreen.instance.LoadLevel("MinigameRanked");
}
}catch{
}else{
//Waiting
}
}

View File

@ -11,7 +11,12 @@ public class MinigameManager : NetworkBehaviour
public static MinigameManager instance;
public bool isRanked;
public bool RankedGameStarted=false;
[SyncVar(hook =nameof(OnWinnerChanged))]
public int winnerId=-1;
[SyncVar]
public double startedTime = 0;
public GameObject waitingScreen;
public RankedGameSummary rankedSummary;
public float mapRadius;
public int maxMoons, maxStars = 100;
public Transform pickupItemsParent;
@ -38,7 +43,13 @@ public class MinigameManager : NetworkBehaviour
// if(!DBmanager.LoggedIn){SceneManager.LoadScene(0);} //Signed out, no game for u
if(isRanked){
RankedGameStarted= (FindObjectsOfType<SpaceshipController>().Length >=2);
// RankedGameStarted= (FindObjectsOfType<SpaceshipController>().Length >=2);
if(!RankedGameStarted && !isServer){
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
if(players.Length >= 2){
RankedGameStarted=true;
}
}
waitingScreen.SetActive(!RankedGameStarted);
}
@ -46,7 +57,51 @@ public class MinigameManager : NetworkBehaviour
HandlePickupSpawn();
KillOutOfBoundsPlayers();
if(isRanked){RankedMechanics();}
}
void RankedMechanics(){
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
if(players.Length < 2){
//Not enough players
}else{
if(!RankedGameStarted){
startedTime=NetworkTime.time;
}
RankedGameStarted=true;
if(players[0].moonsCollected >= 30){
//player 1 has won
winnerId = (int)players[0].netId;
// players[0].WonRanked();
// players[1].LostRanked();
}else if(players[1].moonsCollected >= 30){
//player 2 has won
winnerId = (int)players[1].netId;
// players[0].WonRanked();
// players[1].LostRanked();
}
}
if(RankedGameStarted && players.Length < 2){
//Forfeited!
winnerId = (int)players[0].netId;
// players[0].WonRanked();
}
}
void OnWinnerChanged(int oldVal, int newVal){
if(newVal<= 0){return;}
Debug.Log($"{newVal} id won!");
SpaceshipController localPlayer = SceneData.localPlayer.GetComponent<SpaceshipController>();
if(newVal == localPlayer.netId){
//We won
localPlayer.CmdWonRanked();
Debug.Log("Its Me!, I won!");
}else{
Debug.Log("Its not me, I lost!");
localPlayer.CmdLostRanked();
}
}
void KillOutOfBoundsPlayers()

View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class RankedGameSummary : MonoBehaviour
{
public TMP_Text txtGameOver;
public TMP_Text txtTrophies;
public void ShowWin(){
txtGameOver.text = "You Won!";
txtTrophies.text= "+30";
txtTrophies.color = Color.green;
}
public void ShowLoss(){
txtGameOver.text = "You Lost!";
txtTrophies.text= "-15";
txtTrophies.color = Color.red;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 812537ae82c3b8c56ada62732b76a181
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,6 +13,7 @@ public class SceneDataHolder : MonoBehaviour
public GameObject metalEarnings;
public TMP_Text survivalTimeTxt;
public TMP_Text mostTimeTxt;
public TMP_Text gameOverTxt;
public EventTrigger boostBtn;
public TMP_Text timerTxt;
void Awake()
@ -32,8 +33,12 @@ public class SceneDataHolder : MonoBehaviour
xpEarnings.SetActive(xpEarned > 0); metalEarnings.SetActive(metalEarned > 0);
xpEarnings.GetComponentInChildren<TMP_Text>().text = xpEarned.ToString();
metalEarnings.GetComponentInChildren<TMP_Text>().text = metalEarned.ToString();
survivalTimeTxt.text = SceneData.SecondsToText(survivalTime);
mostTimeTxt.text = SceneData.SecondsToText(DBmanager.MostTime);
if(!MinigameManager.instance.isRanked){
survivalTimeTxt.text = SceneData.SecondsToText(survivalTime);
mostTimeTxt.text = SceneData.SecondsToText(DBmanager.MostTime);
}else{
// MinigameManager.instance.rankedSummary.ShowLoss();
}
}
}

View File

@ -3,20 +3,21 @@ using UnityEngine;
using Mirror;
using System.Linq;
using UnityEngine.UI;
using System.Collections;
public class SpaceshipController : NetworkBehaviour
{
public SpriteRenderer playerImg;
public SkinsData skins;
[SyncVar(hook=nameof(OnSkinChanged))]
[SyncVar(hook = nameof(OnSkinChanged))]
public string skinName = null;
[SyncVar(hook=nameof(OnPnameChanged))]
[SyncVar(hook = nameof(OnPnameChanged))]
public string pname;
[SyncVar(hook=nameof(OnScoresChanged))]
[SyncVar(hook = nameof(OnScoresChanged))]
public int Scores;
[SyncVar(hook=nameof(OnKillsChanged))]
[SyncVar(hook = nameof(OnKillsChanged))]
public int Kills;
[SyncVar(hook=nameof(OnTrailTimeChanged))]
[SyncVar(hook = nameof(OnTrailTimeChanged))]
public float trailTime;
[SyncVar]
public int moonsCollected;
@ -25,8 +26,8 @@ public class SpaceshipController : NetworkBehaviour
public bool dead;
[SyncVar]
public float speed;
[SyncVar(hook=nameof(OnScaleChanged))]
public float scaleMultiplier=1;
[SyncVar(hook = nameof(OnScaleChanged))]
public float scaleMultiplier = 1;
public Text pnameTxt;
public Transform body;
public TrailMgr trailMgr;
@ -39,87 +40,108 @@ public class SpaceshipController : NetworkBehaviour
[Header("Client Prediction")]
public SortedDictionary<int, StatePayload> serverStateBuffer = new SortedDictionary<int, StatePayload>();
public Vector3 DetourError = new Vector3(0,0.2f,0);
public Vector3 DetourError = new Vector3(0, 0.2f, 0);
public Vector3 Detour = Vector3.zero;
public Quaternion RotationDetour = Quaternion.identity;
public float DetourCorrectionFactor = 0.5f;
public float timeDelayErrorFix = 1f;
public bool showDebugHUD = false;
public float distanceFromCenter= 0;
public float distanceFromCenter = 0;
[Command]
void CmdSetPname(string value){
void CmdSetPname(string value)
{
pname = value;
}
void OnPnameChanged(string oldName, string newName){
void OnPnameChanged(string oldName, string newName)
{
pnameTxt.text = newName;
}
[Command]
void CmdSetSkin(string newSkin){
void CmdSetSkin(string newSkin)
{
skinName = newSkin;
}
void OnSkinChanged(string oldSkin, string newSkin){
void OnSkinChanged(string oldSkin, string newSkin)
{
ChangeSkin(newSkin);
}
void ChangeSkin(string name){
Sprite newSprite = SkinManagerHelper.getSkinSprite(name,skins);
void ChangeSkin(string name)
{
Sprite newSprite = SkinManagerHelper.getSkinSprite(name, skins);
playerImg.sprite = newSprite;
}
void OnScoresChanged(int oldScores, int newScores){
Debug.Log($"Add scores { newScores - oldScores}, (total: {newScores})");
void OnScoresChanged(int oldScores, int newScores)
{
Debug.Log($"Add scores {newScores - oldScores}, (total: {newScores})");
}
void OnTrailTimeChanged(float oldValue, float newValue){
void OnTrailTimeChanged(float oldValue, float newValue)
{
trailMgr.trail.time = newValue;
}
void OnBoostDown(){
if(isLocalPlayer){
if(isServer){
boosting=true;
}else{
void OnBoostDown()
{
if (isLocalPlayer)
{
if (isServer)
{
boosting = true;
}
else
{
CmdSetBoosting(true);
}
}
}
void OnBoostUp(){
if(isLocalPlayer){
if(isServer){
boosting=false;
}else{
void OnBoostUp()
{
if (isLocalPlayer)
{
if (isServer)
{
boosting = false;
}
else
{
CmdSetBoosting(false);
}
}
}
void OnScaleChanged(float oldScale, float newScale){
if(isLocalPlayer){
SceneData.holder.boostBtn.gameObject.SetActive(newScale>1);
void OnScaleChanged(float oldScale, float newScale)
{
if (isLocalPlayer)
{
SceneData.holder.boostBtn.gameObject.SetActive(newScale > 1);
}
}
[Command]
void CmdSetBoosting(bool value){
boosting=value;
void CmdSetBoosting(bool value)
{
boosting = value;
}
[SyncVar]
double startedTime = 0;
void ResetStats(){
void ResetStats()
{
startedXp = DBmanager.Xp;
startedMetal = DBmanager.Metal;
}
void Start()
{
scaleMultiplier=1;
scaleMultiplier = 1;
if (isLocalPlayer)
{
ResetStats();
@ -130,17 +152,25 @@ public class SpaceshipController : NetworkBehaviour
SceneData.OnBoostDown.AddListener(OnBoostDown);
SceneData.OnBoostUp.AddListener(OnBoostUp);
//Set username
if(isServer){pname=myName;}else{
if (isServer) { pname = myName; }
else
{
CmdSetPname(myName);
}
//Set Skin
if(!DBmanager.SkinsPurchased.Contains(SkinShopManager.GetEquipedSkin())){
if (!DBmanager.SkinsPurchased.Contains(SkinShopManager.GetEquipedSkin()))
{
//False skin purchase
}else{
if(isServer){
}
else
{
if (isServer)
{
skinName = SkinShopManager.GetEquipedSkin();
}else{
}
else
{
CmdSetSkin(SkinShopManager.GetEquipedSkin());
}
}
@ -162,27 +192,29 @@ public class SpaceshipController : NetworkBehaviour
int lastClientUpdateTime = 0;
void FixedUpdate()
{
if(MinigameManager.instance.isRanked && !MinigameManager.instance.RankedGameStarted){return;}
if (MinigameManager.instance.isRanked && !MinigameManager.instance.RankedGameStarted) { return; }
distanceFromCenter = Vector3.Distance(transform.position, Vector3.zero);
pnameTxt.rectTransform.rotation = Quaternion.Euler(Vector3.zero);
//Update size of trail and spaceship
transform.localScale = Vector3.Lerp(transform.localScale,new Vector3(scaleMultiplier,scaleMultiplier,scaleMultiplier),0.1f);
trailMgr.trail.startWidth = Mathf.Lerp(trailMgr.trail.startWidth,scaleMultiplier,0.1f);
transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(scaleMultiplier, scaleMultiplier, scaleMultiplier), 0.1f);
trailMgr.trail.startWidth = Mathf.Lerp(trailMgr.trail.startWidth, scaleMultiplier, 0.1f);
if(dead){return;}
if (dead) { return; }
if (isLocalPlayer)
{
joyInput = joystick.input;
//Cheats => TODO: Remove this
if(Input.GetKeyDown(KeyCode.F)){
if (Input.GetKeyDown(KeyCode.F))
{
CmdCheatKills();
}
// Debug.Log(startedTime-NetworkTime.time);
double survivalTime = (startedTime ==0) ? 0 :NetworkTime.time - startedTime;
if(DBmanager.MostTime < (int)survivalTime){
double survivalTime = (startedTime == 0) ? 0 : NetworkTime.time - ((MinigameManager.instance.isRanked)? MinigameManager.instance.startedTime :startedTime);
if (DBmanager.MostTime < (int)survivalTime)
{
DBmanager.SetMostTime((int)survivalTime);
}
SceneData.SetTimerTxt(survivalTime);
@ -197,15 +229,19 @@ public class SpaceshipController : NetworkBehaviour
}
}
if(isServer){
if (isServer)
{
//boost check
if(boosting && scaleMultiplier > 1){
speed= movingSpeed*2;
scaleMultiplier-=Time.deltaTime;
if(scaleMultiplier<1){scaleMultiplier=1;} //Clamp in case gets lower
}else{
speed=movingSpeed;
if (boosting && scaleMultiplier > 1)
{
speed = movingSpeed * 2;
scaleMultiplier -= Time.deltaTime;
if (scaleMultiplier < 1) { scaleMultiplier = 1; } //Clamp in case gets lower
}
else
{
speed = movingSpeed;
}
}
///Diff = rot1 . rot2
@ -221,15 +257,16 @@ public class SpaceshipController : NetworkBehaviour
{
Vector3 newPosition = body.position + Detour;
Quaternion newRotation = body.rotation * RotationDetour;
if(Detour.magnitude > 0.5f){
trailMgr.trail.emitting =false;
if (Detour.magnitude > 0.5f)
{
trailMgr.trail.emitting = false;
}
body.position = Vector3.Lerp(body.position, newPosition, (Mathf.Abs(Detour.magnitude) > 0.2f) ? DetourCorrectionFactor * 2 * Detour.magnitude : DetourCorrectionFactor);
body.position = Vector3.Lerp(body.position, newPosition, (Mathf.Abs(Detour.magnitude) > 0.2f) ? DetourCorrectionFactor * 2 * Detour.magnitude : DetourCorrectionFactor);
Detour = newPosition - body.position;
body.rotation = Quaternion.Lerp(body.rotation, newRotation, DetourCorrectionFactor * ((joystick.touchDown) ? 0.1f : 1));
RotationDetour = Quaternion.Inverse(transform.rotation) * newRotation;
trailMgr.trail.emitting=true;
trailMgr.trail.emitting = true;
}
}
@ -258,7 +295,9 @@ public class SpaceshipController : NetworkBehaviour
}
RpcUpdatePosition(joyInput, transform.position, transform.rotation, timeInMillis);
RpcUpdateTrail(trailMgr.positions);
}else{
}
else
{
transform.position = Vector3.Lerp(transform.position, targetPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, 0.1f);
}
@ -266,7 +305,7 @@ public class SpaceshipController : NetworkBehaviour
Vector3 targetPosition;
Quaternion targetRotation;
void Turn(Vector2 input)
{
@ -298,7 +337,7 @@ public class SpaceshipController : NetworkBehaviour
payloadToCompare = lastServerState;
if (lastServerState.Time < time)
{
// Debug.Log("Server doesn't have that data yet\nYou asked for " + time + " best I can do is " + lastServerState.Time);
// Debug.Log("Server doesn't have that data yet\nYou asked for " + time + " best I can do is " + lastServerState.Time);
}
else
{
@ -327,7 +366,7 @@ public class SpaceshipController : NetworkBehaviour
}
else
{
// Debug.Log($"RB : {positionDiff.magnitude} [{timeDiff}ms]");
// Debug.Log($"RB : {positionDiff.magnitude} [{timeDiff}ms]");
RpcRubberBand(joyInput, serverStateBuffer.Values.Last().Position, serverStateBuffer.Values.Last().Rotation, trailMgr.positions, timeInMillis);
}
@ -336,21 +375,21 @@ public class SpaceshipController : NetworkBehaviour
[ClientRpc]
void RpcUpdatePosition(Vector2 input, Vector3 position, Quaternion rotation, double sentTime)
{
if(isLocalPlayer || isServer){return;}
if (isLocalPlayer || isServer) { return; }
double delay = (timeInMillis - sentTime) * timeDelayErrorFix;
int numberOfFrames = (int)((float)(delay/1000f) *50f);
int numberOfFrames = (int)((float)(delay / 1000f) * 50f);
Quaternion newRotation = rotation;
Vector3 direction = (rotation * Vector3.forward).normalized;
Vector3 newPosition = position + ((direction * speed) * numberOfFrames);
for (int i = 0; i < numberOfFrames; i++)
{
newRotation = Quaternion.Lerp(newRotation, getTurnAngle(input), turningSmoothFactor * input.magnitude);
}
targetPosition = newPosition - DetourError;
targetRotation = newRotation;
}
double lastRubberBandTime = 0;
@ -363,12 +402,12 @@ public class SpaceshipController : NetworkBehaviour
if (sentTime < lastRubberBandTime) { Debug.Log("Old rubber band rpc, ignoree..."); return; }
//Lag comprehension
double delay = (timeInMillis - sentTime) * timeDelayErrorFix;
int numberOfFrames = (int)((float)(delay/1000f) * 50f);
int numberOfFrames = (int)((float)(delay / 1000f) * 50f);
Quaternion newRotation = rotation;
Vector3 direction = (rotation * Vector3.forward).normalized;
Vector3 newPosition = position + ((direction * speed) * numberOfFrames);
for (int i = 0; i < numberOfFrames; i++)
{
newRotation = Quaternion.Lerp(newRotation, getTurnAngle(input), turningSmoothFactor * input.magnitude);
@ -402,12 +441,13 @@ public class SpaceshipController : NetworkBehaviour
RotationDetour = Quaternion.Inverse(transform.rotation) * newRotation;
lastRubberBandTime = sentTime;
// Debug.Log($"Rubber banded (Detour of pos:{Detour}, rotation: {RotationDetour}) you to {transform.position}, @ {sentTime} (delay: {delay}");
// Debug.Log($"Rubber banded (Detour of pos:{Detour}, rotation: {RotationDetour}) you to {transform.position}, @ {sentTime} (delay: {delay}");
}
}
[ClientRpc]
void RpcUpdateTrail(Vector3[] positions){
void RpcUpdateTrail(Vector3[] positions)
{
//trailMgr.trail.SetPositions(positions);
}
@ -438,15 +478,18 @@ public class SpaceshipController : NetworkBehaviour
{
body = transform;
}
if(trailMgr==null){
if (trailMgr == null)
{
trailMgr = GetComponent<TrailMgr>();
}
}
public void TrailCollided(Collider2D hit){
if(!isServer){
public void TrailCollided(Collider2D hit)
{
if (!isServer)
{
Debug.Log("Got hit : " + hit.name);
// Debug.Log("This cannot run on client, That's illegal!"); // <-- What this log says
return;
@ -454,55 +497,64 @@ public class SpaceshipController : NetworkBehaviour
SpaceshipController deadPlayer = hit.GetComponent<SpaceshipController>();
Debug.Log("got hit by player? : " + deadPlayer != null);
if(deadPlayer!=null && !deadPlayer.dead){ // <-- okay we killed someone | KILLCODE
if (deadPlayer != null && !deadPlayer.dead && (NetworkTime.time- deadPlayer.startedTime) > 5)
{ // <-- okay we killed someone | KILLCODE
deadPlayer.Die(pname);
Debug.Log($"{pname} killed {deadPlayer.pname}");
OnKill();
OnKill();
}
}
void OnKill(){
void OnKill()
{
Kills++;
Scores+= 10; //TODO: Need to change Scores on kills?
scaleMultiplier+=0.05f;
OnScaleChanged(scaleMultiplier,scaleMultiplier);
Scores += 10; //TODO: Need to change Scores on kills?
scaleMultiplier += 0.05f;
OnScaleChanged(scaleMultiplier, scaleMultiplier);
IncreaseTrail(trailIncrementRate);
RpcOnKill();
}
[ClientRpc]
void RpcOnKill(){
void RpcOnKill()
{
}
void OnKillsChanged(int oldVal, int newVal){
if(isLocalPlayer){
void OnKillsChanged(int oldVal, int newVal)
{
if (isLocalPlayer)
{
Debug.Log("Show kills for " + newVal);
KillText.Show(newVal);
}
}
void IncreaseTrail(float rate){
trailTime = trailMgr.trail.time+ rate;
void IncreaseTrail(float rate)
{
trailTime = trailMgr.trail.time + rate;
trailMgr.trail.time = trailTime;
Debug.Log("Increasing trail of" + pname);
}
[Command]
void CmdCheatKills(){
void CmdCheatKills()
{
OnKill();
}
public void CollectPickup(PickupItem.PickupType type){
if(!isServer){Debug.Log("Server function ran on client. That's illegal!");} // <-- What this log says
switch(type){
public void CollectPickup(PickupItem.PickupType type)
{
if (!isServer) { Debug.Log("Server function ran on client. That's illegal!"); } // <-- What this log says
switch (type)
{
case PickupItem.PickupType.Moon:
IncreaseTrail(trailIncrementRate);
moonsCollected++;
break;
case PickupItem.PickupType.Star:
IncreaseTrail(trailIncrementRate/2f);
IncreaseTrail(trailIncrementRate / 2f);
break;
}
@ -510,24 +562,27 @@ public class SpaceshipController : NetworkBehaviour
}
[ClientRpc]
void RpcCollectPickup(PickupItem.PickupType type){
if(isLocalPlayer){
MinigameManager.instance.GainMetals((type==PickupItem.PickupType.Star) ? 10 : 30);
void RpcCollectPickup(PickupItem.PickupType type)
{
if (isLocalPlayer)
{
MinigameManager.instance.GainMetals((type == PickupItem.PickupType.Star) ? 2 : 5);
}
}
public void Die(string killer){
public void Die(string killer)
{
MinigameManager.instance.SpawnLeftoverPickups(transform.position, Scores);
Debug.Log($"Sending death signal to {pname} by {killer}");
//Handle Respawning
OnScaleChanged(scaleMultiplier,1);
scaleMultiplier=1;
dead=true;
Scores=0;
Kills=0;
startedTime=NetworkTime.time;
OnScaleChanged(scaleMultiplier, 1);
scaleMultiplier = 1;
dead = true;
Scores = 0;
Kills = 0;
startedTime = NetworkTime.time;
trailTime = 1;
trailMgr.trail.time = trailTime;
RpcDie(killer);
@ -538,59 +593,153 @@ public class SpaceshipController : NetworkBehaviour
private int startedXp;
private int startedMetal;
bool RewardedRankedMetal =false;
[ClientRpc]
public void RpcDie(string killer){
public void RpcDie(string killer)
{
Debug.Log($"{killer} killed {pname} : isItMe? -> {isLocalPlayer}");
KillfeedMgr.instance.AddNewEntry($"<b>{pname}</b> was killed by <b>{killer}</b>");
gameObject.SetActive(false);
if(isLocalPlayer){
if (isLocalPlayer)
{
//TODO: Death message goes here
SceneData.holder.ShowDeadscreen(DBmanager.Xp - startedXp, DBmanager.Metal - startedMetal, NetworkTime.time - startedTime);
if (MinigameManager.instance.isRanked)
{
// MinigameManager.instance.rankedSummary.ShowLoss();
// StartCoroutine(ShowRankedResults());
if(MinigameManager.instance.winnerId<=0){
Debug.LogError("Winner ID not synced yet");
}
if (MinigameManager.instance.winnerId != netId)
{
//LOSER!
MinigameManager.instance.rankedSummary.ShowLoss();
}
else
{
MinigameManager.instance.rankedSummary.ShowWin();
}
}
}
}
public void Respawn(Vector3 respawnPoint){
IEnumerator ShowRankedResults()
{
while (MinigameManager.instance.winnerId <= 0)
{
yield return new WaitForFixedUpdate();
}
}
public void Respawn(Vector3 respawnPoint)
{
Debug.Log("Respawning " + pname);
if(isServer){
if (isServer)
{
respawn(respawnPoint);
}else{
}
else
{
CmdRespawn(respawnPoint);
}
}
[Command]
void CmdRespawn(Vector3 respawnPoint){
void CmdRespawn(Vector3 respawnPoint)
{
respawn(respawnPoint);
}
public void respawn(Vector3 respawnPoint){
dead=false;
trailMgr.trail.emitting =false;
public void respawn(Vector3 respawnPoint)
{
dead = false;
trailMgr.trail.emitting = false;
trailMgr.trail.Clear();
RpcRespawn(respawnPoint);
transform.position = respawnPoint;
trailMgr.trail.emitting=true;
trailMgr.trail.emitting = true;
gameObject.SetActive(true);
}
[ClientRpc]
public void RpcRespawn(Vector3 respawnPoint){
GetComponent<NetworkTrail>().enableValidation=false;
public void RpcRespawn(Vector3 respawnPoint)
{
GetComponent<NetworkTrail>().enableValidation = false;
trailMgr.trail.Clear();
trailMgr.positions = new Vector3[0];
trailMgr.trail.emitting = false;
transform.position = respawnPoint;
trailMgr.trail.emitting=true;
GetComponent<NetworkTrail>().enableValidation=true;
trailMgr.trail.emitting = true;
GetComponent<NetworkTrail>().enableValidation = true;
gameObject.SetActive(true);
if(isLocalPlayer){
if (isLocalPlayer)
{
SceneData.holder.deadScreen.SetActive(false);
ResetStats();
}
}
[Command]
public void CmdWonRanked(){
WonRanked();
}
[Command]
public void CmdLostRanked(){
LostRanked();
}
public void WonRanked()
{
if (!isServer)
{
return;
}
RpcWonRanked();
Die("server");
}
[ClientRpc]
void RpcWonRanked()
{
if (isLocalPlayer)
{
DBmanager.SetMetal(DBmanager.Metal+500);
MinigameManager.instance.rankedSummary.ShowWin();
//Add trophies
DBmanager.SetTrophies(DBmanager.Trophies + 30);
}
}
public void LostRanked()
{
if (!isServer)
{
return;
}
RpcLostRanked();
Die("server");
}
void RpcLostRanked()
{
if (isLocalPlayer)
{
DBmanager.SetMetal(DBmanager.Metal+250);
MinigameManager.instance.rankedSummary.ShowLoss();
DBmanager.SetTrophies(Mathf.Clamp(DBmanager.Trophies - 15, 0, int.MaxValue));
}
}
}

View File

@ -19,6 +19,11 @@ public class RegionManager : MonoBehaviour
UpdateSelectedRegion();
foreach(RegionServerData server in servers){
if(PlayerPrefs.HasKey("regionOverride")){
if(PlayerPrefs.GetString("regionOverride") == server.name){
selectedServer = server;
}
}
server.btn_select.onClick.AddListener(()=>{SetRegionOverride(server.name);});
}
btn_auto.onClick.AddListener(()=>{ SetRegionOverride(""); });

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f3f4943072bf1ac4d8c69666654fc1f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ChestButton : MonoBehaviour
{
public bool IsSpecial = false;
public bool readFromTexts;
public TMP_Text txtPrice;
public TMP_Text txtChestName;
public string ChestName => txtChestName.text;
public int Price;
public float minLuck = 0;
public float maxLuck = 100;
public Button btnInfo;
[TextArea]
public string infoTxt;
void Start()
{
btnInfo.onClick.AddListener(OnClickedInfo);
if(!IsSpecial)GetComponent<Button>().onClick.AddListener(OnClick);
}
void OnClickedInfo()
{
MessageDialog.instance.ShowDialog(ChestName, $"This chest will drop following items.\n\n{getItemsProbability()}");
}
void OnClick(){
if(DBmanager.Gems < Price){
MessageDialog.instance.ShowDialog("Failed","Insufficient Gems to complete the Purchase!");
return;
}
DBmanager.SetGems(DBmanager.Gems - Price);
ChestOpener.instance.OpenChest((int)minLuck, (int)maxLuck);
}
public string getItemsProbability()
{
string items = "Gold";
if (maxLuck > 50)
{
float probability = ((maxLuck - 50f) / (maxLuck - minLuck)) * 100f;
items += $"\nGems : {probability.ToString("n1")}%";
}
if (maxLuck > 70)
{
//some skins
float probability = ((maxLuck - 70f) / (maxLuck - minLuck)) * 100f;
items += $"\nCommon Skin : {probability.ToString("n1")}%";
}
if (maxLuck > 85)
{
float probability = ((maxLuck - 85f) / (maxLuck - minLuck)) * 100f;
items += $"\nRare Skin : {probability.ToString("n1")}%";
}
if (maxLuck > 95)
{
float probability = ((maxLuck - 95f) / (maxLuck - minLuck)) * 100f;
items += $"\nLegendary Skin : {probability.ToString("n1")}%";
}
return items;
}
void OnValidate()
{
infoTxt = getItemsProbability();
if (!readFromTexts) { return; }
if (txtPrice != null)
{
Price = int.Parse(txtPrice.text);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a00d06b92d7a4dd78fab8529a589430
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class GoldPackButton : MonoBehaviour
{
public bool autoReadFromText = true;
public TMP_Text txtAmount;
public TMP_Text txtPrice;
public int Amount;
public int Price;
void Start()
{
GetComponent<Button>().onClick.AddListener(()=>{GameManager.instance.BuyGold(this);});
}
// Update is called once per frame
void Update()
{
}
void OnValidate() {
if(!autoReadFromText){return;}
if(txtAmount!=null){
Amount = int.Parse(txtAmount.text.Replace(",",""));
}
if(txtPrice!=null){
Price = int.Parse(txtPrice.text.Replace(",",""));
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5cf2108220cbbf8449f5acdb4be74f69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,90 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class SpecialChest : MonoBehaviour
{
public int quantity=3;
public DateTime lastCollectedTime;
public ChestButton chestButton;
public TMP_Text txtTimeLeft;
public Button button;
void Start(){
button.onClick.AddListener(OnClicked);
StartCoroutine(LoadData());
}
DateTime specialChestExpire=DateTime.MinValue;
float t =30;
IEnumerator LoadData(){
WWW storeData = new WWW(DBmanager.phpRoot + "get_store_data.php");
yield return storeData;
Debug.Log(storeData.text + " => " + DBmanager.LastCollectedDailyChest);
specialChestExpire= DateTime.Parse(storeData.text);
}
void Update()
{
if(t < 30){
t +=Time.deltaTime;
}else{
t=0;
UpdateStat();
}
// if((DateTime.Now - DBmanager.LastCollectedDailyChest).TotalHours > 24){
// button.interactable = true;
// txtTimeLeft.text = "Ready";
// }else{
// button.interactable = false;
// // txtTimeLeft.text = SceneData.SecondsToText((DateTime.Now - DBmanager.LastCollectedDailyChest).Seconds);
// txtTimeLeft.text = MinutesToText((24*60)-(DateTime.Now - DBmanager.LastCollectedDailyChest).TotalMinutes);
// // Debug.Log(DateTime.Now + "-" + DBmanager.LastCollectedDailyChest + " = " + (DateTime.Now - DBmanager.LastCollectedDailyChest));
// }
}
public async void UpdateStat(){
if(specialChestExpire == DateTime.MinValue){ chestButton.gameObject.SetActive(false);}
DateTime nowTime = await DBmanager.GetNetworkTime();
if(specialChestExpire < nowTime){
chestButton.gameObject.SetActive(false);
}else if(DBmanager.LastCollectedDailyChest == specialChestExpire){
chestButton.gameObject.SetActive(false);
}else{
//Set the timer
chestButton.gameObject.SetActive(true);
txtTimeLeft.text = MinutesToText(specialChestExpire.Subtract(nowTime).TotalMinutes);
}
}
void OnClicked(){
// gameObject.SetActive(false);
if(DBmanager.Gems < chestButton.Price){
MessageDialog.instance.ShowDialog("Failed","Insufficient Gems to complete the Purchase!");
return;
}
DBmanager.SetGems(DBmanager.Gems - chestButton.Price);
DBmanager.SetLastCollectedDailyChest(specialChestExpire.ToString("yyyy-MM-dd HH:mm:ss"));
UpdateStat();
StartCoroutine(StartChestList());
}
IEnumerator StartChestList(){
for(int i=0; i< quantity; i++){
ChestOpener.instance.OpenChest((int)chestButton.minLuck, (int)chestButton.maxLuck);
while(ChestOpener.instance.active){
yield return new WaitForEndOfFrame();
}
}
}
public static string MinutesToText(double minutes){
int mins = ((int)(minutes % 60));
int hours = Mathf.FloorToInt((float)(minutes/60));
return hours + "h "+ mins.ToString("0") + "m";
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b15c5b3b610c912db8c1355f50b9f3d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -107,7 +107,7 @@ public class XpPass : MonoBehaviour
DBmanager.SetGems(DBmanager.Gems + reward.amount);
}else if(reward.rewardType == XpRewardType.Chest){
// StartCoroutine(destroyTimer(Instantiate(chestPrefab, chestSpawnParent),5));
ChestOpener.instance.OpenChest();
ChestOpener.instance.OpenChest(0,100);
}
break;

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

View File

@ -0,0 +1,120 @@
fileFormatVersion: 2
guid: 0d1a9d421a6c35f4391d8c82675a23a3
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

View File

@ -0,0 +1,120 @@
fileFormatVersion: 2
guid: 988d7450862c2fdfab23f6e1521b16f1
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -17,14 +17,14 @@ MonoBehaviour:
- level: 1
stats:
- name: Gold Per H
value: 100
value: 50
image: {fileID: 21300000, guid: ffe128a5f047f43d9a494e099634504e, type: 3}
price: 8500
xpGain: 2000
- level: 1
stats:
- name: Gold Per H
value: +50
value: +100
image: {fileID: 21300000, guid: ffe128a5f047f43d9a494e099634504e, type: 3}
price: 8500
xpGain: 2000
@ -39,6 +39,6 @@ MonoBehaviour:
collectable: 1
resourceType: 2
productinoRates:
- 100
- 50
- 150
- 300

View File

@ -19,25 +19,25 @@ MonoBehaviour:
skinType: 0
- name: Avg space enjoyer
image: {fileID: 5693378827328238, guid: 4de40472c684c464db6425c3f8b4cb86, type: 3}
price: 0
price: 5000
skinType: 0
- name: Rare Prince
image: {fileID: 638681777288463559, guid: d274292b8f4ba6c49a18bae11a1b9893, type: 3}
price: 150
price: 20000
skinType: 1
- name: Rare Viper
image: {fileID: -5759662267452513102, guid: d274292b8f4ba6c49a18bae11a1b9893, type: 3}
price: 200
price: 20000
skinType: 1
- name: Rare Gold
image: {fileID: 4684224760558976125, guid: d274292b8f4ba6c49a18bae11a1b9893, type: 3}
price: 300
price: 20000
skinType: 1
- name: Legendary Fish
image: {fileID: 4684224760558976125, guid: 2c885f2a72d92dd4e96779a685c53911, type: 3}
price: 500
price: 50000
skinType: 2
- name: Legendary Fish Toxic
image: {fileID: -891101006492794385, guid: 2c885f2a72d92dd4e96779a685c53911, type: 3}
price: 550
price: 50000
skinType: 2

View File

@ -11,16 +11,22 @@ EditorBuildSettings:
- enabled: 1
path: Assets/Game/Scenes/GameScene/GameScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
- enabled: 0
- enabled: 1
path: Assets/Game/Scenes/Minigame/NoLogin.unity
guid: eea869b23eb94de6c83d5bac8a04358a
- enabled: 1
path: Assets/Game/Scenes/Minigame/MinigameMenu.unity
guid: 24a7d750806c45aa1a9560044335a825
- enabled: 1
path: Assets/Game/Scenes/Minigame/MinigameMatchmaking.unity
guid: 59eddda8397341803b1134237eb697d7
- enabled: 1
path: Assets/Game/Scenes/Minigame/Minigame.unity
guid: 04c0f75906081f2cda037ccf580ff104
- enabled: 1
path: Assets/Game/Scenes/GameScene/Maintaince.unity
guid: 0d77b4960213a84b1877a979d4f5e03a
- enabled: 1
path: Assets/Game/Scenes/Minigame/MinigameRanked.unity
guid: a9d3dbf520f6a482b8a715db7a293e58
m_configObjects: {}

View File

@ -12,7 +12,7 @@ PlayerSettings:
targetDevice: 2
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: DefaultCompany
companyName: TWEP
productName: UPF
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.1
bundleVersion: 1
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
@ -153,7 +153,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.DefaultCompany.UPF
Android: com.TWEP.UPF
Standalone: com.DefaultCompany.UPF
buildNumber:
Standalone: 0
@ -247,15 +247,15 @@ PlayerSettings:
AndroidTargetDevices: 0
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidKeystoreName: /media/RocketSpeed/keys/twep.keystore
AndroidKeyaliasName: tul
AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0
AndroidIsGame: 1
AndroidEnableTango: 0
androidEnableBanner: 1
androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 0
androidUseCustomKeystore: 1
m_AndroidBanners:
- width: 320
height: 180

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More