This commit is contained in:
2022-12-14 01:49:10 +05:30
parent c4403fb562
commit 1d555e0aee
213 changed files with 466265 additions and 3334 deletions

View File

@@ -60,11 +60,22 @@ public class AdsManager : MonoBehaviour
rewardedAd.OnUserEarnedReward += OnRewardedComplete;
rewardedAd.OnAdFailedToLoad += OnRewardedFailed;
rewardedAd.OnAdFailedToShow += OnRewardedFailed;
interstitial.OnAdClosed += OnInterestitialClosed;
// RequestBanner();
LoadInterestitial();
LoadRewarded();
}
private static UnityEvent onInterestitialClosed = new UnityEvent();
public static void AddOnInterestitialClosed(UnityAction e){
if(onInterestitialClosed==null){onInterestitialClosed = new UnityEvent();}
onInterestitialClosed.AddListener(e);
}
void OnInterestitialClosed(object sender, EventArgs args){
onInterestitialClosed.Invoke();
}
void RequestBanner(){
bannerView = new BannerView(bannerId, AdSize.Banner, AdPosition.BottomLeft);

View File

@@ -17,6 +17,7 @@ public class AudioManager : MonoBehaviour
[SerializeField]private AudioClip spend;
[SerializeField]private AudioClip chestOpenRiser;
[SerializeField]private AudioClip chestOpen;
[SerializeField]private AudioClip epicChestOpen;
[SerializeField]private AudioClip buildingUpgrade;
[SerializeField]private AudioClip buildingUpgradeWhoosh;
[SerializeField]private AudioClip[] rocketUpgrade;
@@ -24,12 +25,16 @@ public class AudioManager : MonoBehaviour
[SerializeField]private AudioClip[] bpOpen;
[SerializeField]private AudioClip bpFound;
[SerializeField]private AudioClip reward;
[SerializeField]private AudioClip gemsCollect;
[Header("Gold")]
public AudioClip collectGoldBegin;
public AudioClip[] collectGoldArray;
// public float
[Header("Minigame")]
[SerializeField]private AudioSource EngineSource;
[SerializeField]private AudioSource PickupSource;
[SerializeField]private AudioClip moonCollected;
[SerializeField]private AudioClip starCollected;
[SerializeField]private AudioClip minigameVictory;
@@ -121,11 +126,12 @@ public class AudioManager : MonoBehaviour
public void BattleRanked(){
audioSrc.PlayOneShot(battleRanked);
}
public void CollectMoon(){
audioSrc.PlayOneShot(moonCollected, 0.3f);
}
public void CollectStar(){
audioSrc.PlayOneShot(moonCollected, 0.3f);
public void CollectMoon(float trailTime, float maxTrailTime){
// audioSrc.PlayOneShot(moonCollected, 0.3f);
float mult = Mathf.Clamp(trailTime / maxTrailTime, 0f,1f);
PickupSource.pitch = 0.5f + (mult/2f);
Debug.Log(PickupSource.pitch);
PickupSource.Play();
}
public void Spend(){
audioSrc.PlayOneShot(spend);
@@ -137,6 +143,10 @@ public class AudioManager : MonoBehaviour
audioSrc.PlayOneShot(chestOpen);
}
public void EpicChestOpen(){
audioSrc.PlayOneShot(epicChestOpen);
}
public void UpgradeBuilding(){
audioSrc.PlayOneShot(buildingUpgrade);
audioSrc.PlayOneShot(buildingUpgradeWhoosh);
@@ -204,6 +214,10 @@ public class AudioManager : MonoBehaviour
audioSrc.PlayOneShot(collectGoldArray[index]);
}
public void CollectGems(){
audioSrc.PlayOneShot(gemsCollect);
}
public void Boost(){
audioSrc.PlayOneShot(boostStart[Random.Range(0,boostStart.Length)]);
}

View File

@@ -11,12 +11,14 @@ public class ChestOpener : MonoBehaviour
public GameObject chestOpenPopup;
public ChestDataObject EpicChestData;
public bool active => chestOpenPopup.activeSelf;
public Animator chestAnim;
public GameObject gemsDrop;
public GameObject goldDrop;
public GameObject skinDrop;
public ParticleSystem skinBgParticle;
public ParticleSystem confettiFX;
public SkinsData skins;
@@ -26,6 +28,11 @@ public class ChestOpener : MonoBehaviour
}
public async void OpenChest(ChestDataObject chestData){
if(chestData == EpicChestData){
AudioManager.instnace.EpicChestOpen();
}else{
AudioManager.instnace.ChestOpen();
}
chestOpenPopup.SetActive(true);
okButton.SetActive(false);
@@ -94,10 +101,13 @@ public class ChestOpener : MonoBehaviour
chestAnim.CrossFadeInFixedTime("openAnim",0.1f);
while(chestAnim.GetCurrentAnimatorStateInfo(0).IsName("openAnim")){
//Chest opens here
confettiFX.Play();
while (chestAnim.GetCurrentAnimatorStateInfo(0).IsName("openAnim")){
await Task.Delay(10);
}
DBmanager.SetGems(DBmanager.Gems + gemsCount);
DBmanager.SetCoins(DBmanager.Coins + goldCount);

View File

@@ -5,6 +5,7 @@ using UnityEngine.UI;
public class CollectBtn : MonoBehaviour
{
public static CollectBtn instance;
public DateTime lastCollected;
public string buildingId;
public float productionRate;
@@ -13,7 +14,9 @@ public class CollectBtn : MonoBehaviour
public TMP_Text txt;
public CollectablesData.ResourceType resourceType;
void Awake(){
instance = this;
}
void Start(){
btn.onClick.AddListener(OnClick);
@@ -42,17 +45,19 @@ public class CollectBtn : MonoBehaviour
switch (resourceType){
case CollectablesData.ResourceType.Metal:
collectableAmount= GetCollectableEnergy();
if((int)collectableAmount <= 0){return;}
DBmanager.SetMetal(DBmanager.Metal + (int)collectableAmount);
CollectEffect.instance.Show(resourceType,(int)collectableAmount);
AudioManager.instnace.CollectGems();
break;
case CollectablesData.ResourceType.Gold:
collectableAmount= GetCollectableGold();
if((int)collectableAmount <= 0){return;}
DBmanager.SetCoins(DBmanager.Coins + (int)collectableAmount);
CollectEffect.instance.Show(resourceType,(int)collectableAmount);
AudioManager.instnace.CollectGold((int)collectableAmount);
// AudioManager.instnace.CollectGems();
break;
// case CollectablesData.ResourceType.Oxygen:
@@ -77,6 +82,22 @@ public class CollectBtn : MonoBehaviour
return Mathf.Clamp((float)((DateTime.UtcNow - lastCollected).TotalSeconds * ((productionRate/60f)/60f)),0, coinsCap);
}
public bool isGoldCapped(string bid){
if(TutorialManager.showing){
return false;
}
Building selectedBuilding = BuildingManager.instance.GetBuildingWithId(bid);
int coinsCap = 0;
foreach(BuildingStat stat in selectedBuilding.buildingData.levels[selectedBuilding.curLevel].stats){
if(stat.name == "Capacity"){
coinsCap = int.Parse(stat.value);
break;
}
}
float collectable=(float)((DateTime.UtcNow - lastCollected).TotalSeconds * ((productionRate/60f)/60f));
// return Mathf.Clamp(,0, coinsCap);
return collectable >= coinsCap;
}
double GetCollectableEnergy(){
Building selectedBuilding = BuildingManager.instance.GetBuildingWithId(buildingId);
@@ -90,4 +111,18 @@ public class CollectBtn : MonoBehaviour
return Mathf.Clamp((float)((DateTime.UtcNow - lastCollected).TotalSeconds * ((productionRate/60f)/60f)),0, coinsCap);
}
public static bool isEnergyCapped(string bid){
Building selectedBuilding = BuildingManager.instance.GetBuildingWithId(bid);
int coinsCap = 0;
foreach(BuildingStat stat in selectedBuilding.buildingData.levels[selectedBuilding.curLevel].stats){
if(stat.name == "Capacity"){
coinsCap = int.Parse(stat.value);
break;
}
}
float collectable = (float)((DateTime.UtcNow - selectedBuilding.lastCollected).TotalSeconds * ((selectedBuilding.buildingData.productinoRates[selectedBuilding.curLevel]/60f)/60f));
return collectable >= coinsCap;
}
}

View File

@@ -6,11 +6,12 @@ using UnityEngine.UI;
public class CollectEffect : MonoBehaviour
{
public static CollectEffect instance;
public Camera FXCam;
public Transform solarPanel;
public Transform goldMine;
public RectTransform goldStats, metalStats;
public Animator GoldAnim, MetalAnim;
public Transform GoldEffect, MetalEffect;
public RectTransform GoldEffect, MetalEffect;
public float EffectScale =1;
void Awake(){
@@ -24,41 +25,51 @@ public class CollectEffect : MonoBehaviour
public void Show(CollectablesData.ResourceType type, int amount){
if(type == CollectablesData.ResourceType.Gold){
GoldEffect.GetComponent<ParticleSystem>().maxParticles = (int)Mathf.Clamp(amount * EffectScale, 5, 100);
StartCoroutine(PlayAnimation(GoldAnim, GoldEffect));
// Vector3 ViewportPosition = Camera.main.WorldToViewportPoint(goldMine.position);
// RectTransform CanvasRect = GoldEffect.root.GetComponent<RectTransform>();
// Vector2 WorldObject_ScreenPosition=new Vector2(
// ((ViewportPosition.x*CanvasRect.sizeDelta.x)-(CanvasRect.sizeDelta.x*0.5f)),
// ((ViewportPosition.y*CanvasRect.sizeDelta.y)-(CanvasRect.sizeDelta.y*0.5f)));
// Debug.Log(WorldObject_ScreenPosition);
Vector2 WorldObject_ScreenPosition = Camera.main.WorldToScreenPoint(goldMine.position);
StartCoroutine(startEffect(GoldEffect, WorldObject_ScreenPosition, goldStats.position));
// StartCoroutine(PlayAnimation(GoldAnim, GoldEffect));
}else{
MetalEffect.GetComponent<ParticleSystem>().maxParticles = (int)Mathf.Clamp(amount * EffectScale, 5, 100);
StartCoroutine(startEffect(MetalEffect, FXCam.WorldToScreenPoint(solarPanel.position), metalStats.position));
StartCoroutine(PlayAnimation(MetalAnim,MetalEffect));
// StartCoroutine(PlayAnimation(MetalAnim,MetalEffect));
}
}
IEnumerator PlayAnimation(Animator anim, Transform target){
target.gameObject.SetActive(false);
anim.Play("CollectAnim");
yield return new WaitForSeconds(0.05f);
target.gameObject.SetActive(true);
while(anim.GetCurrentAnimatorStateInfo(0).IsName("CollectAnim")){
target.position = anim.transform.position;
yield return null;
}
}
// IEnumerator startEffect(Transform item,Vector3 start, Vector3 stop){
// Vector3 diff = stop - start;
// item.gameObject.SetActive(true);
// for(int i =0; i < steps; i++){
// item.position = start + (diff * ((float)i/(float)steps));
// item.localScale = Vector3.one * (1-(float)(Mathf.Abs(((float)steps/2f) - i)) / ((float)steps / 2f));
// yield return new WaitForFixedUpdate();
// IEnumerator PlayAnimation(Animator anim, Transform target){
// target.gameObject.SetActive(false);
// anim.Play("CollectAnim");
// yield return new WaitForSeconds(0.05f);
// target.gameObject.SetActive(true);
// while(anim.GetCurrentAnimatorStateInfo(0).IsName("CollectAnim")){
// target.position = anim.transform.position;
// yield return null;
// }
// item.gameObject.SetActive(false);
// }
// [Header("Animation tweaks")]
// public int steps = 500;
// public int offset = 10;
IEnumerator startEffect(RectTransform item,Vector3 start, Vector3 stop){
Vector3 diff = stop - start;
item.gameObject.SetActive(true);
Debug.Log(start + " : " + stop);
for(int i =0; i < steps; i++){
item.position = start + (diff * ((float)i/(float)steps));
item.localScale = Vector3.one * (5 + (22 * (1-(float)(Mathf.Abs(((float)steps/2f) - i)) / ((float)steps / 2f))));
yield return new WaitForFixedUpdate();
}
item.gameObject.SetActive(false);
}
[Header("Animation tweaks")]
public int steps = 500;
public int offset = 10;
// IEnumerator startEffect(Vector3 start, Vector3 stop){
// Vector3 diff = stop - start;
// for(int i=0; i < transform.childCount; i++){

View File

@@ -2,13 +2,14 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class ControlSettings : MonoBehaviour
{
private const string ControlOnRightKey = "ControlOnRight";
public Button left;
public Button right;
public static bool ControlIsOnRight = true;
public UnityEvent OnChanged;
void Awake()
{
if(PlayerPrefs.HasKey(ControlOnRightKey)){
@@ -25,6 +26,7 @@ public class ControlSettings : MonoBehaviour
PlayerPrefs.Save();
UpdateSettingsPage();
AudioManager.instnace.UIClick();
OnChanged.Invoke();
}
void UpdateSettingsPage(){

View File

@@ -14,6 +14,8 @@ public class DesignLab : MonoBehaviour
public GameObject newSkinPanel;
public GameObject goldsPanel;
public Button btnOpen;
public ParticleSystem confettiFX;
public ParticleSystem[] fullscreenFX;
public Button[] slips;
@@ -47,6 +49,7 @@ public class DesignLab : MonoBehaviour
public void OnBoxSelected(int index){
selectedBoxIndex = index;
Refresh();
AudioManager.instnace.UIClick();
}
void Refresh()
@@ -182,6 +185,11 @@ public class DesignLab : MonoBehaviour
MessageDialog.instance.ShowMessage("Error", "Not enough resources to build this blueprint");
}
//Fullscreen FX
foreach (ParticleSystem particle in fullscreenFX)
{
particle.Play();
}
Refresh();
}
@@ -227,7 +235,7 @@ public class DesignLab : MonoBehaviour
Debug.LogError("No skin found to award");
int amount = (int)(boxPrices[selectedBoxIndex] / 4f);
AwardGold(amount);
AudioManager.instnace.CollectGold(amount);
// AudioManager.instnace.CollectGold(amount);
}else{
AwardSkin(availableSkins[Random.Range(0, availableSkins.Count-1)]);
@@ -242,17 +250,24 @@ public class DesignLab : MonoBehaviour
void AwardSkin(SkinShopItemData skin){
newSkinPanel.SetActive(true);
newSkinPanel.transform.Find("img_skin").GetComponent<Image>().sprite = skin.image;
UpgradeEffect.top_instance.Show(newSkinPanel.GetComponent<RectTransform>().position);
//UpgradeEffect.top_instance.Show(newSkinPanel.GetComponent<RectTransform>().position);
DBmanager.AddSkinBlueprint(skin);
//Fullscreen FX
foreach (ParticleSystem particle in fullscreenFX)
{
particle.Play();
}
Refresh();
}
void AwardGold(int amount){
goldsPanel.SetActive(true);
goldsPanel.transform.Find("txt_amount").GetComponent<TMP_Text>().text = amount.ToString();
UpgradeEffect.top_instance.Show(goldsPanel.GetComponent<RectTransform>().position);
// UpgradeEffect.top_instance.Show(goldsPanel.GetComponent<RectTransform>().position);
//Confetti
confettiFX.Play();
DBmanager.SetCoins(DBmanager.Coins + amount);
Refresh();
}

View File

@@ -8,14 +8,16 @@ public class GoldMine : MonoBehaviour
public Sprite statIcon;
public GoldMineData gold_stats;
public static GoldMineData Stats;
public GameObject fullFX;
// static int ProductionMultiplier=50;
// static int CapacityMultiplier=1000;
// static int gold_prod_upgrade_cost = 3000;
// static int gold_cap_upgrade_cost = 2500;
BuildingData data;
void Awake()
{
Stats = gold_stats;
BuildingData data =GetComponent<Building>().buildingData;
data =GetComponent<Building>().buildingData;
data.levels = new List<BuildingLevel>();
data.productinoRates = new float[levelsCount*levelsCount];
Debug.Log($"Gold mine levels combos:{levelsCount}");
@@ -39,6 +41,16 @@ public class GoldMine : MonoBehaviour
}
}
float t = 0;
void Update(){
if(t < 1){
t += Time.deltaTime;
}else{
t=0;
fullFX.SetActive(CollectBtn.isEnergyCapped(data.buildingName));
}
}
//Note for future me: Refer to the sketch you draw on laptop to understand below equations
public static int GetProductionRateByLevel(int level){
//P = L - C - (2l-3)

View File

@@ -18,11 +18,12 @@ public class LoadingScreen : MonoBehaviour
{
instance = this;
Application.backgroundLoadingPriority = ThreadPriority.Low;
canvasGroup = GetComponent<CanvasGroup>();
}
void Start()
{
DontDestroyOnLoad(gameObject);
canvasGroup = GetComponent<CanvasGroup>();
}
public void LoadLevel(string levelName)
@@ -46,14 +47,14 @@ public class LoadingScreen : MonoBehaviour
canvasGroup.alpha += 0.03f;
yield return new WaitForFixedUpdate();
}
if (levelName.ToLower().Contains("minigame"))
{
while (RegionManager.selectedServer == null && levelName.Contains("Minigame"))
{
loadingProgressTxt.text = "Preparing";
yield return new WaitForSeconds(0.5f);
}
}
// if (levelName.ToLower().Contains("minigame") && !levelName.ToLower().Contains("tutorial"))
// {
// while (RegionManager.selectedServer == null && levelName.Contains("Minigame"))
// {
// loadingProgressTxt.text = "Preparing";
// yield return new WaitForSeconds(0.5f);
// }
// }
AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(levelName);
// asyncOperation.allowSceneActivation = false;
while (!asyncOperation.isDone)
@@ -64,15 +65,19 @@ public class LoadingScreen : MonoBehaviour
SetProgress(asyncOperation.progress);
yield return null;
}
yield return new WaitForSeconds(0.2f);
Debug.Log("Loaded scene " + levelName);
yield return new WaitForSecondsRealtime(0.2f);
canvasGroup.blocksRaycasts = false;
while (canvasGroup.alpha > 0)
{
canvasGroup.alpha -= 0.03f;
yield return new WaitForFixedUpdate();
yield return new WaitForSecondsRealtime(0.015f);
}
Debug.Log("Loading scene vanishing");
loading = false;
}

View File

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

View File

@@ -30,7 +30,7 @@ public class MinigameManager : NetworkBehaviour
public float safeZoneShrinkTime = 30;
float safeZoneShrinkSpeed;
[SerializeField] private PickupSetting[] PickupItems;
public GameObject starPrefab;
// public GameObject starPrefab;
// public int maxMoons, maxStars = 100;
// public int maxTweps = 2;
public Transform pickupItemsParent;
@@ -45,20 +45,32 @@ public class MinigameManager : NetworkBehaviour
UpdateMaterialValues();
safeZoneShrinkSpeed = mapRadius / safeZoneShrinkTime;
defaultJoyPos = joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition;
SwitchUISides();
}
Vector2 defaultJoyPos;
public void SwitchUISides(){
if(ControlSettings.ControlIsOnRight){
joystick.anchorMin = new Vector2(0,0);
joystick.anchorMax = new Vector2(0.5f, 1);
btn_boost.anchorMin = new Vector2(1,0);
btn_boost.anchorMax = new Vector2(1,0);
btn_boost.position = new Vector2(Screen.width-100, btn_boost.position.y);
btn_boost.position = new Vector2(Screen.width-150, btn_boost.position.y);
Vector2 newDef = new Vector2(defaultJoyPos.x, defaultJoyPos.y);
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
}else{
joystick.anchorMin = new Vector2(0.5f,0);
joystick.anchorMax = new Vector2(1f, 1);
btn_boost.anchorMin = new Vector2(0,0);
btn_boost.anchorMax = new Vector2(0,0);
btn_boost.position = new Vector2(100, btn_boost.position.y);
Vector2 newDef = new Vector2(-joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition.x, joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition.y);
btn_boost.position = new Vector2(150, btn_boost.position.y);
Vector2 newDef = new Vector2(-defaultJoyPos.x, defaultJoyPos.y);
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
}
@@ -237,11 +249,27 @@ public class MinigameManager : NetworkBehaviour
}
}
}
GameObject RandomStar { get{
int i = Random.Range(0,5);
int c = 0;
GameObject selected = null;
foreach(PickupSetting pickup in PickupItems){
if(pickup.Prefab.name.ToLower().Contains("star")){
selected = pickup.Prefab;
if(c == i){
return pickup.Prefab;
break;
}
c++;
}
}
return selected;
}}
void SpawnStars(int amount, Vector3 focusedPosition){
for(int i=0; i < amount;i++){
Vector3 newPosition = getRandomPointInCirlce((Vector3)focusedPosition, 10);
GameObject newStar = Instantiate(starPrefab, pickupItemsParent);
GameObject newStar = Instantiate(RandomStar, pickupItemsParent);
NetworkServer.Spawn(newStar);
newStar.GetComponent<PickupItem>().Reposition(newPosition);
}

View File

@@ -126,6 +126,10 @@ public class PickupItem : NetworkBehaviour
public enum PickupType{
Star,
Star2,
Star3,
Star4,
Star5,
Moon1,
Moon2,
Moon3,

View File

@@ -11,7 +11,7 @@ public class RankedSplash : MonoBehaviour
statusTxt.text = "Waiting for confirmation";
}
bool allConnected= false;
string rules = @"1.Last one standing or the first to \ncollect 30 moons wins!
string rules = @"1.Last one standing or the first to collect 30 moons wins!
2.Stay in safe zone to survive
3.Safe-Zone gets shrinked in 5 mins
4.Have fun!";
@@ -20,11 +20,12 @@ public class RankedSplash : MonoBehaviour
// if(AutoConnect.instance.isClient){return;}
if(MinigameManager.instance ==null){return;}
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
if(players.Length >= playerCountRequired){
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){

View File

@@ -17,6 +17,7 @@ public class RocketUpgradePanel : MonoBehaviour
// RocketLevel CurrentLevel,NextLevel;
string selectedRocket;
public ParticleSystem[] fullscreenFX;
// public bool Affordable => DBmanager.Metal >= NextLevel.metalCost && DBmanager.Coins >= NextLevel.goldCost;
@@ -138,7 +139,11 @@ public class RocketUpgradePanel : MonoBehaviour
AudioManager.instnace.UpgradeRocket();
// Hide();
Show(selectedRocket);
UpgradeEffect.top_instance.Show(txtSpeed.rectTransform.position);
//UpgradeEffect.top_instance.Show(txtSpeed.rectTransform.position);
foreach(ParticleSystem particle in fullscreenFX)
{
particle.Play();
}
}
@@ -157,7 +162,11 @@ public class RocketUpgradePanel : MonoBehaviour
// Hide();
Show(selectedRocket);
UpgradeEffect.top_instance.Show(txtBoostConsumption.rectTransform.position);
// UpgradeEffect.top_instance.Show(txtBoostConsumption.rectTransform.position);
foreach (ParticleSystem particle in fullscreenFX)
{
particle.Play();
}
}
@@ -175,7 +184,11 @@ public class RocketUpgradePanel : MonoBehaviour
// Hide();
Show(selectedRocket);
UpgradeEffect.top_instance.Show(txtEnergyGain.rectTransform.position);
// UpgradeEffect.top_instance.Show(txtEnergyGain.rectTransform.position);
foreach (ParticleSystem particle in fullscreenFX)
{
particle.Play();
}
}

View File

@@ -4,6 +4,8 @@ using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using TMPro;
using System;
public class SceneDataHolder : MonoBehaviour
{
public Transform trailCollidersParent;
@@ -27,9 +29,9 @@ public class SceneDataHolder : MonoBehaviour
public void OnBoostDown(){
SceneData.OnBoostDown.Invoke();
}
DateTime lastShownTime;
public void ShowDeadscreen(int xpEarned, int metalEarned, double survivalTime){
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();
@@ -45,6 +47,15 @@ public class SceneDataHolder : MonoBehaviour
}
public async void ShowAds(){
if(MinigameManager.instance.isRanked){
if(AdsManager.instance!=null && (DateTime.Now - lastShownTime).Minutes > 10){
AdsManager.instance.ShowInterestitial();
lastShownTime = DateTime.Now;
}
}
}
}

View File

@@ -155,6 +155,7 @@ public class SkinShopManager : MonoBehaviour
item.OnSelectionChanged(data.name);
}
AudioManager.instnace.UIClick();
}
void onEquip(){

View File

@@ -49,13 +49,14 @@ public class SpaceshipControllerSolo : MonoBehaviour
public void CollectPickup(PickupItemSolo.PickupType type){
switch(type){
case PickupItemSolo.PickupType.Moon:
AudioManager.instnace.CollectMoon();
AudioManager.instnace.CollectMoon(1,1);
trailMgr.trail.time += TrailIncrementRate;
MoonsCollected++;
break;
case PickupItemSolo.PickupType.Star:
AudioManager.instnace.CollectStar();
AudioManager.instnace.CollectMoon(1,1);
trailMgr.trail.time += TrailIncrementRate/2f;

View File

@@ -72,6 +72,9 @@ public class SpaceshipController : NetworkBehaviour
[SerializeField]private int RubberBandsCount;
public GameObject DeathEffect;
public GameObject debrisEffect;
// public GameObject boostStartEffect;
public ParticleSystem[] boostStartEffect;
public ParticleSystem[] boostEffects;
// public GameObject PickupEffect;
public float distanceFromCenter = 0;
@@ -138,14 +141,21 @@ public class SpaceshipController : NetworkBehaviour
{
Debug.Log($"Add scores {newScores - oldScores}, (total: {newScores})");
}
bool isBoostAvailable {get{ return trailTime > minTrailTime;}}
void OnTrailTimeChanged(float oldValue, float newValue)
{
trailMgr.trail.time = newValue;
if (isLocalPlayer)
{
bool isBoostAvailable = trailTime > minTrailTime;
SceneData.holder.boostBtn.gameObject.SetActive(isBoostAvailable);
// SceneData.holder.boostBtn.gameObject.SetActive(isBoostAvailable);
SceneData.holder.boostBtn.transform.GetChild(0).gameObject.SetActive(isBoostAvailable);
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(0).gameObject.SetActive(trailTime > maxTrailTime/2f);
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(1).gameObject.SetActive(trailTime > maxTrailTime* 0.8f);
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(2).gameObject.SetActive(trailTime >= maxTrailTime);
SceneData.holder.boostBtn.transform.GetChild(0).Find("Slider").GetComponent<Image>().fillAmount = Mathf.Clamp(0.73f - ((trailTime /maxTrailTime)*0.73f),0f,0.73f);
if (!isBoostAvailable && boosting)
{
CmdSetBoosting(false);
@@ -155,8 +165,10 @@ public class SpaceshipController : NetworkBehaviour
void OnBoostDown()
{
if(!isBoostAvailable){return; }
if (isLocalPlayer)
{
AudioManager.instnace.Boost();
if (isServer)
{
@@ -168,6 +180,10 @@ public class SpaceshipController : NetworkBehaviour
}
CameraFollower.instance.ShakeBoost();
// GameObject fx = EffectPool.Spawn(boostStartEffect, transform.position);
foreach(ParticleSystem particle in boostStartEffect){
particle.Play();
}
}
}
@@ -356,10 +372,11 @@ public class SpaceshipController : NetworkBehaviour
return val;
}
}
public float MovementSmoothnessFactor = 0.1f;
void HandleTick(){
curBufferIndex = bufferIndex;
if(isLocalPlayer){
HandleInput(input);
// HandleInput(input);
InputState curInputState = new InputState(){Tick=currentTick, Input = input};
PlayerState curState = new PlayerState(){Tick=currentTick, Position= transform.position, Rotation = transform.rotation};
@@ -369,6 +386,11 @@ public class SpaceshipController : NetworkBehaviour
// transform.Translate(transform.forward * input.y);
// transform.Rotate(transform.up * input.x);
UpdateStates(currentTick, NetworkTime.rtt, input, curState.Position, curState.Rotation);
body.position = targetState.Position;
body.rotation = targetState.Rotation;
// body.position = Vector3.Lerp(body.position,targetState.Position,MovementSmoothnessFactor * movingSpeed);
// body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
}else if (isServer){
HandleInput(m_Input);
RpcUpdateOnClient(body.position, body.rotation, m_Input);
@@ -383,7 +405,13 @@ public class SpaceshipController : NetworkBehaviour
if(isLocalPlayer){CameraFollower.UpdateFrame();}
float stateError = clientStateBuffer[bufferIndex].Difference(serverStateBuffer[latencyBufferIndex]);
foreach(ParticleSystem boostEffect in boostEffects){
if(boostEffect.isEmitting && !boosting){
boostEffect.Stop();
}else if(!boostEffect.isEmitting && boosting){
boostEffect.Play();
}
}
if(isServer){
InputState curServerInputState = new InputState(){Tick=currentTick, Input = m_Input};
PlayerState curServerState = new PlayerState(){Tick=currentTick, Position = transform.position, Rotation = transform.rotation};
@@ -469,7 +497,7 @@ public class SpaceshipController : NetworkBehaviour
[ClientRpc]
void RpcUpdateOnClient(Vector3 m_position, Quaternion m_rotation, Vector2 _input){
if(isLocalPlayer){
return;
// return;
}
targetState = new PlayerState(){Position = m_position, Rotation = m_rotation};
}
@@ -638,7 +666,7 @@ public class SpaceshipController : NetworkBehaviour
// scaleMultiplier += 0.05f;
moonsCollected++;
Scores += 2;
}else if(type == PickupItem.PickupType.Star){
}else {
IncreaseTrail(trailIncrementRate / 2f);
Scores += 1;
}
@@ -663,7 +691,7 @@ public class SpaceshipController : NetworkBehaviour
MinigameManager.instance.GainMetals(gainedEnergy);
}
AudioManager.instnace.CollectMoon();
AudioManager.instnace.CollectMoon(trailTime,maxTrailTime);
}
}

View File

@@ -27,8 +27,8 @@ public class SelectedItemMenu : MonoBehaviour
[Header("upgrade menu")]
public GameObject upgradeMenu;
public GameObject goldmineUpgradeMenu;
public TMP_Text goldMineUpgradeMenuTitle;
// public GameObject goldmineUpgradeMenu;
// public TMP_Text goldMineUpgradeMenuTitle;
public Button btn_gold_prod;
public Button btn_gold_cap;
@@ -39,6 +39,9 @@ public class SelectedItemMenu : MonoBehaviour
public Button upgradeBtn;
[Header("Special buildings")]
public BuildingData goldMineBuilding;
public BuildingData solarPanelsBuilding;
public BuildingData designLabBuilding;
public BuildingData rocketRepair;
public BuildingData tradePost;
@@ -84,6 +87,9 @@ public class SelectedItemMenu : MonoBehaviour
OpenTradingPost();
}else if(Selector.selectedData == designLabBuilding){
OpenDesignLab();
}else if(Selector.selectedData == goldMineBuilding || Selector.selectedData == solarPanelsBuilding){
Debug.Log("Double tapped on a collectable");
CollectBtn.instance.OnClick();
}
}
StartCoroutine(DoubleClickTimer(Selector.selectedBuilding));
@@ -157,17 +163,23 @@ public class SelectedItemMenu : MonoBehaviour
// }
upgrade_tierTxt.text = "";
if (Selector.selectedBuilding.curLevel < Selector.selectedData.levels.Count - 1){
upgradeBtn.interactable = true;
// upgradeBtn.GetComponentInChildren<TMP_Text>().text = "Upgrade";
upgradeBtn.transform.GetChild(1).gameObject.SetActive(false);
upgradeBtn.transform.GetChild(2).gameObject.SetActive(false);
upgradeBtn.transform.GetChild(3).gameObject.SetActive(true);
// upgradeBtn.interactable = true;
// // upgradeBtn.GetComponentInChildren<TMP_Text>().text = "Upgrade";
// upgradeBtn.transform.GetChild(1).gameObject.SetActive(false);
// upgradeBtn.transform.GetChild(2).gameObject.SetActive(false);
// upgradeBtn.transform.GetChild(3).gameObject.SetActive(true);
upgradeBtn.gameObject.SetActive(false);
btn_gold_cap.gameObject.SetActive(true);
btn_gold_prod.gameObject.SetActive(true);
OnUpgrade();
}
return;
}
upgradeBtn.gameObject.SetActive(true);
btn_gold_cap.gameObject.SetActive(false);
btn_gold_prod.gameObject.SetActive(false);
upgradeBtn.transform.GetChild(3).gameObject.SetActive(false); //Not gold mine, no choice
upgrade_tierTxt.text = BuildingManager.GetStatValue(Selector.selectedBuilding,"Level");
@@ -221,8 +233,8 @@ public class SelectedItemMenu : MonoBehaviour
{
if(Selector.selectedBuilding.GetComponent<GoldMine>()!=null){
AudioManager.instnace.UIPopup();
goldMineUpgradeMenuTitle.text = "Upgrade Gold Mine";
goldmineUpgradeMenu.SetActive(true);
// goldMineUpgradeMenuTitle.text = "Upgrade Gold Mine";
// goldmineUpgradeMenu.SetActive(true);
int L = Selector.selectedBuilding.curLevel+1;
int C = GoldMine.GetCapacityRateByLevel(L);
int P = GoldMine.GetProductionRateByLevel(L);
@@ -267,8 +279,8 @@ public class SelectedItemMenu : MonoBehaviour
return;
}else if(Selector.selectedBuilding.GetComponent<SolarPanels>()!=null){
AudioManager.instnace.UIPopup();
goldmineUpgradeMenu.SetActive(true);
goldMineUpgradeMenuTitle.text = "Upgrade Solar Panels";
// goldmineUpgradeMenu.SetActive(true);
// goldMineUpgradeMenuTitle.text = "Upgrade Solar Panels";
int L = Selector.selectedBuilding.curLevel+1;
int C = SolarPanels.GetCapacityRateByLevel(L);
@@ -327,7 +339,9 @@ public class SelectedItemMenu : MonoBehaviour
int newLevel = GoldMine.GetLevelByRates(C + 1, P);
upgradeBtn.interactable= false;
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, gold_cost:GoldMine.GetGoldCostForCapacity(L), metal_cost: GoldMine.GetMetalCostForCapacity(L) );
goldmineUpgradeMenu.SetActive(false);
// goldmineUpgradeMenu.SetActive(false);
HideUpgradeMenu();
OnUpgradeMenuClicked();
}else{
int L = Selector.selectedBuilding.curLevel+1;
@@ -338,9 +352,10 @@ public class SelectedItemMenu : MonoBehaviour
int newLevel = SolarPanels.GetLevelByRates(C + 1, P);
upgradeBtn.interactable= false;
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, gold_cost:SolarPanels.GetGoldCostForCapacity(L), metal_cost: SolarPanels.GetMetalCostForCapacity(L) );
goldmineUpgradeMenu.SetActive(false);
// goldmineUpgradeMenu.SetActive(false);
OnUpgradeMenuClicked();
}
HideUpgradeMenu();
}
public void OnGoldmineProdUpgrade(){
@@ -363,7 +378,9 @@ public class SelectedItemMenu : MonoBehaviour
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, gold_cost: SolarPanels.GetGoldCostForProduction(L), metal_cost: SolarPanels.GetMetalCostForProduction(L));
}
goldmineUpgradeMenu.SetActive(false);
// goldmineUpgradeMenu.SetActive(false);
HideUpgradeMenu();
OnUpgradeMenuClicked();
}

View File

@@ -9,14 +9,16 @@ public class SolarPanels : MonoBehaviour
public Sprite statIcon;
public GoldMineData solar_stats;
public static GoldMineData Stats;
public GameObject fullFX;
// static int ProductionMultiplier=50;
// static int CapacityMultiplier=1000;
// static int gold_prod_upgrade_cost = 3000;
// static int gold_cap_upgrade_cost = 2500;
BuildingData data;
void Awake()
{
Stats = solar_stats;
BuildingData data =GetComponent<Building>().buildingData;
data =GetComponent<Building>().buildingData;
data.levels = new List<BuildingLevel>();
data.productinoRates = new float[levelsCount*levelsCount];
Debug.Log($"Solar mine levels combos:{levelsCount}");
@@ -40,6 +42,16 @@ public class SolarPanels : MonoBehaviour
}
}
float t = 0;
void Update(){
if(t < 1){
t += Time.deltaTime;
}else{
t=0;
fullFX.SetActive(CollectBtn.isEnergyCapped(data.buildingName));
}
}
//Note for future me: Refer to the sketch you draw on laptop to understand below equations
public static int GetProductionRateByLevel(int level){
//P = L - C - (2l-3)

View File

@@ -287,7 +287,7 @@ public class DBmanager : MonoBehaviour
OnStateChanged.Invoke();
}
static int levelDivider = 350;
static int levelDivider = 170;
public static float GetLevelFromXP(int _xp){
float _level =(Mathf.Sqrt((float)Mathf.Clamp(_xp, levelDivider, float.PositiveInfinity) / (float)levelDivider));
if(_level == Mathf.CeilToInt(_level)){
@@ -311,6 +311,8 @@ public class DBmanager : MonoBehaviour
int oldValue = coins;
coins = Mathf.Clamp(newValue,0,int.MaxValue);
if (justOffline) { return; }
AudioManager.instnace.CollectGold(newValue - oldValue);
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "set_coins.php", form))
{
var operation = www.SendWebRequest();

View File

@@ -135,6 +135,22 @@ namespace CustomExtensions{
case PickupItem.PickupType.Star:
return 0.5f;
break;
case PickupItem.PickupType.Star2:
return 1f;
break;
case PickupItem.PickupType.Star3:
return 1.5f;
break;
case PickupItem.PickupType.Star4:
return 2f;
break;
case PickupItem.PickupType.Star5:
return 2.5f;
break;
}
return 0;
@@ -164,6 +180,22 @@ namespace CustomExtensions{
case PickupItem.PickupType.Star:
return Color.grey;
break;
case PickupItem.PickupType.Star2:
return Color.green;;
break;
case PickupItem.PickupType.Star3:
return Color.blue;
break;
case PickupItem.PickupType.Star4:
return Color.magenta;
break;
case PickupItem.PickupType.Star5:
return Color.yellow;
break;
}
return Color.white;

View File

@@ -9,6 +9,8 @@ public class TutorialManager : MonoBehaviour
{
public static bool justRegistered;
public static bool showing =false;
public static Camera UICamera => instance.UI_Camera;
public Camera UI_Camera;
public static TutorialManager instance;
public TutorialScreen[] firstTutorial;
public TutorialScreen[] minigameTutorial;

View File

@@ -7,6 +7,6 @@ public class UIAnchorToWorldPoint : MonoBehaviour
public Transform worldPoint;
void Update()
{
transform.position = Camera.main.WorldToScreenPoint(worldPoint.position);
transform.position = TutorialManager.UICamera.WorldToScreenPoint(worldPoint.position);
}
}