1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-22 00:14:18 +00:00

Some android stuff

This commit is contained in:
Steffo 2019-10-15 01:36:48 +02:00
parent ce2ac19add
commit 918cefba65
9 changed files with 3560 additions and 47 deletions

View file

@ -7,30 +7,82 @@ public class CameraPan : MonoBehaviour
{
public string axisName;
protected Vector3? lastMousePosition;
protected Vector3? lastWorldPosition;
protected GameController gameController;
protected void Awake() {
protected float panWasPressedFor;
protected float? previousDistance;
protected void Awake()
{
gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
}
private void Start() {
lastMousePosition = null;
private void Start()
{
lastWorldPosition = null;
if (Application.platform == RuntimePlatform.Android)
{
Input.simulateMouseWithTouches = false;
}
panWasPressedFor = 0f;
}
private void Update()
{
bool panIsPressed = false;
switch (Application.platform)
{
case RuntimePlatform.Android:
panIsPressed = Input.touchCount >= 2;
break;
default:
panIsPressed = Input.GetAxisRaw(axisName) != 0f;
break;
}
private void Update() {
bool panIsPressed = Input.GetAxisRaw(axisName) != 0f;
Vector3? currentMousePosition = null;
if(panIsPressed) {
currentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if(lastMousePosition.HasValue) {
Vector3 positionDelta = lastMousePosition.Value - currentMousePosition.Value;
panWasPressedFor += Time.deltaTime;
}
else {
panWasPressedFor = 0f;
}
if (Application.platform != RuntimePlatform.Android && panIsPressed || panWasPressedFor >= 0.2f)
{
float currentDistance;
Vector2 currentScreenPosition;
if (Application.platform == RuntimePlatform.Android)
{
Touch touchA = Input.GetTouch(0);
Touch touchB = Input.GetTouch(1);
Vector2 touchPositionTotal = touchA.position + touchB.position;
currentScreenPosition = new Vector2(touchPositionTotal.x / Input.touchCount, touchPositionTotal.y / Input.touchCount);
}
else
{
currentScreenPosition = Input.mousePosition;
}
Vector3 currentWorldPosition = Camera.main.ScreenToWorldPoint(currentScreenPosition);
if (lastWorldPosition.HasValue)
{
Vector3 positionDelta = lastWorldPosition.Value - currentWorldPosition;
Camera.main.transform.position += positionDelta;
currentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//Don't vibrate the camera!
currentWorldPosition = Camera.main.ScreenToWorldPoint(currentScreenPosition);
}
lastWorldPosition = currentWorldPosition;
}
lastMousePosition = currentMousePosition;
else {
lastWorldPosition = null;
}
if(Input.GetAxisRaw("ResetCamera") > 0) {
if(gameController.blackHole != null) {
Camera.main.transform.position = new Vector3(gameController.blackHole.transform.position.x,

View file

@ -10,28 +10,23 @@ public class SpawnOnMouseClick : MonoBehaviour
public int spawnCount = 1;
public float appliedForce = 0.1f;
protected Camera camera;
protected GameController gameController;
protected void Awake() {
gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
camera = GetComponent<Camera>();
}
protected Vector3 GetWorldMousePosition() {
return Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
protected void Update()
{
if(!gameController.upgradePanel.gameObject.activeSelf && Input.GetMouseButtonDown(mouseButton)) {
Vector3 mousePosition = GetWorldMousePosition();
protected void SpawnAtPosition(Vector3 position) {
if(gameController.blackHole == null) {
gameController.blackHole = Instantiate(gameController.blackHolePrefab, new Vector3(mousePosition.x, mousePosition.y, 0f), Quaternion.identity).GetComponent<BlackHole>();
gameController.blackHole = Instantiate(gameController.blackHolePrefab, new Vector3(position.x, position.y, 0f), Quaternion.identity).GetComponent<BlackHole>();
gameController.tutorial.Step2();
gameController.musicManager.UpdateLayers(-1);
}
else {
for(int i = 0; i < spawnCount; i++) {
GameObject particleObject = Instantiate(gameController.particlePrefab, new Vector3(mousePosition.x, mousePosition.y, 0f), Quaternion.identity);
GameObject particleObject = Instantiate(gameController.particlePrefab, new Vector3(position.x, position.y, 0f), Quaternion.identity);
Particle particle = particleObject.GetComponent<Particle>();
particle.Tier = spawnedTier;
Vector2 direction = new Vector2(Random.value - 0.5f, Random.value - 0.5f).normalized;
@ -39,5 +34,21 @@ public class SpawnOnMouseClick : MonoBehaviour
}
}
}
protected void Update()
{
bool canSpawn = !gameController.upgradePanel.gameObject.activeSelf;
if(Application.platform == RuntimePlatform.Android) {
foreach(Touch touch in Input.touches) {
if(touch.phase == TouchPhase.Began) {
SpawnAtPosition(camera.ScreenToWorldPoint(touch.position));
}
}
}
else {
if(Input.GetMouseButtonDown(mouseButton)) {
SpawnAtPosition(camera.ScreenToWorldPoint(Input.mousePosition));
}
}
}
}

View file

@ -13,7 +13,7 @@ public class TempUpgradesToggler : MonoBehaviour
protected void Update()
{
if(gameController.blackHole != null) {
if(Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Escape)) {
if(Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Menu)) {
gameController.upgradePanel.gameObject.SetActive(!gameController.upgradePanel.gameObject.activeSelf);
}
}

View file

@ -14,12 +14,22 @@ public class Tutorial : MonoBehaviour {
}
public void Step1() {
if(Application.platform == RuntimePlatform.Android) {
gameController.messageBox.Write("Touch somewhere to spawn your Black Hole!", null);
}
else {
gameController.messageBox.Write("Press Left Mouse Button to spawn your Black Hole!", null);
}
}
public void Step2() {
if(Application.platform == RuntimePlatform.Android) {
gameController.messageBox.Write("Tap outside the Black Hole to spawn a Particle!", Step3);
}
else {
gameController.messageBox.Write("Click outside the Black Hole to spawn a Particle!", Step3);
}
}
public void Step3() {
gameController.messageBox.Write("6 Particles of the same size merge into a bigger one!", Step4);
@ -30,20 +40,35 @@ public class Tutorial : MonoBehaviour {
}
public void Step45() {
if(Application.platform == RuntimePlatform.Android) {
gameController.messageBox.Write("Zoom in and out by pinching the screen!", Step5);
}
else {
gameController.messageBox.Write("Zoom in and out with the Mouse Scroll Wheel!", Step5);
}
}
public void Step5() {
if(Application.platform == RuntimePlatform.Android) {
gameController.messageBox.Write("Pan the camera by dragging with two fingers!", Step6);
}
else {
gameController.messageBox.Write("Pan the camera with Middle Mouse Button (or Space)!", Step6);
}
}
public void Step6() {
gameController.messageBox.Write("Larger Particles automatically generate smaller particles!", Step7);
}
public void Step7() {
if(Application.platform == RuntimePlatform.Android) {
gameController.messageBox.Write("You can press Back to buy upgrades at my Mass Shop!", Step8);
}
else {
gameController.messageBox.Write("You can press Tab to buy upgrades at my Mass Shop!", Step8);
}
}
public void Step8() {
gameController.messageBox.Write("Grow the Black Hole the most you can!", Step9);

3316
Assets/Scenes/Android.unity Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b1bf78ac5430fa3498cc6271e4cfc4e8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -5,9 +5,12 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/Scenes/Game.unity
guid: 2cda990e2423bbf4892e6590ba056729
- enabled: 1
path: Assets/Scenes/Android.unity
guid: b1bf78ac5430fa3498cc6271e4cfc4e8
m_configObjects:
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: b3c648ee69249814bad890a2d67c9db8,
type: 2}

View file

@ -35,6 +35,7 @@ GraphicsSettings:
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 4800000, guid: be7d228df3bb92446b8050571922dbac, type: 3}
- {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}

View file

@ -41,7 +41,7 @@ PlayerSettings:
height: 1
m_SplashScreenLogos:
- logo: {fileID: 21300000, guid: fd84a9b22c49ee64e89b5774aafff087, type: 3}
duration: 2
duration: 4
m_VirtualRealitySplashScreen: {fileID: 0}
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1024
@ -120,7 +120,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 0
bundleVersion: 1.1
bundleVersion: 1.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
@ -280,11 +280,109 @@ PlayerSettings:
- m_BuildTarget:
m_Icons:
- serializedVersion: 2
m_Icon: {fileID: 0}
m_Icon: {fileID: 2800000, guid: 701648e6e9c182d47a63632d3e686f5b, type: 3}
m_Width: 128
m_Height: 128
m_Kind: 0
m_BuildTargetPlatformIcons: []
m_BuildTargetPlatformIcons:
- m_BuildTarget: Android
m_Icons:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 432
m_Height: 432
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 324
m_Height: 324
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 216
m_Height: 216
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 162
m_Height: 162
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 108
m_Height: 108
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 81
m_Height: 81
m_Kind: 2
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 0}
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
m_BuildTargetBatching: []
m_BuildTargetGraphicsJobs:
- m_BuildTarget: MacStandaloneSupport