version 1.3

This commit is contained in:
2023-01-02 00:08:18 +05:30
parent 8faf4476ed
commit af487ad62d
581 changed files with 145027 additions and 809 deletions

View File

@@ -97,6 +97,7 @@ public class AdsManager : MonoBehaviour
}
public async void ShowInterestitial(){
Debug.Log("Showing int ad");
interstitial.Show();
await Task.Delay(10000);
LoadInterestitial();

View File

@@ -3,6 +3,11 @@ using UnityEngine;
public class Building : MonoBehaviour
{
public override string ToString()
{
return "data: " + JsonUtility.ToJson(buildingData) + ", level:"+curLevel;
}
public BuildingData buildingData;
public int curLevel;
public int[] additionalLevels;

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using CustomLogger;
using Debug = CustomLogger.Debug;
public class ChangeUsername : MonoBehaviour
{
public GameObject panel;
public TMP_InputField newNameInput;
public Button changeBtn;
bool hasChanged = true;
void Awake(){
changeBtn.onClick.AddListener(OnChangeClicked);
}
public void Show(){
if(DBmanager.isGuest){
MessageDialog.instance.ShowMessage("Failed", "You can't change username with a guest account.\nLink your account to proceed");
return;
}
Refresh();
panel.SetActive(true);
}
public void Hide(){
panel.SetActive(false);
}
async void Refresh(){
Disable();
newNameInput.text = "";
hasChanged = await DBmanager.GetUsernameChanged();
if(hasChanged){
//Not free
changeBtn.transform.GetChild(1).GetComponentInChildren<TMP_Text>().text = "10";
}else{
changeBtn.transform.GetChild(1).GetComponentInChildren<TMP_Text>().text = "0";
MessageDialog.instance.ShowMessage("Notice", "You can change your username FREE for the first time.\nAfter that changing name Costs 10 Gems");
}
Enable();
}
async void OnChangeClicked(){
if(!changeBtn.interactable){
return;
}
if(newNameInput.text.Length < 3){
MessageDialog.instance.ShowMessage("Failed", "Username requires at-least 3 characters");
}
if(hasChanged){
if(DBmanager.Gems < 10){
MessageDialog.instance.ShowMessage("Failed", "Not enough gems to change name");
return;
}
}
string response = await DBmanager.ChangeName(newNameInput.text);
if(response.Contains("username already exists")){
MessageDialog.instance.ShowMessage("Failed", "Name you entered already exists, Please enter a different name");
}
if(response == "0"){
GameManager.Refresh();
if(hasChanged){
DBmanager.SetGems(DBmanager.Gems -10);
}
MessageDialog.instance.ShowMessage("Success","Username successfully changed!");
Hide();
}else{
Debug.Log("Couldn't change username:" + response);
MessageDialog.instance.ShowMessage("Failed", "Failed to change username");
Feedbacks.Send("Change username", response, "",Debug.loggedText);
}
}
void Disable(){
newNameInput.interactable = changeBtn.interactable = false;
}
void Enable(){
newNameInput.interactable = changeBtn.interactable = true;
}
}

View File

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

View File

@@ -54,10 +54,7 @@ public class GameManager : MonoBehaviour
}
else
{
foreach (TMP_Text usernameTxt in usernameTxts)
{
usernameTxt.text = DBmanager.displayName;
}
RefreshData();
}
@@ -90,6 +87,10 @@ public class GameManager : MonoBehaviour
private void RefreshData()
{
foreach (TMP_Text usernameTxt in usernameTxts)
{
usernameTxt.text = DBmanager.DisplayName;
}
foreach (TMP_Text txt in coinsTxt)
{
txt.text = DBmanager.Coins.ToString();
@@ -213,7 +214,7 @@ public class GameManager : MonoBehaviour
public void OnTwepsClicked(){
MessageDialog.instance.ShowMessage("Coming Soon!", "Soon to be introduced.");
MessageDialog.instance.ShowMessage("Coming Soon!", "To be introduced soon.");
}
public void OnBoughtIAPGems(int Amount){

View File

@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
public class MaintainceChecker : MonoBehaviour
{
public static int version = 44;
public static int version = 51;
public static MaintainceChecker instance;
public int checkInterval = 30;
float t;

View File

@@ -1,8 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
using UnityEngine.UI;
using Random = UnityEngine.Random;
public class SpaceshipNetworkBot : NetworkBehaviour
{
@@ -11,20 +14,53 @@ public class SpaceshipNetworkBot : NetworkBehaviour
public string pname;
public Text nameTxt;
public float movingSpeed;
public float minSpeed;
public float maxSpeed;
public Transform curTarget;
public TrailMgrBot trailMgr;
public GameObject DeathEffect;
public LayerMask pickupsLayer;
[SyncVar]
public int Scores = 0;
public float up;
[SyncVar(hook = nameof(OnSetupIndexChanged))]
public int SelectedSetupIndex;
void OnSetupIndexChanged(int old, int value){
GetComponent<SpriteRenderer>().sprite = botSetups[value].skins[SelectedSkinIndex];
}
[SyncVar(hook = nameof(OnSkinIndexChanged))]
public int SelectedSkinIndex;
void OnSkinIndexChanged(int old, int value){
GetComponent<SpriteRenderer>().sprite = botSetups[SelectedSetupIndex].skins[value];
}
public float up;
public BotSetup[] botSetups;
void OnPnameChanged(string oldName, string newName){
nameTxt.text = newName;
}
void Start()
{
public void InitRandomBot(){
pname = BotsHiveMind.LeaseName(pname.Length > 0 ? pname : null);
nameTxt.text = pname;
int luck = Random.Range(0,100);
BotSetup selectedSetup = botSetups[0];
for(int i=0; i < botSetups.Length; i++){
BotSetup setup = botSetups[i];
if(setup.rarity < luck && setup.rarity > selectedSetup.rarity){
selectedSetup = setup;
SelectedSetupIndex = i;
}
}
SelectedSkinIndex = Random.Range(0, selectedSetup.skins.Length);
GetComponent<SpriteRenderer>().sprite = selectedSetup.skins[SelectedSkinIndex];
movingSpeed = Random.Range(selectedSetup.minSpeed, selectedSetup.maxSpeed);
// movingSpeed = Random.Range(minSpeed, maxSpeed);
}
// Update is called once per frame
@@ -33,21 +69,9 @@ public class SpaceshipNetworkBot : NetworkBehaviour
if(!isServer){return;}
HandleMovement();
CheckForPickups();
ChangeName();
// ChangeName();
}
float nameChangeTimer = 1000;
float nameChangeTime = 0;
void ChangeName(){
nameChangeTimer+=Time.deltaTime;
if(nameChangeTimer > nameChangeTime){
nameChangeTimer = 0;
nameChangeTime = Random.Range(1000, 2000);
pname = BotsHiveMind.LeaseName(pname.Length > 0 ? pname : null);
nameTxt.text = pname;
}
}
void CheckForPickups(){
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, 3, pickupsLayer);
@@ -191,7 +215,8 @@ public class SpaceshipNetworkBot : NetworkBehaviour
int leftoverAmount = (int)((float)Scores/4f);
Debug.Log("Bot " + pname + " Left " + leftoverAmount + " Stars");
MinigameManager.instance.SpawnLeftoverPickups(transform.position, leftoverAmount);
MinigameManager.instance.DestroyBot(this);
return;
RpcDie(transform.position);
Scores = 0;
trailTime = 0;
@@ -242,6 +267,12 @@ public static class BotsHiveMind{
return chosenName;
}
public static void ReturnName(string name){
PooledNames.Add(name);
ActiveNames.Remove(name);
}
private static Dictionary<SpaceshipController, SpaceshipNetworkBot> leased = new Dictionary<SpaceshipController, SpaceshipNetworkBot>();
public static Dictionary<SpaceshipController, SpaceshipNetworkBot> Leased {
@@ -264,4 +295,22 @@ public static class BotsHiveMind{
leased.Add(player,bot);
return true;
}
public static void RetrunPlayer(SpaceshipController player){
if(leased.ContainsKey(player)){
leased.Remove(player);
}
Debug.Log("Trying to return a player to hive mind pool. But no one was borrowing them");
}
}
[Serializable]
public class BotSetup{
public float minSpeed;
public float maxSpeed;
public Sprite[] skins;
[Range(0,100)]
public int rarity;
}

View File

@@ -8,6 +8,7 @@ using System;
using Mirror;
using UnityEngine.SceneManagement;
using System.Threading.Tasks;
using Debug = CustomLogger.Debug;
public class MatchMaker : MonoBehaviour
{
@@ -85,41 +86,64 @@ public class MatchMaker : MonoBehaviour
void UpdatePlayerCount(){
playerCountTxt.text = $"EU: {euPlayers}\nSGP: {sgpPlayers}\nUSA: {usPlayers}";
}
int port =-1;
IEnumerator FetchMatchmake(){
#region old
// WWWForm form = new WWWForm();
// form.AddField("name", DBmanager.username);
// form.AddField("region", RegionManager.selectedServer.name);
// WWW req = new WWW(DBmanager.phpRoot+"matchmake.php", form);
// yield return req;
// Debug.Log(req.text);
WWWForm form = new WWWForm();
form.AddField("name", DBmanager.username);
form.AddField("region", RegionManager.selectedServer.name);
// 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{
WWW req = new WWW(DBmanager.phpRoot+"matchmake.php", form);
yield return req;
Debug.Log(req.text);
// 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");
// }else{
// //Waiting
// }
#endregion
try{
int port = int.Parse(req.text);
if(port > 5000){
WWW req = new WWW($"http://{RegionManager.selectedServer.ip}:1601/?password=xyz@123&&username=" + DBmanager.username);
yield return req;
Debug.Log("Matchmaker: "+req.text);
if(req.text.Contains("{")){
MatchmakerResponse response = JsonUtility.FromJson<MatchmakerResponse>(req.text);
// if()
if(port < 0){
confirmRoom(response);
}else if(port > 0){
Debug.Log("Got the port, Lets go!");
AutoConnect.serverPort = port;
AutoConnect.serverPort = response.Port;
LoadingScreen.instance.LoadLevel("MinigameRanked");
}
}catch{
Debug.Log(response.ToString());
port = -1;
}
}
}
MatchmakerResponse init_response;
int responseCounter =0;
void confirmRoom(MatchmakerResponse response){
if(responseCounter == 0){
init_response = response;
}
responseCounter++;
if(responseCounter > 5){
responseCounter=0;
if(response.Players.Length == 2){
//Confirm room
port = response.Port;
}else{
port = -1;
}
}
}
@@ -161,3 +185,21 @@ public class MatchMaker : MonoBehaviour
}
[Serializable]
public class MatchmakerResponse{
public MatchmakerPlayerEntry[] Players;
public int Port;
public long InitTime;
public override string ToString()
{
return JsonUtility.ToJson(this);
}
}
[Serializable]
public class MatchmakerPlayerEntry{
public string Name;
public long LastSeen;
}

View File

@@ -31,8 +31,12 @@ public class MinigameManager : NetworkBehaviour
float safeZoneShrinkSpeed;
[SerializeField] private PickupSetting[] PickupItems;
public PickupSetting[] pickupItems => PickupItems;
[Header("Bots")]
public GameObject botPrefab;
public int maxBots;
public List<SpaceshipNetworkBot> bots;
public GameObject DeathEffect;
// public GameObject starPrefab;
// public int maxMoons, maxStars = 100;
// public int maxTweps = 2;
@@ -113,23 +117,22 @@ public class MinigameManager : NetworkBehaviour
}
void Start(){
AudioManager.instnace.SetCustomMusic(musicClips[Random.Range(0,musicClips.Length)]);
if(!isServer){
Application.targetFrameRate = 60;
}else{
Debug.Log("Setting framerate to 35");
Application.targetFrameRate = 35;
}
if(isServer && !isRanked){
bots = new List<SpaceshipNetworkBot>();
for(int i =0; i < 5; i++){
GameObject newBot = Instantiate(botPrefab, getRandomPointInCirlce(Vector3.zero, 150), Quaternion.identity);
bots.Add(newBot.GetComponent<SpaceshipNetworkBot>());
newBot.GetComponent<SpaceshipNetworkBot>().pname = newBot.GetComponent<SpaceshipNetworkBot>().Names[i];
NetworkServer.Spawn(newBot);
for(int i =0; i < maxBots; i++){
SpawnBot();
}
}
AudioManager.instnace.SetCustomMusic(musicClips[Random.Range(0,musicClips.Length)]);
}
void Update()
@@ -140,7 +143,9 @@ public class MinigameManager : NetworkBehaviour
HandlePickupSpawn();
KillOutOfBoundsPlayers();
if(isRanked){RankedMechanics();}
if(isRanked){RankedMechanics();}else{
HandleBots();
}
}
public float timeElapsed => (float)(NetworkTime.time - startedTime);
bool shrinkStarted =false;
@@ -471,6 +476,44 @@ public class MinigameManager : NetworkBehaviour
public void UpdateMaterialValues(){
metalTxt.text = DBmanager.Metal.ToString();
}
void HandleBots(){
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
float m_maxBots = maxBots - players.Length;
if(bots.Count < m_maxBots){
SpawnBot();
}else if(bots.Count - m_maxBots > 0){
DestroyBot(bots[0]);
}
}
void SpawnBot(){
Debug.Log("Spawning bot");
GameObject newBot = Instantiate(botPrefab, getRandomPointInCirlce(Vector3.zero, 150), Quaternion.identity);
SpaceshipNetworkBot bot = newBot.GetComponent<SpaceshipNetworkBot>();
bots.Add(bot);
bot.pname = BotsHiveMind.LeaseName();
bot.InitRandomBot();
NetworkServer.Spawn(newBot);
}
public void DestroyBot(SpaceshipNetworkBot bot){
RpcShowDeathEffect(bot.transform.position);
NetworkServer.Destroy(bot.gameObject);
bots.Remove(bot);
BotsHiveMind.ReturnName(bot.pname);
if(bot.curTarget.GetComponent<SpaceshipController>() != null){
BotsHiveMind.RetrunPlayer(bot.curTarget.GetComponent<SpaceshipController>());
}
Debug.Log("Destroyed bot " + bot.pname + ". Left bots: " +bots.Count);
}
[ClientRpc]
void RpcShowDeathEffect(Vector3 position){
EffectPool.Spawn(DeathEffect, position);
}
}
[System.Serializable]

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using Mirror;
using CustomExtensions;
using System.Threading.Tasks;
public class PickupItem : NetworkBehaviour
{
@@ -102,7 +103,7 @@ public class PickupItem : NetworkBehaviour
transform.position = newPosition;
position= newPosition;
gameObject.SetActive(true);
Debug.LogWarning("Repositoning pickup");
// Debug.LogWarning("Repositoning pickup");
}
public void Deactivate(Transform playerPos){
@@ -123,17 +124,22 @@ public class PickupItem : NetworkBehaviour
NetworkServer.Destroy(gameObject);
}else{
StartCoroutine(MoveToPlayer(playerPos));
MoveToPlayer(playerPos);
}
}
IEnumerator MoveToPlayer(Transform position){
async void MoveToPlayer(Transform position){
float speed = 0.02f;
while(Vector3.Distance(position.position, transform.position) > 1f){
transform.position = Vector3.Lerp(transform.position, position.position, speed);
speed+= 0.02f;
yield return new WaitForSeconds(0.01f);
try{
while(transform != null && Vector3.Distance(position.position, transform.position) > 1f){
transform.position = Vector3.Lerp(transform.position, position.position, speed);
speed+= 0.02f;
// yield return new WaitForSeconds(0.01f);
await Task.Delay(10);
}
}catch{
Debug.Log("Target lost");
}
if(!isServer){
ParticleSystem particle = EffectPool.Spawn(PickupEffect, transform.position).GetComponent<ParticleSystem>();

View File

@@ -8,7 +8,7 @@ public class RankedSplash : MonoBehaviour
public int playerCountRequired;
public TMP_Text statusTxt;
public GameObject controlsUI;
public float startTimer = 120;
public float startTimer = 60;
void Start()
{
@@ -28,23 +28,26 @@ public class RankedSplash : MonoBehaviour
if(gameObject.activeSelf){
if(startTimer > 0){
startTimer-= Time.deltaTime;
if(startTimer <= 45 && players.Length == 0){
if(startTimer <= 10 && players.Length == 0){
MessageDialog.instance.ShowMessage("Error", "Connection to the server timed out");
LoadingScreen.instance.LoadLevel("GameScene");
startTimer = -100;
Feedbacks.Send("Ranked Didn't start", "Couldn't Connect to server", $"Ip:{RegionManager.selectedServer.ip}, Port:{AutoConnect.serverPort}", CustomLogger.Debug.loggedText);
}
if(startTimer <= 45 && players.Length == 1){
if(startTimer <= 10 && players.Length == 1){
Debug.Log("Timed out");
MinigameManager.instance.EnemyForfeit();
players[0].WonRanked();
startTimer = -100;
Feedbacks.Send("Ranked Didn't start", "Opponent didnt connect", $"Ip:{RegionManager.selectedServer.ip}, Port:{AutoConnect.serverPort}", CustomLogger.Debug.loggedText);
}
}else{
if(SceneData.localPlayer.GetComponent<SpaceshipController>().ready){
MinigameManager.instance.EnemyForfeit();
SceneData.localPlayer.GetComponent<SpaceshipController>().WonRanked();
Feedbacks.Send("Ranked Didn't start", "Opponent didnt connect, I was ready", $"Ip:{RegionManager.selectedServer.ip}, Port:{AutoConnect.serverPort}", CustomLogger.Debug.loggedText);
}
gameObject.SetActive(false);
}

View File

@@ -127,13 +127,14 @@ public class RocketUpgradePanel : MonoBehaviour
}
void OnUpgradeSpeed(){
bool Affordable = DBmanager.Coins >= nextSpeedStats.goldCost && DBmanager.Metal >= nextSpeedStats.metalCost;
bool Affordable = DBmanager.Coins >= nextRocketLevel.goldCost && DBmanager.Metal >= nextRocketLevel.metalCost;
if(!Affordable){
MessageDialog.instance.ShowMessage("Error","Not enough resources to upgrade.");
return;
}
Debug.Log("Upgrade cost: " + nextRocketLevel.goldCost + "golds " + nextRocketLevel.metalCost + "m");
DBmanager.UpgradeRocketSpeed(selectedRocket, nextSpeedStats);
DBmanager.UpgradeRocketSpeed(selectedRocket, nextRocketLevel);
SkinShopManager.instance.Populate();
// MessageDialog.instance.ShowMessage("Success","Rocket Upgraded Successfully!");
AudioManager.instnace.UpgradeRocket();
@@ -148,13 +149,14 @@ public class RocketUpgradePanel : MonoBehaviour
}
void OnUpgradeBoost(){
bool Affordable = DBmanager.Coins >= nextBoostStats.goldCost && DBmanager.Metal >= nextBoostStats.metalCost;
bool Affordable = DBmanager.Coins >= nextRocketLevel.goldCost && DBmanager.Metal >= nextRocketLevel.metalCost;
if(!Affordable){
MessageDialog.instance.ShowMessage("Error","Not enough resources to upgrade.");
return;
}
Debug.Log("Upgrade cost: " + nextRocketLevel.goldCost + "golds " + nextRocketLevel.metalCost + "m");
DBmanager.UpgradeRocketBoost(selectedRocket, nextBoostStats);
DBmanager.UpgradeRocketBoost(selectedRocket, nextRocketLevel);
SkinShopManager.instance.Populate();
// MessageDialog.instance.ShowMessage("Success","Rocket Upgraded Successfully!");
AudioManager.instnace.UpgradeRocket();
@@ -171,13 +173,14 @@ public class RocketUpgradePanel : MonoBehaviour
}
void OnUpgradeEnergy(){
bool Affordable = DBmanager.Coins >= nextEnergyStats.goldCost && DBmanager.Metal >= nextEnergyStats.metalCost;
bool Affordable = DBmanager.Coins >= nextRocketLevel.goldCost && DBmanager.Metal >= nextRocketLevel.metalCost;
if(!Affordable){
MessageDialog.instance.ShowMessage("Error","Not enough resources to upgrade.");
return;
}
Debug.Log("Upgrade cost: " + nextRocketLevel.goldCost + "golds " + nextRocketLevel.metalCost + "m");
DBmanager.UpgradeRocketEnergy(selectedRocket, nextEnergyStats);
DBmanager.UpgradeRocketEnergy(selectedRocket, nextRocketLevel);
SkinShopManager.instance.Populate();
// MessageDialog.instance.ShowMessage("Success","Rocket Upgraded Successfully!");
AudioManager.instnace.UpgradeRocket();

View File

@@ -5,6 +5,8 @@ using System.Linq;
using UnityEngine.UI;
using System.Collections;
using CustomExtensions;
using Debug = CustomLogger.Debug;
public class SpaceshipController : NetworkBehaviour
{
public LayerMask pickupsLayer;
@@ -58,6 +60,7 @@ public class SpaceshipController : NetworkBehaviour
private float minTimeBetweenTicks;
private const float SERVER_TICK_RATE = 30f;
private const int BUFFER_SIZE = 2048;
private const bool CUSTOM_NET_TRANSFORM = false;
private float ERROR_THRESHOLD =0.25f;
private int MIN_ERROR_COUNT = 10;
public bool showDebugHUD = false;
@@ -256,7 +259,7 @@ public class SpaceshipController : NetworkBehaviour
}
if (joystick == null) { joystick = FindObjectOfType<Joystick>(); }
FindObjectOfType<CameraFollower>().SetTarget(transform);
string myName = DBmanager.displayName;
string myName = DBmanager.DisplayName;
SceneData.localPlayer = gameObject;
SceneData.OnBoostDown.AddListener(OnBoostDown);
SceneData.OnBoostUp.AddListener(OnBoostUp);
@@ -359,20 +362,33 @@ public class SpaceshipController : NetworkBehaviour
}
SceneData.SetTimerTxt(survivalTime);
body.position = Vector3.Lerp(body.position,targetState.Position,MovementSmoothnessFactor * movingSpeed * Vector2.Distance(targetState.Position, body.position));
body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
if(CUSTOM_NET_TRANSFORM){
body.position = Vector3.Lerp(body.position,targetState.Position,MovementSmoothnessFactor * movingSpeed * Vector2.Distance(targetState.Position, body.position));
body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
}
// Debug.Log(lastTime - currentTick);
lastTime = targetState.Tick;
CameraFollower.UpdateFrame();
if(CUSTOM_NET_TRANSFORM){
CameraFollower.UpdateFrame();
}
}
timer += Time.deltaTime;
// return;
}
while(timer >= minTimeBetweenTicks){
timer -= minTimeBetweenTicks;
HandleTick();
currentTick++;
}
void FixedUpdate(){
// timer += Time.deltaTime;
// while(timer >= minTimeBetweenTicks){
// timer -= minTimeBetweenTicks;
// HandleTick();
// currentTick++;
// }
if (MinigameManager.instance.isRanked && !MinigameManager.instance.RankedGameStarted) { return; }
HandleTick();
currentTick++;
}
Vector3 serverPosition => serverStateBuffer[bufferIndex].Position;
Vector3 clientPosition => clientStateBuffer[bufferIndex].Position;
@@ -414,7 +430,9 @@ public class SpaceshipController : NetworkBehaviour
// body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
}else if (isServer){
HandleInput(m_Input);
// RpcUpdateOnClient(body.position, body.rotation, m_Input);
if(CUSTOM_NET_TRANSFORM){
RpcUpdateOnClient(body.position, body.rotation, m_Input);
}
CheckForPickups();
}else{
@@ -517,6 +535,7 @@ public class SpaceshipController : NetworkBehaviour
[ClientRpc]
void RpcRubberband(Vector3 m_position, Quaternion m_rotation){
return;
if(!CUSTOM_NET_TRANSFORM){return;}
PlayerState serverState = new PlayerState(){Tick=0, Position = m_position, Rotation = m_rotation};
PlayerState clientState = new PlayerState(){Tick=0, Position = transform.position, Rotation = transform.rotation};
float diff = serverState.Difference(clientState);
@@ -615,7 +634,7 @@ public class SpaceshipController : NetworkBehaviour
}
SpaceshipController deadPlayer = hit.GetComponent<SpaceshipController>();
Debug.Log("got hit by player? : " + (deadPlayer != null));
// Debug.Log("got hit by player? : " + (deadPlayer != null));
if (deadPlayer != null && !deadPlayer.dead && (NetworkTime.time - deadPlayer.startedTime) > 5)
{ // <-- okay we killed someone | KILLCODE
// deadPlayer.RpcShowDeathEffect(deadPlayer.transform.position);
@@ -627,11 +646,11 @@ public class SpaceshipController : NetworkBehaviour
}
SpaceshipNetworkBot deadBot = hit.GetComponent<SpaceshipNetworkBot>();
Debug.Log("got hit by bot? : " + (deadPlayer != deadBot));
// Debug.Log("got hit by bot? : " + (deadPlayer != deadBot));
if(deadBot != null){
deadBot.Die();
Kills++;
return;
}
}

View File

@@ -1,9 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Debug = CustomLogger.Debug;
public class NewLoginManager : MonoBehaviour
{
@@ -20,6 +22,8 @@ public class NewLoginManager : MonoBehaviour
void Start()
{
// Feedbacks.Send("Test", "test", "test", CustomLogger.Debug.loggedText);
statusTxt.text = "Checking credentials";
btn_login.onClick.AddListener(OnRegisterButton);
loadingPanel.SetActive(true);
@@ -80,11 +84,13 @@ public class NewLoginManager : MonoBehaviour
PlayerPrefs.Save();
Login();
}catch{
}catch (Exception e){
statusTxt.text = "Failed";
MessageDialog.instance.ShowMessage("Failed!", "Failed to register you into the game.\nReason: " + id);
newUsernamePanel.SetActive(true);
usernameInput.text = "";
Feedbacks.Send("Register Failed", e.Message, e.StackTrace, CustomLogger.Debug.loggedText);
}
}
@@ -130,6 +136,8 @@ public class NewLoginManager : MonoBehaviour
MessageDialog.instance.ShowQuestion("Error",
"Failed to log you in using saved credentials.\nDo you want to open game with guest account?",OnYes:Register, OnNo:OnLoginFailed);
Feedbacks.Send("Login Failed", $"Bad credentials, username:{savedUsername}, password:{savedPassword}, isGoogle:{googleSigned}", www.text, CustomLogger.Debug.loggedText);
}
}

View File

@@ -98,4 +98,10 @@ public class RegionServerData{
public int ping;
public TMPro.TMP_Text[] pingTxts;
public Button btn_select;
public override string ToString()
{
return JsonUtility.ToJson(this);
}
}

View File

@@ -8,6 +8,8 @@ using UnityEngine.Events;
using UnityEngine.Networking;
using System.Net;
using System.Net.Sockets;
using Debug = CustomLogger.Debug;
public class DBmanager : MonoBehaviour
{
static RankLevel[] rankLevels;
@@ -15,13 +17,15 @@ public class DBmanager : MonoBehaviour
public static string phpRoot = "vmi1005083.contaboserver.net/upf/";
public static string username = null;
public static string displayName {get {
if(username.Contains("#0")){
return PlayerPrefs.GetString("displayname");
}else{
return username;
}
}}
private static string displayName;
public static string DisplayName=>displayName;
// public static string displayName {get {
// if(username.Contains("#0")){
// return PlayerPrefs.GetString("displayname");
// }else{
// return username;
// }
// }}
public static int userid=0;
@@ -98,6 +102,7 @@ public class DBmanager : MonoBehaviour
try{
UserData userData = JsonUtility.FromJson<UserData>(jsonData);
username = userData.username;
displayName = userData.displayName;
userid = userData.id;
DBmanager.SetLastCollectedDailyChest(userData.last_collected_daily_chest ,true);
@@ -147,7 +152,7 @@ public class DBmanager : MonoBehaviour
}
Debug.Log("Bridge : " + www.downloadHandler.text);
// Debug.Log("Bridge : " + www.downloadHandler.text);
}
await Task.Delay(20000);
@@ -173,6 +178,48 @@ public class DBmanager : MonoBehaviour
return www.downloadHandler.text;
}
}
public static async Task<string> ChangeName(string newUsername){
WWWForm form = new WWWForm();
form.AddField("id", userid);
form.AddField("username", newUsername);
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "change_name.php", form))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
if(www.downloadHandler.text == "0"){
displayName = newUsername;
GameManager.Refresh();
}
return www.downloadHandler.text;
}
}
public static async Task<bool> GetUsernameChanged(){
WWWForm form = new WWWForm();
form.AddField("username", username);
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "get_username_changed.php", form))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
return www.downloadHandler.text != "0";
}
}
public static void LogOut()
{
@@ -768,7 +815,7 @@ public class DBmanager : MonoBehaviour
SetCoins(coins-nextLevel.goldCost);
SetMetal(metal - nextLevel.metalCost);
skinsPurchased[GetSkinIdByName(rocketName)].speedLevel = nextLevel.Level;
skinsPurchased[GetSkinIdByName(rocketName)].speedLevel++;
UpdatePurchasedSkins();
}
@@ -1174,6 +1221,7 @@ public class DBmanager : MonoBehaviour
public class UserData{
public int id;
public string username;
public string displayName;
public int coins;
public int gems;
public int tweps;

View File

@@ -0,0 +1,34 @@
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Networking;
public static class Feedbacks{
public static async void Send(string title, string message, string stackTrace="", string additionalData=""){
WWWForm form = new WWWForm();
form.AddField("username", DBmanager.username ?? "dev");
form.AddField("userid", DBmanager.userid);
form.AddField("title", title);
form.AddField("message",message);
form.AddField("stackTrace",stackTrace);
form.AddField("additionalData", additionalData);
string server_connection = "";
if(RegionManager.instance != null){
foreach(RegionServerData server in RegionManager.instance.servers){
server_connection += server.ToString() + "\n";
}
}
form.AddField("server_connection", server_connection);
using (UnityWebRequest www = UnityWebRequest.Post(DBmanager.phpRoot + "add_feedback.php", form))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
Debug.Log("Feedback sent : " + www.downloadHandler.text);
}
}
}

View File

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

View File

@@ -0,0 +1,29 @@
using System;
using UnityEngine;
namespace CustomLogger{
public static class Debug{
public static string loggedText{get; private set;}
public static void Log(object msg){
string output = $"[{DateTime.Now}] {msg}";
loggedText+=output+"\n";
UnityEngine.Debug.Log(output);
}
public static void LogError(object msg){
string output = $"* [{DateTime.Now}] {msg}";
loggedText+=output+"\n";
UnityEngine.Debug.LogError(output);
}
public static void LogWarning(object msg){
string output = $"![{DateTime.Now}] {msg}";
loggedText+=output+"\n";
UnityEngine.Debug.LogWarning(output);
}
}
}

View File

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

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using Debug = CustomLogger.Debug;
public class TradingPost : MonoBehaviour
{
public Building building;
@@ -21,8 +23,22 @@ public class TradingPost : MonoBehaviour
}
public void Show(){
string stackTrace="";
foreach(Building building in BuildingManager.instance.buildings){
stackTrace += building.ToString() +"\n";
}
checkTradePostBug(stackTrace);
gameObject.SetActive(true);
Refresh();
}
async void checkTradePostBug(string stackTrace){
await System.Threading.Tasks.Task.Delay(2000);
if(goldCount < 5){
Feedbacks.Send("Trading Post bug", $"gpm:{goldPerMetal}, metal:{metalCount}, goldCount:{goldCount}",stackTrace:stackTrace,additionalData:CustomLogger.Debug.loggedText);
}
}
public void Hide(){
@@ -78,6 +94,7 @@ public class TradingPost : MonoBehaviour
txtMetalAmount.text = metalCount.ToString();
txtGoldAmount.text = (goldCount).ToString();
Debug.Log(building.curLevel);
return 0;