suck it unity collab
This commit is contained in:
parent
2630db1920
commit
dad44ef0cf
456 changed files with 1861 additions and 128 deletions
13
Assets/RealCode/Menu/ButtonS/ButtonConnectArcade.cs
Normal file
13
Assets/RealCode/Menu/ButtonS/ButtonConnectArcade.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonConnectArcade : ButtonOnClick {
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Menu) {
|
||||
GameBoardInstance.instance.SetupGame();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonConnectArcade.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonConnectArcade.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b180e388299c2f14dbe4cb73df1c4bfb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
83
Assets/RealCode/Menu/ButtonS/ButtonConnectOnline.cs
Normal file
83
Assets/RealCode/Menu/ButtonS/ButtonConnectOnline.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ExitGames.Client.Photon.LoadBalancing;
|
||||
|
||||
public class ButtonConnectOnline : ButtonOnClick {
|
||||
|
||||
public static string region;
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Menu) {
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
GameTransition.Instance.inMultiplayer = true;
|
||||
StartCoroutine(ConnectToMultiplayerCoroutine());
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator ConnectToMultiplayerCoroutine(){
|
||||
if (NetworkManager.net.ConnectToNameServer()){
|
||||
Debug.Log("Connecting to name server");
|
||||
} else {
|
||||
Debug.Log("Name Server connection failed");
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (!NetworkManager.onNameServer || !NetworkManager.isReady) yield return null;
|
||||
Debug.Log("Connected to name server");
|
||||
|
||||
if (NetworkManager.net.OpGetRegions()){
|
||||
Debug.Log("Started region request");
|
||||
} else {
|
||||
Debug.Log("Failed region request");
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (NetworkManager.net.AvailableRegions == null) yield return null;
|
||||
Debug.Log("Received region list");
|
||||
|
||||
// testing, quick load
|
||||
if (NetworkManager.instance.quickLoadTestingLobby){
|
||||
region = "usw";
|
||||
}
|
||||
// select best region
|
||||
else {
|
||||
region = null;
|
||||
while(region == null) yield return null;
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
}
|
||||
|
||||
|
||||
if(NetworkManager.net.ConnectToRegionMaster(region)){
|
||||
Debug.LogFormat("Connecting to region master '{0}'", region);
|
||||
} else {
|
||||
Debug.LogFormat("Failed to connect to region master '{0}'", region);
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (!NetworkManager.onMasterLobby) yield return null;
|
||||
Debug.Log("Connected to region master");
|
||||
Debug.Log("You can quick join now");
|
||||
|
||||
// testing, quick load
|
||||
if (NetworkManager.instance.quickLoadTestingLobby){
|
||||
var activeScene = "QUICKJOIN";
|
||||
|
||||
var ro = new RoomOptions();
|
||||
ro.IsVisible = false;
|
||||
ro.IsOpen = true;
|
||||
ro.MaxPlayers = NetworkManager.instance.expectedMaxPlayers;
|
||||
|
||||
NetworkManager.net.OpJoinOrCreateRoomWithProperties(activeScene, ro, null);
|
||||
|
||||
// connect to room
|
||||
while(!NetworkManager.inRoom) yield return null;
|
||||
|
||||
// wait for max players to auto start
|
||||
while(NetworkManager.net.CurrentRoom.PlayerCount != NetworkManager.instance.expectedMaxPlayers) yield return null;
|
||||
|
||||
GameBoardInstance.instance.SetupGame();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonConnectOnline.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonConnectOnline.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4e462570ffc55746b27123581212710
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Assets/RealCode/Menu/ButtonS/ButtonCreateLobby.cs
Normal file
45
Assets/RealCode/Menu/ButtonS/ButtonCreateLobby.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
using ClientState = ExitGames.Client.Photon.LoadBalancing.ClientState;
|
||||
using RoomInfo = ExitGames.Client.Photon.LoadBalancing.RoomInfo;
|
||||
using RoomOptions = ExitGames.Client.Photon.LoadBalancing.RoomOptions;
|
||||
|
||||
public class ButtonCreateLobby : ButtonOnClick {
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Multiplayer){
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
Debug.Log("Creating room");
|
||||
|
||||
var ro = new RoomOptions();
|
||||
ro.EmptyRoomTtl = 1000;
|
||||
ro.CleanupCacheOnLeave = true;
|
||||
ro.PlayerTtl = 500;
|
||||
ro.PublishUserId = false;
|
||||
ro.MaxPlayers = 2; // TODO: Expose this better
|
||||
|
||||
string roomCode = string.Empty;
|
||||
var roomList = NetworkManager.net.RoomInfoList.Keys.ToList();
|
||||
do {
|
||||
roomCode = string.Format("{0}{1}{2}{3}", RandomDigit(), RandomDigit(), RandomDigit(), RandomDigit());
|
||||
} while (roomList.Contains(roomCode));
|
||||
|
||||
LobbySetup.Instance.Setup();
|
||||
|
||||
var success = NetworkManager.net.OpCreateRoomWithProperties(roomCode, ro, ExitGames.Client.Photon.LoadBalancing.TypedLobby.Default);
|
||||
if (success) {
|
||||
Debug.Log("Room created");
|
||||
} else {
|
||||
Debug.Log("Failed to connect to room");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int RandomDigit() {
|
||||
return Random.Range(0, 10);
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonCreateLobby.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonCreateLobby.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f61e54fc64c3ac49bf99ba0c36fb95e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/RealCode/Menu/ButtonS/ButtonDisconnect.cs
Normal file
20
Assets/RealCode/Menu/ButtonS/ButtonDisconnect.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using ClientState = ExitGames.Client.Photon.LoadBalancing.ClientState;
|
||||
|
||||
public class ButtonDisconnect : ButtonOnClick {
|
||||
|
||||
public ClientState state => NetworkManager.net.State;
|
||||
public bool isDisconnected => state == ClientState.Disconnected || state == ClientState.PeerCreated;
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Multiplayer) {
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
NetworkManager.net.Service();
|
||||
NetworkManager.net.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonDisconnect.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonDisconnect.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bda166cb3696bbf44a36856632e823ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/RealCode/Menu/ButtonS/ButtonJoinLobby.cs
Normal file
27
Assets/RealCode/Menu/ButtonS/ButtonJoinLobby.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class ButtonJoinLobby : ButtonOnClick {
|
||||
|
||||
public TMP_InputField joinField;
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Multiplayer){
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
|
||||
LobbySetup.Instance.Setup();
|
||||
|
||||
var roomCode = joinField.text;
|
||||
Debug.LogFormat("Joining room '{0}'", roomCode);
|
||||
if (NetworkManager.net.OpJoinRoomWithProperties(roomCode)) {
|
||||
Debug.Log("Room joined");
|
||||
} else {
|
||||
Debug.Log("Couldn't join room");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonJoinLobby.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonJoinLobby.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dda82481bd0d3ab4c8e4d41c04475835
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/RealCode/Menu/ButtonS/ButtonLeaveLobby.cs
Normal file
14
Assets/RealCode/Menu/ButtonS/ButtonLeaveLobby.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonLeaveLobby : ButtonOnClick {
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Lobby) {
|
||||
GameTransition.Instance.state = GameState.ConnectionInProgress;
|
||||
NetworkManager.net.OpLeaveRoom();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonLeaveLobby.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonLeaveLobby.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0be7eb25514620d47bc3fbeff009a735
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
7
Assets/RealCode/Menu/ButtonS/ButtonOnClick.cs
Normal file
7
Assets/RealCode/Menu/ButtonS/ButtonOnClick.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ButtonOnClick : MonoBehaviour {
|
||||
public abstract void OnClick();
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonOnClick.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonOnClick.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 117c2cfc8bc6dd342bc6836cef88ab81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/RealCode/Menu/ButtonS/ButtonReadyUp.cs
Normal file
12
Assets/RealCode/Menu/ButtonS/ButtonReadyUp.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonReadyUp : ButtonOnClick {
|
||||
|
||||
public override void OnClick() {
|
||||
if (GameTransition.Instance.state == GameState.Lobby)
|
||||
PlayerProperties.lobbyStatus.SetLocal(!PlayerProperties.lobbyStatus.GetLocal());
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonReadyUp.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonReadyUp.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 16215d74378700844ae416c1de7db07d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Assets/RealCode/Menu/ButtonS/ButtonSelectRegionMaster.cs
Normal file
13
Assets/RealCode/Menu/ButtonS/ButtonSelectRegionMaster.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonSelectRegionMaster : ButtonOnClick {
|
||||
|
||||
public string region;
|
||||
|
||||
public override void OnClick() {
|
||||
ButtonConnectOnline.region = region;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c68f2d0c5c989ac40b86c84c3c241d71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/RealCode/Menu/ButtonS/ButtonSwitchLanguages.cs
Normal file
22
Assets/RealCode/Menu/ButtonS/ButtonSwitchLanguages.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonSwitchLanguages : ButtonOnClick {
|
||||
|
||||
private void Awake() {
|
||||
Localization.SelectedLanguage = (LocalizationLanguage)PlayerPrefs.GetInt("lang", 0);
|
||||
}
|
||||
|
||||
public override void OnClick() {
|
||||
Localization.SelectedLanguage = Localization.SelectedLanguage == LocalizationLanguage.English ? LocalizationLanguage.Japanese : LocalizationLanguage.English;
|
||||
PlayerPrefs.SetInt("lang", (int)Localization.SelectedLanguage);
|
||||
Localization.RebuildKeyDictionary();
|
||||
|
||||
var injector = FindObjectsOfType<LocalizationButtonInjector>();
|
||||
foreach(var i in injector){
|
||||
i.UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/ButtonSwitchLanguages.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/ButtonSwitchLanguages.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ecef12b4d0865c49920da1e92c82a87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
Assets/RealCode/Menu/ButtonS/MainMenuButton.cs
Normal file
66
Assets/RealCode/Menu/ButtonS/MainMenuButton.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class MainMenuButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IPointerDownHandler, IPointerUpHandler {
|
||||
|
||||
[Header("References")]
|
||||
public Image targetGraphic;
|
||||
public RectTransform targetTransform;
|
||||
public bool pointerSelected;
|
||||
public bool keyboardSelected;
|
||||
public bool pressed;
|
||||
|
||||
[Header("Style")]
|
||||
public Color baseColor;
|
||||
public Color selectedColor;
|
||||
public float baseWidth;
|
||||
public float selectedWidth;
|
||||
public Color tintColor;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData) {
|
||||
pointerSelected = true;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData) {
|
||||
pointerSelected = false;
|
||||
}
|
||||
|
||||
public void OnSelect(BaseEventData eventData) {
|
||||
keyboardSelected = true;
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData) {
|
||||
keyboardSelected = false;
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData) {
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData) {
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
void Start(){
|
||||
var b = GetComponent<Button>();
|
||||
if (b){
|
||||
b.onClick.RemoveAllListeners();
|
||||
|
||||
var click = GetComponent<ButtonOnClick>();
|
||||
if (click)
|
||||
b.onClick.AddListener(click.OnClick);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
var selected = keyboardSelected || pointerSelected;
|
||||
targetGraphic.color = (selected ? selectedColor : baseColor) * (pressed ? tintColor : Color.white);
|
||||
targetTransform.sizeDelta = new Vector2(selected ? selectedWidth : baseWidth, targetTransform.sizeDelta.y);
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/MainMenuButton.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/MainMenuButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bcbd46c9872ea004ba60441124c200df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/RealCode/Menu/ButtonS/NicknameField.cs
Normal file
21
Assets/RealCode/Menu/ButtonS/NicknameField.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class NicknameField : MonoBehaviour {
|
||||
|
||||
public TMP_InputField field;
|
||||
|
||||
private void Start() {
|
||||
field.text = PlayerProperties.GetPlayerNickname();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
var nn = field.text;
|
||||
if (PlayerProperties.localPlayer.NickName != nn){
|
||||
PlayerProperties.SetPlayerNickname(nn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/RealCode/Menu/ButtonS/NicknameField.cs.meta
Normal file
11
Assets/RealCode/Menu/ButtonS/NicknameField.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 666188a1504035c4f9f23134443092c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue