Alpha commit

This commit is contained in:
Elias Virta
2020-04-30 00:04:48 +03:00
parent b299afc245
commit dc95ad3746
92 changed files with 19094 additions and 173 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e74af6472dbc62c448e95b75ea6bf889
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using UnityEngine;
using UnityEngine.UI;
public class DebugRespawn : MonoBehaviour
{
public Button button;
private GameObject player;
private Rigidbody2D rbody;
private GameObject camera;
void Start()
{
camera = GameObject.FindWithTag("MainCamera");
player = GameObject.FindWithTag("Player");
rbody = player.GetComponent<Rigidbody2D>();
button.onClick.AddListener(Respawn);
}
void Respawn()
{
rbody.velocity = new Vector3(0, 0, 0);
player.transform.position = new Vector3(-7, -2, -0.16f);
camera.transform.position = new Vector3(0.9002959f, 2.056212f, -32.28906f);
//CameraController.storedPosition = 0f;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 198b158ebd15b4b4fb0620187b2abe75
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEngine.UI;
public class Valueprint : MonoBehaviour
{
public Text text;
public PlayerController playerController;
double charger;
// Start is called before the first frame update
void Start()
{
charger = playerController.charger;
}
// Update is called once per frame
void Update()
{
charger = System.Math.Round(playerController.charger,1);
text.text = charger.ToString();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 851757fe5cf49ba408a082927c8e5487
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -9,12 +9,20 @@ public class ChangeScene : MonoBehaviour
// Start is called before the first frame update
void Start()
{
StartCoroutine(ChangeSceneToGame());
if(SceneManager.GetActiveScene().buildIndex == 1)
{
StartCoroutine(ChangeSceneToGame(2));
}
if(SceneManager.GetActiveScene().buildIndex == 3)
{
StartCoroutine(ChangeSceneToGame(0));
}
}
private IEnumerator ChangeSceneToGame()
private IEnumerator ChangeSceneToGame(int index)
{
yield return new WaitForSeconds(5);
SceneManager.LoadScene(2);
SceneManager.LoadScene(index);
}
}

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public static Rigidbody2D rbody;
public static float movementSpeed;
public static float jumpForce;
void Start()
{
rbody = GameObject.FindWithTag("Player").GetComponent<Rigidbody2D>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a4eea1046a966345b269824a75b0af8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimator : MonoBehaviour
{
Animator _animator;
private Rigidbody2D rbody;
PlayerController playerController;
public AudioSource audioSource;
public AudioClip jumpSound;
public AudioClip landSound;
void Start()
{
audioSource = GetComponent<AudioSource>();
GameObject player = GameObject.Find("Player");
rbody = GetComponent<Rigidbody2D>();
_animator = GetComponent<Animator>();
playerController = player.GetComponent<PlayerController>();
}
void Update()
{
if (playerController.isGrounded && Input.GetAxis("Horizontal") < 0.5 || Input.GetAxis("Horizontal") > -0.5 && playerController.isCharging == false)
{
_animator.SetBool("is_moving", false);
_animator.SetBool("is_grounded", true);
_animator.SetBool("bigfall", false);
}
if (playerController.isGrounded && Input.GetAxis("Horizontal") != 0 && playerController.isCharging == false)
{
_animator.SetBool("is_moving", true);
_animator.SetBool("is_grounded", true);
_animator.SetBool("bigfall", false);
}
if (!playerController.isGrounded)
{
_animator.SetBool("is_grounded", false);
StartCoroutine("BigFall");
}
if(playerController.isCharging == true)
{
_animator.SetBool("is_charging", true);
}
else
{
_animator.SetBool("is_charging", false);
}
}
IEnumerator BigFall()
{
yield return new WaitForSeconds(1);
if(_animator.GetBool("is_grounded") == true)
{
_animator.SetBool("bigfall", true);
}
}
public void PlaySound(AudioClip sound)
{
audioSource.PlayOneShot(sound);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 64c17a687e4409b4eb9478560b908642
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -2,73 +2,98 @@
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
public class PlayerController : Player
{
private Rigidbody2D rbody;
private float moveInput;
private float movementSpeed;
private float jumpForce;
private float moveInput;
public bool isGrounded;
public Transform feetPos;
public LayerMask whatIsGround;
public float checkRadius;
private float charger;
private bool discharge;
private bool isCharging;
private SpriteRenderer spriteRenderer;
public int maxCharge;
//public RaycastHit2D hit;
//public Ray ray;
void Start()
public float movementSpeed;
public float jumpForce;
private bool _isGrounded;
public bool isGrounded { get { return _isGrounded; } set { _isGrounded = value; } }
public Transform feetPos;
public LayerMask whatIsGround;
public Transform checkRadius;
private double _charger;
public double charger
{
get { return _charger; }
set { _charger = value; }
}
public float chargeMultiplier;
public bool isCharging;
void Start()
{
isCharging = false;
Player.movementSpeed = movementSpeed;
Player.jumpForce = jumpForce;
spriteRenderer = GetComponent<SpriteRenderer>();
}
void FixedUpdate()
{
Player.rbody.velocity += new Vector2(0, -0.75f);
//ray.origin = feetPos.position;
//ray.direction = Vector2.down;
//RaycastHit2D hit = Physics2D.Raycast(origin: transform.position, direction: -Vector2.up, layerMask: whatIsGround, distance: 100);
}
void Update()
{
//isGrounded = hit.collider == null ? true : false;
isGrounded = Physics2D.OverlapArea(feetPos.position, checkRadius.position, whatIsGround); //return true for overlap
moveInput = Input.GetAxis("Horizontal");
if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } //temporary exit measure
if(_isGrounded && Input.GetAxis("Horizontal") != -1 && Input.GetAxis("Horizontal") != 1) { Player.rbody.velocity = new Vector2(0, Player.rbody.velocity.y); }
if (Input.GetAxis("Horizontal") > 0) { spriteRenderer.flipX = false; }
if (Input.GetAxis("Horizontal") < 0) { spriteRenderer.flipX = true; }
if (!isCharging && _isGrounded)
{
rbody.velocity = new Vector2(moveInput * movementSpeed, rbody.velocity.y);
}
if (_isGrounded && Input.GetButton("Jump") && _charger < maxCharge)
{
if (_charger > maxCharge) { _charger = maxCharge; }
else { _charger += Time.deltaTime * chargeMultiplier; }
rbody.velocity = new Vector2(0, rbody.velocity.y);
isCharging = true;
}
if (isCharging && !Input.GetButton("Jump"))
{
Jump(moveInput, (float)System.Math.Round(_charger, 1));
}
}
void Jump(float direction, float jumpCharge)
{
Debug.Log(jumpCharge);
Player.rbody.velocity = new Vector2((8 - (float)charger) * direction, jumpForce * jumpCharge);
_charger = 0f;
isCharging = false;
}
void OnCollisionEnter(Collision collision)
{
rbody = GetComponent<Rigidbody2D>();
isCharging = false;
}
void Update()
{
if (Input.GetKey(KeyCode.Space))
if (!_isGrounded && collision.gameObject.layer == LayerMask.NameToLayer("Wall"))
{
charger += Time.deltaTime;
isCharging = true;
}
if (Input.GetKeyUp(KeyCode.Space))
{
discharge = true;
isCharging = false;
rbody.velocity = new Vector2(rbody.velocity.x * -1, rbody.velocity.y);
}
}
void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);
if (isGrounded)
{
moveInput = Input.GetAxis("Horizontal");
}
rbody.velocity = new Vector2(moveInput * movementSpeed, rbody.velocity.y);
// Stops movement when space is pressed
if (isCharging && isGrounded)
{
movementSpeed = 0;
}
else
{
movementSpeed = 8;
}
if (discharge && isGrounded)
{
// Charges the jump
jumpForce = 10 * charger;
if (jumpForce > 10)
{
jumpForce = 10;
}
rbody.velocity = new Vector2(rbody.velocity.x, jumpForce);
// Reset charge and set discharge to false
charger = 0f;
discharge = false;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f66787d8f0911b04caee289fd263ff18
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Permissions;
using UnityEngine;
public class CameraController : MonoBehaviour
{
GameObject player;
public GameObject camera;
public static float storedPosition;
//Every time player height changes by 10, adjust depending on whether it was decreased or increased
void Start()
{
player = GameObject.FindWithTag("Player");
camera = GameObject.FindWithTag("MainCamera");
storedPosition = player.transform.position.y;
UnityEngine.Debug.Log(storedPosition);
}
void Update()
{
if((player.transform.position.y - storedPosition) > 10)
{
storedPosition += 10;
camera.transform.position = new Vector3(camera.transform.position.x, camera.transform.position.y + 10, camera.transform.position.z);
}
if ((storedPosition - player.transform.position.y) > 2)
{
storedPosition -= 10;
camera.transform.position = new Vector3(camera.transform.position.x, camera.transform.position.y - 10, camera.transform.position.z);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: beda4e26be9780042bb832dbb6864948
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Winner : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Player")
{
SceneManager.LoadScene(3);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 64b4e8d5b75907d4da0e9117fee142b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b34d7ae96c5298c44849aece66c6a2e6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Permissions;
using UnityEngine;
public class legacy_CameraController : MonoBehaviour
{
GameObject player;
GameObject[] cameras;
int camIterator;
float storedPosition;
//Every time player height changes by 10, adjust depending on whether it was decreased or increased
void Start()
{
player = GameObject.FindWithTag("Player");
cameras = GameObject.FindGameObjectsWithTag("MainCamera");
foreach(GameObject g in cameras)
{
if(g.name == "Cam0") { continue; }
UnityEngine.Debug.Log(g);
g.SetActive(false);
}
camIterator = 0;
storedPosition = player.transform.position.y;
UnityEngine.Debug.Log(storedPosition);
}
// Update is called once per frame
void Update()
{
if((player.transform.position.y - storedPosition) > 10)
{
storedPosition += 9;
camIterator += 1;
cameras[camIterator].SetActive(true);
cameras[camIterator - 1].SetActive(false);
}
if ((storedPosition - player.transform.position.y) > 2)
{
storedPosition -= 9;
camIterator -= 1;
cameras[camIterator].SetActive(true);
cameras[camIterator + 1].SetActive(false);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac9afa7358b55e443b298bc32c4b4882
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: