Commit e9ac14ea authored by You're Perfect 's avatar You're Perfect

online leaderboards and better input handling

parent d5a58ff1
......@@ -45,7 +45,7 @@ public class RodController : MonoBehaviour
{
if (transform.localScale.x < MinScale)
{
Vector3 newScale = new Vector3(transform.localScale.x + Speed, transform.localScale.y, transform.localScale.z);
Vector3 newScale = new Vector3(transform.localScale.x + Mathf.Abs(Speed*value), transform.localScale.y, transform.localScale.z);
transform.localScale = Vector3.Lerp(transform.localScale, newScale, Time.deltaTime * 2);
}
}
......@@ -53,7 +53,7 @@ public class RodController : MonoBehaviour
{
if (transform.localScale.x > MaxScale)
{
Vector3 newScale = new Vector3(transform.localScale.x - Speed, transform.localScale.y, transform.localScale.z);
Vector3 newScale = new Vector3(transform.localScale.x - Mathf.Abs(Speed*value), transform.localScale.y, transform.localScale.z);
transform.localScale = Vector3.Lerp(transform.localScale, newScale, Time.deltaTime * 2);
}
}
......
......@@ -3,23 +3,24 @@
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a9badd6626894dc459f92a91d0bd95fa, type: 3}
m_Name: GJAPISettings
m_EditorClassIdentifier:
gameId: 0
privateKey:
gameId: 360745
privateKey: 95546eb490cf104d4a267e50f79b4804
timeout: 10
autoPing: 1
autoSignInOutMessage: 0
signInMessage: Signed in as '{0}'
signOutMessage: Signed out
useCaching: 1
encryptionKey:
encryptionKey: "dId\xA7nOV5igzJ?4Y4"
logLevel: 1
secretTrophies:
autoConnect: 0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,7 +14,8 @@ public class DelayedHide : MonoBehaviour
public void Hide(float seconds)
{
StartCoroutine(HideHelper(seconds));
if(gameObject.activeInHierarchy)
StartCoroutine(HideHelper(seconds));
}
private IEnumerator HideHelper(float seconds)
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HighScoreCounter : MonoBehaviour
{
private void OnEnable()
{
GetComponent<Text>().text = PlayerPrefs.GetInt("HighScore", 0).ToString();
}
private void OnClear()
{
PlayerPrefs.SetInt("HighScore", 0);
GetComponent<Text>().text = "Cleared!";
}
}
fileFormatVersion: 2
guid: 1d65cc6a110dc174199104367188f54a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HighScorePanel : MonoBehaviour
{
public Button SubmitButton;
public InputField Initials;
// Start is called before the first frame update
void Start()
{
}
private void OnEnable()
{
Initials.text = PlayerPrefs.GetString("Initials", "");
}
// Update is called once per frame
void Update()
{
if (Application.internetReachability == NetworkReachability.NotReachable || Initials.text.Length < 1)
SubmitButton.gameObject.SetActive(false);
else
SubmitButton.gameObject.SetActive(true);
}
public void OnCancelClicked()
{
gameObject.SetActive(false);
}
}
fileFormatVersion: 2
guid: 5b3d7b74bb0879848aacc09fe3f11396
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 24f56c115bb92984e8debb8094662322
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5defaf6aa07d9ff4ab94dd745ae2204a
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b049c6404b67ffb42ae88062f1532aeb
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: c17d132bce5c8dc46942a3d7faf8116b
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,6 +5,8 @@
* See LICENSE files in the project root for full license information.
* See CONTRIBUTORS file in the project root for full list of contributors.
*/
using CnControls;
using GameJolt.API;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
......@@ -25,9 +27,15 @@ public class MainMenu : MonoBehaviour
public Sprite HumanIcon;
public Sprite NoneIcon;
public Button Player2Button;
public Button Player2TouchControls;
public SimpleJoystick Player2Stick;
public LineController Player2Line;
public RodController Player2Rod;
public HighScorePanel HighScorePanel;
public Image SpashScreen;
void OnEnable()
{
KeyboardControlsInfo.SetActive(true);
......@@ -37,11 +45,40 @@ public class MainMenu : MonoBehaviour
Player2Winner.gameObject.SetActive(true);
if (ScoreManager.Player1Score == ScoreManager.Player2Score && ScoreManager.Player1Score != 0)
Player2Winner.gameObject.SetActive(true);
int oldScore = PlayerPrefs.GetInt("HighScore", 0);
if(Player1Winner.gameObject.activeInHierarchy && ScoreManager.Player1Score > oldScore)
{
if (GameJoltAPI.Instance.HasSignedInUser)
{
if(Application.internetReachability != NetworkReachability.NotReachable)
GameJolt.API.Scores.Add(ScoreManager.Player1Score, ScoreManager.Player1Score+" Points");
PlayerPrefs.SetInt("HighScore", ScoreManager.Player1Score);
PlayerPrefs.Save();
}
else
{
PlayerPrefs.SetInt("HighScore", ScoreManager.Player1Score);
PlayerPrefs.Save();
if (Application.internetReachability != NetworkReachability.NotReachable)
HighScorePanel.gameObject.SetActive(true);
}
}
else if(Player2Winner.gameObject.activeInHierarchy && !SoundManager.Player2AI && ScoreManager.Player2Score > oldScore)
{
PlayerPrefs.SetInt("HighScore", ScoreManager.Player2Score);
PlayerPrefs.Save();
if (Application.internetReachability != NetworkReachability.NotReachable)
HighScorePanel.gameObject.SetActive(true);
}
ScoreManager.StopTimer();
MusicPlayer.Stop();
MusicPlayer.clip = MainMenuMusic;
MusicPlayer.loop = true;
MusicPlayer.Play();
SpashScreen.GetComponent<DelayedHide>().Hide(2f);
}
IEnumerator PlayGameMusicAndClose()
......@@ -53,7 +90,7 @@ public class MainMenu : MonoBehaviour
MusicPlayer.Play();
InfoBar.SetActive(true);
KeyboardControlsInfo.SetActive(true);
KeyboardControlsInfo.GetComponent<DelayedHide>().Hide(3f);
KeyboardControlsInfo.GetComponent<DelayedHide>().Hide(0f);
ScoreManager.Reset();
ScoreManager.StartTimer();
Player1Winner.gameObject.SetActive(false);
......@@ -83,12 +120,15 @@ public class MainMenu : MonoBehaviour
Player2Button.image.sprite = RobotIcon;
Player2Line.HumanControlled = false;
Player2Rod.HumanControlled = false;
Player2TouchControls.gameObject.SetActive(false);
Player2Stick.gameObject.SetActive(false);
}
else
{
Player2Button.image.sprite = HumanIcon;
Player2Line.HumanControlled = true;
Player2Rod.HumanControlled = true;
Player2TouchControls.gameObject.SetActive(true);
}
}
......
using GameJolt.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerSignIn : MonoBehaviour
{
public void OnClick()
{
GameJoltUI.Instance.ShowSignIn();
}
}
fileFormatVersion: 2
guid: 03197db3959ed584d84b700ac1fa3898
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using GameJolt.API;
using GameJolt.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SubmitHighScore : MonoBehaviour
{
public InputField Initials;
public HighScorePanel Panel;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public string NaughtyFilter(string input)
{
string[] words = { "fuck","shit","damn","cunt","asshole","clit","cock","dick","crap","piss","bitch","choad","twat","fag" };
foreach(string word in words)
{
if (input.ToLower().Contains(word))
return "Catherine Irkalla";
}
return input;
}
public void OnClick()
{
int score = PlayerPrefs.GetInt("HighScore", 0);
string name = NaughtyFilter(Initials.text);
if (score != 0)
{
GameJolt.API.Scores.Add(score, score + " Points", name);
PlayerPrefs.SetString("Initials", name);
StartCoroutine(OnClickHelper(1f));
}
}
public IEnumerator OnClickHelper(float delay)
{
yield return new WaitForSeconds(delay);
GameJoltUI.Instance.ShowLeaderboards();
Panel.gameObject.SetActive(false);
}
}
fileFormatVersion: 2
guid: 210357ffe3fd1ff4a9d758efc7d1ef2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using CnControls;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TouchControlsButton : MonoBehaviour
{
public bool Enabled;
public Sprite KeyboardIcon;
public Sprite TouchscreenIcon;
public Sprite GamepadIcon;
public Text KeyboardText;
public SimpleJoystick Joystick;
Button AsButton;
private void Start()
{
Enabled = (Input.touchSupported && Application.platform != RuntimePlatform.WebGLPlayer);
AsButton = GetComponent<Button>();
}
public void OnClick()
{
Enabled = !Enabled;
}
void Update()
{
if(Enabled)
{
AsButton.image.sprite = TouchscreenIcon;
Joystick.gameObject.SetActive(true);
KeyboardText.gameObject.SetActive(false);
}
else
{
AsButton.image.sprite = KeyboardIcon;
Joystick.gameObject.SetActive(false);
KeyboardText.gameObject.SetActive(true);
}
}
}
fileFormatVersion: 2
guid: 41b94cca33e94164789ab5769ca143ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5e28b66ccb8a9e644940bee571c5d9f6
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 7b54a485c328d4042bea418e6a64696a
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment