Base game sfx done
This commit is contained in:
53
Assets/Game/Scripts/AudioManager.cs
Normal file
53
Assets/Game/Scripts/AudioManager.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
public static AudioManager instnace;
|
||||
[SerializeField]private AudioClip UI_click;
|
||||
[SerializeField]private AudioClip UI_popup;
|
||||
[SerializeField]private AudioClip collectGold;
|
||||
[SerializeField]private AudioClip spend;
|
||||
[SerializeField]private AudioClip chestOpenRiser;
|
||||
[SerializeField]private AudioClip chestOpen;
|
||||
[SerializeField]private AudioClip upgrade;
|
||||
[SerializeField]private AudioClip reward;
|
||||
|
||||
|
||||
AudioSource audioSrc;
|
||||
void Start()
|
||||
{
|
||||
audioSrc = GetComponent<AudioSource>();
|
||||
instnace=this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
public void UIClick(){
|
||||
audioSrc.PlayOneShot(UI_click);
|
||||
}
|
||||
public void UIPopup(){
|
||||
audioSrc.PlayOneShot(UI_popup);
|
||||
}
|
||||
|
||||
public void CollectGold(){
|
||||
audioSrc.PlayOneShot(collectGold);
|
||||
}
|
||||
public void Spend(){
|
||||
audioSrc.PlayOneShot(spend);
|
||||
}
|
||||
public void ChestOpenRiser(){
|
||||
audioSrc.PlayOneShot(chestOpenRiser);
|
||||
}
|
||||
public void ChestOpen(){
|
||||
audioSrc.PlayOneShot(chestOpen);
|
||||
}
|
||||
|
||||
public void UpgradeBuilding(){
|
||||
audioSrc.PlayOneShot(upgrade);
|
||||
}
|
||||
public void Reward(){
|
||||
audioSrc.PlayOneShot(reward);
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/AudioManager.cs.meta
Normal file
11
Assets/Game/Scripts/AudioManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8382ce8b50f25833285c48946db6ff76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Game/Scripts/AudioManagerHelper.cs
Normal file
20
Assets/Game/Scripts/AudioManagerHelper.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManagerHelper : MonoBehaviour
|
||||
{
|
||||
public void PlayChestOpenRiser(){
|
||||
AudioManager.instnace.ChestOpenRiser();
|
||||
}
|
||||
public void PlayChestOpen(){
|
||||
AudioManager.instnace.ChestOpen();
|
||||
}
|
||||
|
||||
public void PlayUIClick(){
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
public void PlayUIPopup(){
|
||||
AudioManager.instnace.UIPopup();
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/AudioManagerHelper.cs.meta
Normal file
11
Assets/Game/Scripts/AudioManagerHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e910d9b1103808af1bac9e24b352024f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -52,6 +52,7 @@ public class Building : MonoBehaviour
|
||||
|
||||
public void Upgrade(){
|
||||
if(curLevel >= buildingData.levels.Count-1){Debug.Log("Already max");return;}
|
||||
|
||||
int cost = buildingData.levels[curLevel+1].price;
|
||||
Debug.Log("Upgrading " + buildingData.buildingName + " for " + cost + " coins");
|
||||
|
||||
@@ -67,6 +68,8 @@ public class Building : MonoBehaviour
|
||||
|
||||
DBmanager.UpgradeBuilding(buildingData.buildingName, curLevel);
|
||||
DBmanager.SetXp(DBmanager.Xp + buildingData.levels[curLevel].xpGain);
|
||||
|
||||
AudioManager.instnace.UpgradeBuilding();
|
||||
}
|
||||
//
|
||||
// public List<Collider> buildingsInsideMe = new List<Collider>();
|
||||
|
||||
@@ -44,6 +44,7 @@ public class CollectBtn : MonoBehaviour
|
||||
|
||||
case CollectablesData.ResourceType.Gold:
|
||||
DBmanager.SetCoins(DBmanager.Coins + (int)collectableAmount);
|
||||
AudioManager.instnace.CollectGold();
|
||||
break;
|
||||
|
||||
// case CollectablesData.ResourceType.Oxygen:
|
||||
|
||||
@@ -545,6 +545,7 @@ public class DBmanager : MonoBehaviour
|
||||
}
|
||||
SetMetal(metal-data.price);
|
||||
AddSkin(data);
|
||||
AudioManager.instnace.Spend();
|
||||
}
|
||||
|
||||
public static void AddSkin(SkinShopItemData data){
|
||||
|
||||
@@ -6,6 +6,7 @@ using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.Monetization;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
@@ -157,8 +158,16 @@ public class GameManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
AudioManager.instnace.Spend();
|
||||
DBmanager.SetGems(DBmanager.Gems-button.Price);
|
||||
DBmanager.SetCoins(DBmanager.Coins + button.Amount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void OnBoughtIAPGems(int Amount){
|
||||
DBmanager.SetGems(DBmanager.Gems + Amount);
|
||||
AudioManager.instnace.Spend();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ public class GlobalLeaderboard : MonoBehaviour
|
||||
public Transform leaderboardItemsParent;
|
||||
public LeaderboardItem template;
|
||||
public async void Show(){
|
||||
AudioManager.instnace.UIPopup();
|
||||
List<LeaderboardUserData> leaderboard = await DBmanager.GetLeaderboard();
|
||||
template.gameObject.SetActive(true);
|
||||
//Clear currentItems
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -5,6 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
public class MaintainceChecker : MonoBehaviour
|
||||
{
|
||||
public static int version = 1;
|
||||
public static MaintainceChecker instance;
|
||||
public int checkInterval = 10;
|
||||
float t;
|
||||
@@ -21,7 +23,6 @@ public class MaintainceChecker : MonoBehaviour
|
||||
t+= Time.deltaTime;
|
||||
}else{
|
||||
t=0;
|
||||
|
||||
CheckMaintainceStatus();
|
||||
}
|
||||
}
|
||||
@@ -33,12 +34,35 @@ public class MaintainceChecker : MonoBehaviour
|
||||
IEnumerator checkMaintaince(){
|
||||
WWW req = new WWW(DBmanager.phpRoot+"get_server_status.php");
|
||||
yield return req;
|
||||
Debug.Log(req.text);
|
||||
|
||||
if(req.text != "200"){
|
||||
Debug.LogError("Servers are not ready. Gotta wait");
|
||||
try{
|
||||
// ServerStatus status = JsonUtility.FromJson<ServerStatus>(req.text);
|
||||
String[] split = {"<td>"};
|
||||
String[] data = req.text.Split(split, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach(String item in data){
|
||||
String[] _item = item.Split(',');
|
||||
if(_item[0]=="maintaince"){
|
||||
if(_item[1] == "1"){
|
||||
//Maintaince mode
|
||||
LoadingScreen.instance.LoadLevel("Maintaince");
|
||||
}
|
||||
}
|
||||
|
||||
if(_item[0]=="version"){
|
||||
if(int.Parse(_item[1]) != version){
|
||||
LoadingScreen.instance.LoadLevel("Update");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception e){
|
||||
Debug.Log("Error while reading server status, Going maintaince mode");
|
||||
Debug.LogError(e.Message);
|
||||
LoadingScreen.instance.LoadLevel("Maintaince");
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ public class MessageDialog : MonoBehaviour
|
||||
if(showing){
|
||||
SetActive(false);
|
||||
}
|
||||
AudioManager.instnace.UIClick();
|
||||
|
||||
}
|
||||
|
||||
public void ShowMessage(string title, string message){
|
||||
@@ -44,31 +46,36 @@ public class MessageDialog : MonoBehaviour
|
||||
okayBtn.gameObject.SetActive(true);
|
||||
SetActive(true);
|
||||
Refresh();
|
||||
AudioManager.instnace.UIPopup();
|
||||
|
||||
// messageTxt.gameObject.SetActive(true);
|
||||
}
|
||||
UnityAction onYes = ()=>{};
|
||||
UnityAction onNo = ()=>{};
|
||||
|
||||
public void ShowQuestion(string title, string message, UnityAction OnYes, UnityAction OnNo){
|
||||
public void ShowQuestion(string title, string message, UnityAction OnYes, UnityAction OnNo, bool onlyYes = false){
|
||||
titleTxt.text = title;
|
||||
messageTxt.text = message;
|
||||
onYes = OnYes;
|
||||
onNo = OnNo;
|
||||
|
||||
yesBtn.gameObject.SetActive(true);
|
||||
noBtn.gameObject.SetActive(true);
|
||||
|
||||
noBtn.gameObject.SetActive(!onlyYes);
|
||||
okayBtn.gameObject.SetActive(false);
|
||||
SetActive(true);
|
||||
Refresh();
|
||||
AudioManager.instnace.UIPopup();
|
||||
}
|
||||
void OnClickedYes(){
|
||||
if(onYes!=null){onYes();}
|
||||
OnOkay();
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
void OnClickedNo(){
|
||||
if(onNo!=null){onNo();}
|
||||
OnOkay();
|
||||
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
public void SetActive(bool value){
|
||||
GetComponent<CanvasGroup>().blocksRaycasts= value;
|
||||
|
||||
@@ -3,14 +3,20 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using LightReflectiveMirror;
|
||||
using UnityEngine.SceneManagement;
|
||||
public class AutoConnect : MonoBehaviour
|
||||
{
|
||||
public static AutoConnect instance;
|
||||
public bool isClient;
|
||||
public static int serverPort;
|
||||
public bool isRanked;
|
||||
public kcp2k.KcpTransport transport;
|
||||
void Start()
|
||||
{
|
||||
instance = this;
|
||||
if(isClient && !DBmanager.LoggedIn){
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
if (isRanked)
|
||||
{
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ public class MinigameManager : NetworkBehaviour
|
||||
{
|
||||
public static MinigameManager instance;
|
||||
public bool isRanked;
|
||||
[SyncVar]
|
||||
public bool RankedGameStarted=false;
|
||||
[SyncVar(hook =nameof(OnWinnerChanged))]
|
||||
public int winnerId=-1;
|
||||
@@ -17,7 +18,15 @@ public class MinigameManager : NetworkBehaviour
|
||||
public double startedTime = 0;
|
||||
public GameObject waitingScreen;
|
||||
public RankedGameSummary rankedSummary;
|
||||
[SyncVar(hook= nameof(OnMapRadisuChanged))]
|
||||
public float mapRadius;
|
||||
[SyncVar(hook=nameof(OnMapCenterChanged))]
|
||||
public Vector2 mapCenter = Vector2.zero;
|
||||
public Transform safeZone;
|
||||
public float safeZoneCoolTime = 60;
|
||||
public float safeZoneShrinkTime = 30;
|
||||
float safeZoneShrinkSpeed;
|
||||
|
||||
public int maxMoons, maxStars = 100;
|
||||
public Transform pickupItemsParent;
|
||||
private List<PickupItem> ActiveMoons = new List<PickupItem>();
|
||||
@@ -36,22 +45,13 @@ public class MinigameManager : NetworkBehaviour
|
||||
|
||||
DBmanager.OnStateChanged.AddListener(UpdateMaterialValues);
|
||||
UpdateMaterialValues();
|
||||
|
||||
safeZoneShrinkSpeed = mapRadius / safeZoneShrinkTime;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// if(!DBmanager.LoggedIn){SceneManager.LoadScene(0);} //Signed out, no game for u
|
||||
|
||||
if(isRanked){
|
||||
// RankedGameStarted= (FindObjectsOfType<SpaceshipController>().Length >=2);
|
||||
if(!RankedGameStarted && !isServer){
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
if(players.Length >= 2){
|
||||
RankedGameStarted=true;
|
||||
}
|
||||
}
|
||||
waitingScreen.SetActive(!RankedGameStarted);
|
||||
}
|
||||
|
||||
if (!isServer) { return; }
|
||||
|
||||
@@ -59,16 +59,46 @@ public class MinigameManager : NetworkBehaviour
|
||||
KillOutOfBoundsPlayers();
|
||||
if(isRanked){RankedMechanics();}
|
||||
}
|
||||
public float timeElapsed => (float)(NetworkTime.time - startedTime);
|
||||
bool shrinkStarted =false;
|
||||
uint[] PlayersIds;
|
||||
Vector2 newMapCenter = Vector2.zero;
|
||||
public void StartRanked(){
|
||||
startedTime=NetworkTime.time;
|
||||
RankedGameStarted=true;
|
||||
|
||||
void RankedMechanics(){
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
if(players.Length < 2){
|
||||
//Not enough players
|
||||
}else{
|
||||
if(!RankedGameStarted){
|
||||
startedTime=NetworkTime.time;
|
||||
PlayersIds = new uint[players.Length];
|
||||
for(int i=0; i < players.Length; i++){
|
||||
PlayersIds[i] = players[i].netId;
|
||||
}
|
||||
}
|
||||
void RankedMechanics(){
|
||||
mapCenter += ((newMapCenter - mapCenter) / safeZoneShrinkTime) * Time.deltaTime;
|
||||
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
if(players.Length >= 2 && !RankedGameStarted){
|
||||
if(players[0].ready && players[1].ready){
|
||||
//Both are ready
|
||||
StartRanked();
|
||||
}
|
||||
RankedGameStarted=true;
|
||||
}
|
||||
|
||||
|
||||
if(RankedGameStarted){
|
||||
if(timeElapsed > safeZoneCoolTime){
|
||||
if(!shrinkStarted){
|
||||
shrinkStarted=true;
|
||||
newMapCenter = getRandomPointInCirlce(mapCenter, mapRadius /2f);
|
||||
KillfeedMgr.instance.AddNewEntry("Safe zone is shrinking!");
|
||||
RpcKillfeed("Safe-zone is Shrinking!");
|
||||
}
|
||||
if(mapRadius > 3){
|
||||
mapRadius -= Time.deltaTime * safeZoneShrinkSpeed;
|
||||
safeZone.localScale = new Vector3(mapRadius, mapRadius,mapRadius);
|
||||
}
|
||||
}
|
||||
|
||||
if(players[0].moonsCollected >= 30){
|
||||
//player 1 has won
|
||||
winnerId = (int)players[0].netId;
|
||||
@@ -90,8 +120,26 @@ public class MinigameManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapRadisuChanged(float oldVal, float newVal){
|
||||
if(isRanked){
|
||||
safeZone.localScale = new Vector3(mapRadius, mapRadius,mapRadius);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapCenterChanged(Vector2 oldPos, Vector2 newPos){
|
||||
if(isRanked){
|
||||
safeZone.position = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
void RpcKillfeed(string message){
|
||||
KillfeedMgr.instance.AddNewEntry(message);
|
||||
}
|
||||
|
||||
|
||||
void OnWinnerChanged(int oldVal, int newVal){
|
||||
if(newVal<= 0){return;}
|
||||
// if(!isLocalPlayer){return;}
|
||||
Debug.Log($"{newVal} id won!");
|
||||
SpaceshipController localPlayer = SceneData.localPlayer.GetComponent<SpaceshipController>();
|
||||
if(newVal == localPlayer.netId){
|
||||
@@ -109,16 +157,31 @@ public class MinigameManager : NetworkBehaviour
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
foreach (SpaceshipController player in players)
|
||||
{
|
||||
if (Vector3.Distance(player.transform.position, Vector3.zero) > mapRadius)
|
||||
if (Vector3.Distance(player.transform.position, mapCenter) > mapRadius)
|
||||
{
|
||||
//Out of bounds. Kill him
|
||||
player.Die("Playzone");
|
||||
if(isRanked){
|
||||
player.DecreaseTrail(Time.deltaTime * 4);
|
||||
if(player.trailTime < 1){
|
||||
winnerId = (int)(PlayersIds[0] == player.netId ? PlayersIds[1] : PlayersIds[0]);
|
||||
player.Die("Playzone");
|
||||
|
||||
}
|
||||
}else{
|
||||
player.Die("Playzone");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandlePickupSpawn()
|
||||
{
|
||||
foreach(PickupItem moon in ActiveMoons){
|
||||
if(Vector2.Distance(Vector2.zero, moon.transform.position) > mapRadius){
|
||||
moon.Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
int moonsNeed = maxMoons - ActiveMoons.Count;
|
||||
int starsNeed = maxStars - ActiveStars.Count;
|
||||
|
||||
|
||||
52
Assets/Game/Scripts/Minigame/RankedSplash.cs
Normal file
52
Assets/Game/Scripts/Minigame/RankedSplash.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
public class RankedSplash : MonoBehaviour
|
||||
{
|
||||
public int playerCountRequired;
|
||||
public TMP_Text statusTxt;
|
||||
void Start()
|
||||
{
|
||||
statusTxt.text = "Waiting for confirmation";
|
||||
}
|
||||
bool allConnected= false;
|
||||
string rules = @"1.Last one standing or the first to \ncollect 30 moons wins!
|
||||
2.Stay in safe zone to survive
|
||||
3.Safe-Zone gets shrinked in 5 mins
|
||||
4.Have fun!";
|
||||
void Update()
|
||||
{
|
||||
// if(AutoConnect.instance.isClient){return;}
|
||||
if(MinigameManager.instance ==null){return;}
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
if(players.Length >= playerCountRequired && players[0].ready && players[1].ready){
|
||||
//Start the match!
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if(!MinigameManager.instance.RankedGameStarted){
|
||||
|
||||
if(!allConnected && players.Length < playerCountRequired){
|
||||
statusTxt.text = "Waiting for opponents to connect";
|
||||
}else{
|
||||
if(!allConnected){
|
||||
allConnected = true;
|
||||
MessageDialog.instance.ShowQuestion("Confirm", $"Click yes to confirm you understand the rules below.\n{rules}", OnAgree, ()=>{}, onlyYes:true);
|
||||
}
|
||||
|
||||
if(players[0].ready && players[1].ready){
|
||||
//Start the match!
|
||||
gameObject.SetActive(false);
|
||||
}else{
|
||||
statusTxt.text = "Waiting for players to get ready";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnAgree(){
|
||||
SceneData.localPlayer.GetComponent<SpaceshipController>().SetReady(true);
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/Minigame/RankedSplash.cs.meta
Normal file
11
Assets/Game/Scripts/Minigame/RankedSplash.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8aaf26be5e0f9cf6ea304725e39a0f8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -29,7 +29,7 @@ public class SceneDataHolder : MonoBehaviour
|
||||
}
|
||||
|
||||
public void ShowDeadscreen(int xpEarned, int metalEarned, double survivalTime){
|
||||
AdsManager.instance.ShowInterestitial();
|
||||
if(AdsManager.instance!=null){AdsManager.instance.ShowInterestitial();}
|
||||
deadScreen.SetActive(true);
|
||||
xpEarnings.SetActive(xpEarned > 0); metalEarnings.SetActive(metalEarned > 0);
|
||||
xpEarnings.GetComponentInChildren<TMP_Text>().text = xpEarned.ToString();
|
||||
|
||||
@@ -8,6 +8,7 @@ using UnityEngine.UI;
|
||||
public class SkinShopManager : MonoBehaviour
|
||||
{
|
||||
public static SkinShopManager instance;
|
||||
public Building skinShopBuilding;
|
||||
public SkinsData skinsData;
|
||||
public GameObject popup;
|
||||
|
||||
@@ -53,6 +54,13 @@ public class SkinShopManager : MonoBehaviour
|
||||
}
|
||||
skinShopItems = new List<SkinShopItem>();
|
||||
for(int i=0; i<skinsData.skins.Length;i++){
|
||||
int rarity = 0;
|
||||
if(skinsData.skins[i].skinType == SkinType.Rare){rarity=1;}
|
||||
if(skinsData.skins[i].skinType == SkinType.Legendary){rarity=2;}
|
||||
|
||||
if(skinShopBuilding.curLevel < rarity){
|
||||
continue;
|
||||
}
|
||||
SkinShopItem newItem = Instantiate(listItemPrefab, listItemsParent).GetComponent<SkinShopItem>();
|
||||
newItem.Set(skinsData.skins[i]);
|
||||
skinShopItems.Add(newItem);
|
||||
|
||||
@@ -7,6 +7,8 @@ using System.Collections;
|
||||
|
||||
public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
[SyncVar]
|
||||
public bool ready;
|
||||
public SpriteRenderer playerImg;
|
||||
public SkinsData skins;
|
||||
[SyncVar(hook = nameof(OnSkinChanged))]
|
||||
@@ -26,8 +28,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
public bool dead;
|
||||
[SyncVar]
|
||||
public float speed;
|
||||
[SyncVar(hook = nameof(OnScaleChanged))]
|
||||
public float scaleMultiplier = 1;
|
||||
public float _scaleMultiplier = 1;
|
||||
public Text pnameTxt;
|
||||
public Transform body;
|
||||
public TrailMgr trailMgr;
|
||||
@@ -49,6 +50,19 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
public float distanceFromCenter = 0;
|
||||
|
||||
public void SetReady(bool value){
|
||||
if(isServer){
|
||||
ready =value;
|
||||
}else{
|
||||
CmdSetReady(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSetReady(bool value){
|
||||
ready= value;
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSetPname(string value)
|
||||
{
|
||||
@@ -57,6 +71,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
void OnPnameChanged(string oldName, string newName)
|
||||
{
|
||||
pnameTxt.text = newName;
|
||||
Debug.Log(pname + " Joined the game");
|
||||
}
|
||||
|
||||
[Command]
|
||||
@@ -85,6 +100,13 @@ public class SpaceshipController : NetworkBehaviour
|
||||
void OnTrailTimeChanged(float oldValue, float newValue)
|
||||
{
|
||||
trailMgr.trail.time = newValue;
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(scale > 1);
|
||||
if(scale <=1 && boosting){
|
||||
CmdSetBoosting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnBoostDown()
|
||||
@@ -117,17 +139,6 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void OnScaleChanged(float oldScale, float newScale)
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(newScale > 1);
|
||||
if(newScale <=1 && boosting){
|
||||
CmdSetBoosting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSetBoosting(bool value)
|
||||
{
|
||||
@@ -144,7 +155,6 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
scaleMultiplier = 1;
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
ResetStats();
|
||||
@@ -193,6 +203,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
int roundedTime => Mathf.FloorToInt((float)timeInMillis / 100f) * 100;
|
||||
|
||||
int lastClientUpdateTime = 0;
|
||||
float scale => Mathf.Clamp(1+(trailTime * _scaleMultiplier),1,10);
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (MinigameManager.instance.isRanked && !MinigameManager.instance.RankedGameStarted) { return; }
|
||||
@@ -200,8 +211,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
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(scale, scale, scale), 0.1f);
|
||||
trailMgr.trail.startWidth = Mathf.Lerp(trailMgr.trail.startWidth, scale, 0.1f);
|
||||
|
||||
if (dead) { return; }
|
||||
|
||||
@@ -235,12 +246,12 @@ public class SpaceshipController : NetworkBehaviour
|
||||
if (isServer)
|
||||
{
|
||||
//boost check
|
||||
if (boosting && scaleMultiplier > 1)
|
||||
if (boosting && scale > 1)
|
||||
{
|
||||
speed = movingSpeed * 2;
|
||||
scaleMultiplier -= Time.deltaTime;
|
||||
|
||||
if (scaleMultiplier < 1) { scaleMultiplier = 1; } //Clamp in case gets lower
|
||||
DecreaseTrail(Time.deltaTime * 3);
|
||||
// scaleMultiplier -= Time.deltaTime;
|
||||
// if (scaleMultiplier < 1) { scaleMultiplier = 1; } //Clamp in case gets lower
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -512,8 +523,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
Kills++;
|
||||
Scores += 10; //TODO: Need to change Scores on kills?
|
||||
scaleMultiplier += 0.05f;
|
||||
OnScaleChanged(scaleMultiplier, scaleMultiplier);
|
||||
// scaleMultiplier += 0.05f;
|
||||
// OnScaleChanged(scaleMultiplier, scaleMultiplier);
|
||||
IncreaseTrail(trailIncrementRate);
|
||||
RpcOnKill();
|
||||
}
|
||||
@@ -537,7 +548,14 @@ public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
trailTime = trailMgr.trail.time + rate;
|
||||
trailMgr.trail.time = trailTime;
|
||||
Debug.Log("Increasing trail of" + pname);
|
||||
// Debug.Log("Increasing trail of" + pname);
|
||||
}
|
||||
|
||||
public void DecreaseTrail(float rate)
|
||||
{
|
||||
trailTime = Mathf.Clamp(trailMgr.trail.time - rate,0,float.MaxValue);
|
||||
trailMgr.trail.time = trailTime;
|
||||
// Debug.Log("Decreasing trail of" + pname);
|
||||
}
|
||||
|
||||
[Command]
|
||||
@@ -553,13 +571,13 @@ public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
case PickupItem.PickupType.Moon:
|
||||
IncreaseTrail(trailIncrementRate);
|
||||
scaleMultiplier += 0.05f;
|
||||
// scaleMultiplier += 0.05f;
|
||||
moonsCollected++;
|
||||
break;
|
||||
|
||||
case PickupItem.PickupType.Star:
|
||||
IncreaseTrail(trailIncrementRate / 2f);
|
||||
scaleMultiplier += 0.025f;
|
||||
// scaleMultiplier += 0.025f;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -583,8 +601,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
Debug.Log($"Sending death signal to {pname} by {killer}");
|
||||
|
||||
//Handle Respawning
|
||||
OnScaleChanged(scaleMultiplier, 1);
|
||||
scaleMultiplier = 1;
|
||||
// OnScaleChanged(scaleMultiplier, 1);
|
||||
// scaleMultiplier = 1;
|
||||
dead = true;
|
||||
Scores = 0;
|
||||
Kills = 0;
|
||||
|
||||
@@ -11,4 +11,8 @@ public class SceneManagerHelper : MonoBehaviour
|
||||
public void LoadLevel(string sceneName){
|
||||
LoadingScreen.instance.LoadLevel(sceneName);
|
||||
}
|
||||
|
||||
public void OpenLink(string url){
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
void OnUpgradeMenuClicked()
|
||||
{
|
||||
// Debug.Log("Opening Upgrade Menu for : " + Selector.selectedBuilding.buildingData.name);
|
||||
AudioManager.instnace.UIPopup();
|
||||
|
||||
upgradeMenu.SetActive(true);
|
||||
upgrade_buildingName.text = Selector.selectedBuilding.buildingData.buildingName;
|
||||
@@ -137,10 +138,14 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
tierIndicators[i].SetActive( Selector.selectedBuilding.curLevel == i);
|
||||
}
|
||||
descriptionTxt.text = Selector.selectedBuilding.buildingData.description;
|
||||
|
||||
AudioManager.instnace.UIPopup();
|
||||
}
|
||||
|
||||
void OpenSkinMenu(){
|
||||
SkinShopManager.instance.Show();
|
||||
AudioManager.instnace.UIPopup();
|
||||
|
||||
}
|
||||
|
||||
void OnCollect(){
|
||||
|
||||
@@ -16,12 +16,6 @@ public class GoldPackButton : MonoBehaviour
|
||||
GetComponent<Button>().onClick.AddListener(OnClicked);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnClicked(){
|
||||
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {Amount} Gold for {Price} Gems?", Buy,null);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class XpPass : MonoBehaviour
|
||||
|
||||
public void OnRewardCollect(int level){
|
||||
if(DBmanager.ExpPassCollected.Contains(level)){return;} //False call
|
||||
|
||||
AudioManager.instnace.Reward();
|
||||
foreach(XpPassReward reward in rewards){
|
||||
if(reward.level == level){
|
||||
DBmanager.AddCollectedExpPass(level);
|
||||
|
||||
Reference in New Issue
Block a user