54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
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 collect 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){
|
|
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);
|
|
}
|
|
}
|