Initial commit

This commit is contained in:
2021-03-18 11:56:10 -04:00
commit 44f201edd8
1582 changed files with 472891 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class FinishLevel : MonoBehaviour
{
public GameObject levelMusic;
public AudioSource levelComplete;
public GameObject levelTimer;
public GameObject timeLeft;
public GameObject theScore;
public GameObject totalScore;
public GameObject fadeOut;
public int timeCalc;
public int scoreCalc;
public int totalScored;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag != "Player") return;
GetComponent<BoxCollider>().enabled = false;
levelMusic.SetActive(false);
levelTimer.SetActive(false);
levelComplete.Play();
StartCoroutine(CalculateScore());
}
IEnumerator CalculateScore()
{
// Stop the spawning of meteors across the whole level
MeteorZone.spawnMeteors = false;
// Reward the player with extra points for the time left on the clock
timeCalc = GlobalTimer.extendScore * 100;
totalScored = GlobalScore.currentScore + timeCalc;
// SReed33
// Changed high score system slightly to show best score for entire playthroughs
// Store this level score in playerprefs
PlayerPrefs.SetInt("LevelScore", totalScored);
// Store the total for this playthrough in playerprefs
PlayerPrefs.SetInt("RunningTotal", PlayerPrefs.GetInt("RunningTotal") + totalScored);
// Check if we beat the high score with this playthrough
print("RunningTotal: " + PlayerPrefs.GetInt("RunningTotal"));
if (PlayerPrefs.GetInt("BestScore") < PlayerPrefs.GetInt("RunningTotal"))
{
PlayerPrefs.SetInt("BestScore", PlayerPrefs.GetInt("RunningTotal"));
}
// Show the bonus applied for time remaining
timeLeft.SetActive(true);
SetChildText(timeLeft, "Time Left: " + GlobalTimer.extendScore + " x100");
yield return new WaitForSeconds(1);
// Give UnityChan 1 second to settle position, then freeze input
// + Also rotates camera to frontView for victory screen
UnityChan.UnityChanControlScriptWithRgidBody.controlsActive = false;
// Show the score from collectables gathered on this level
theScore.SetActive(true);
SetChildText(theScore, "Score: " + GlobalScore.currentScore);
yield return new WaitForSeconds(1);
// Show the calculated total score
totalScore.SetActive(true);
SetChildText(totalScore, "Total Score: " + totalScored);
yield return new WaitForSeconds(3);
// Activate the fadeOut gameobject to fade to next level
fadeOut.SetActive(true);
yield return new WaitForSeconds(2);
SceneManager.LoadScene(Level.nextLevel);
}
// Helper function to set the text of multiple fields that share a parent
void SetChildText(GameObject parent, string text)
{
foreach (Text t in parent.GetComponentsInChildren<Text>())
{
t.text = text;
}
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GemPickup : MonoBehaviour
{
public GameObject scoreBox;
public AudioSource collectSound;
public int gemValue;
public int rotateSpeed = 2;
void Update()
{
// Sreed33
// Had to change this to Space.Self to rotate gems correctly on level2
// + Gems on walls an ceilngs were spinning on wrong axis
transform.Rotate(0, rotateSpeed * Time.timeScale, 0, Space.Self);
}
void OnTriggerEnter(Collider other)
{
// If the object is anything other than a player, do nothing
if (!other.CompareTag("Player")) return;
GlobalScore.currentScore += gemValue;
collectSound.Play();
Destroy(gameObject);
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalScore : MonoBehaviour
{
public GameObject scoreBox;
public static int currentScore;
public int internalScore;
void Update()
{
internalScore = currentScore;
foreach (Text t in scoreBox.GetComponentsInChildren<Text>()) t.text = "" + internalScore;
}
}

View File

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

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalTimer : MonoBehaviour
{
public GameObject timeDisplay01;
public GameObject timeDisplay02;
public bool isTakingTime = false;
public int theSeconds = 150;
public static int extendScore;
void Update()
{
extendScore = theSeconds;
if (isTakingTime == false)
{
StartCoroutine(SubtractSecond());
}
}
IEnumerator SubtractSecond()
{
isTakingTime = true;
theSeconds -= 1;
timeDisplay01.GetComponent<Text>().text = "" + theSeconds;
timeDisplay02.GetComponent<Text>().text = "" + theSeconds;
yield return new WaitForSeconds(1);
isTakingTime = false;
}
}

View File

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

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelDeath : MonoBehaviour
{
public GameObject youFell;
public GameObject levelAudio;
public GameObject fadeOut;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag != "Player") return;
StartCoroutine(YouFellOff());
}
IEnumerator YouFellOff()
{
youFell.SetActive(true);
levelAudio.SetActive(false);
yield return new WaitForSeconds(2);
fadeOut.SetActive(true);
yield return new WaitForSeconds(1);
SceneManager.LoadScene(Level.thisLevel);
}
}

View File

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

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MainMenuFunction : MonoBehaviour
{
public AudioSource buttonPress;
public GameObject bestScoreDisplay;
public int bestScore;
void Start()
{
Cursor.visible = true;
// Reset the running total used to track score between levels
PlayerPrefs.SetInt("RunningTotal", 0);
// Update the best score shown on the main menu
bestScore = PlayerPrefs.GetInt("BestScore");
bestScoreDisplay.GetComponent<Text>().text = "Best: " + bestScore;
// Set the first level to be started when Play Game button is clicked
Level.nextLevel = "Level1";
}
// Called by button click actions
public void PlayGame()
{
buttonPress.Play();
SceneManager.LoadScene(Level.nextLevel);
}
// Called by button click actions
public void QuitGame()
{
buttonPress.Play();
Application.Quit();
}
// Called by button click actions
public void PlayCreds()
{
buttonPress.Play();
SceneManager.LoadScene("Credits");
}
}

View File

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

View File

@@ -0,0 +1,81 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseGame : MonoBehaviour
{
public bool gamePaused = false;
public AudioSource levelMusic;
public GameObject pauseMenu;
public AudioSource pauseJingle;
public AudioSource buttonClickAudio;
public Level levelScript;
void Update()
{
// If we pause the game while fading in, disable fadeIn
if (gamePaused && levelScript.fadeIn.activeSelf)
{
levelScript.fadeIn.SetActive(false);
}
// Toggle pause menu
if (Input.GetButtonDown("Cancel"))
{
if (gamePaused == false)
{
Cursor.visible = true;
pauseJingle.Play();
gamePaused = true;
levelMusic.Pause();
pauseMenu.SetActive(true);
// Stop game movement by setting timeScale = 0
Time.timeScale = 0;
}
else
{
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
// Resume game movement
Time.timeScale = 1;
}
}
}
public void ResumeGame()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
}
public void RestartLevel()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
SceneManager.LoadScene(Level.thisLevel);
}
public void QuitToMenu()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
Level.nextLevel = "MainMenu";
SceneManager.LoadScene(Level.nextLevel);
}
}

View File

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

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformGripper : MonoBehaviour
{
// void OnCollisionStay(Collision other) {
// print("DA");
// if (other.gameObject.tag != "Player") return;
// if (other.transform.parent != this.transform.parent) {
// other.transform.SetParent(this.transform.parent);
// }
// }
// void OnCollisionExit() {
// GameObject.FindGameObjectWithTag("Player").transform.parent = GameObject.Find("##### PLAYER #####").transform;
// }
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag != "Player") return;
if (other.transform.parent != this.transform.parent)
{
other.transform.SetParent(this.transform.parent);
}
}
void OnTriggerExit()
{
GameObject.FindGameObjectWithTag("Player").transform.parent = GameObject.Find("##### PLAYER #####").transform;
}
}

View File

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

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateSky : MonoBehaviour
{
public float roateSpeed = 1.2f;
void Update()
{
RenderSettings.skybox.SetFloat("_Rotation", Time.time * roateSpeed);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,139 @@
//
// Unityちゃん用の三人称カメラ
//
// 2013/06/07 N.Kobyasahi
//
using UnityEngine;
using System.Collections;
namespace UnityChan
{
public class ThirdPersonCamera : MonoBehaviour
{
public float smooth = 3f; // カメラモーションのスムーズ化用変数
Transform standardPos; // the usual position for the camera, specified by a transform in the game
Transform frontPos; // Front Camera locater
Transform jumpPos; // Jump Camera locater
// Sreed333
// Added this for additional lookAt position when holding RMB
Transform lookAt; // lookAt position
// Sreed33
// Removed this from logic to simplify code
// bool bQuickSwitch = false; //Change Camera Position Quickly
void Start()
{
// 各参照の初期化
standardPos = GameObject.Find("CamPos").transform;
if (GameObject.Find("FrontPos"))
frontPos = GameObject.Find("FrontPos").transform;
if (GameObject.Find("JumpPos"))
jumpPos = GameObject.Find("JumpPos").transform;
// Sreed33
// Added a position for a top-down view on the player
if (GameObject.Find("LookAtPos"))
lookAt = GameObject.Find("LookAtPos").transform;
//カメラをスタートする
transform.position = standardPos.position;
transform.forward = standardPos.forward;
}
void FixedUpdate() // このカメラ切り替えはFixedUpdate()内でないと正常に動かない
{
// Sreed33
// Make sure player controls are enabled
if (!UnityChan.UnityChanControlScriptWithRgidBody.controlsActive) return;
if (Input.GetButton("Fire1"))
{ // left Ctlr
// Change Front Camera
setCameraPositionFrontView();
}
else if (Input.GetButton("Fire2"))
{ //Alt
// Sreed33
// Call my function instead of setPositionJumpView
//setCameraPositionJumpView();
setLookAtView();
}
else
{
// return the camera to standard position and direction
setCameraPositionNormalView();
}
}
void setCameraPositionNormalView()
{
// if (bQuickSwitch == false) {
// the camera to standard position and direction
// print("False")
transform.position = Vector3.Lerp(transform.position, standardPos.position, Time.fixedDeltaTime * smooth);
// Sreed33
// Replace commented Vector3.Lerp with Quaternion.Lerp to rotate camera correctly when moving through portals
// + I did something similar in all the setCameraPosition functions
transform.rotation = Quaternion.Lerp(transform.rotation, standardPos.rotation, Time.fixedDeltaTime * smooth);
// transform.forward = Vector3.Lerp (transform.forward, standardPos.forward, Time.fixedDeltaTime * smooth);
// } else {
// the camera to standard position and direction / Quick Change
// transform.position = standardPos.position;
// transform.forward = standardPos.forward;
// bQuickSwitch = false;
// }
}
void setCameraPositionFrontView()
{
// Change Front Camera
// bQuickSwitch = true;
// Sreed33
// Replace commented frontPos.forward with Quaternion.Lerp to rotate camera according to gravity direction
transform.position = Vector3.Lerp(transform.position, frontPos.position, Time.fixedDeltaTime * smooth);
// transform.position = frontPos.position;
transform.rotation = Quaternion.Lerp(transform.rotation, frontPos.rotation, Time.fixedDeltaTime * smooth);
// transform.forward = frontPos.forward;
}
// Sreed33
// This function is no longer in use anywhere
void setCameraPositionJumpView()
{
// Change Jump Camera
// bQuickSwitch = false;
transform.position = Vector3.Lerp(transform.position, jumpPos.position, Time.fixedDeltaTime * smooth);
transform.forward = Vector3.Lerp(transform.forward, jumpPos.forward, Time.fixedDeltaTime * smooth);
}
// Sreed33
// Added function to change to top-down camera view
// Makes it easier to avoid meteors when there is a lot of them
void setLookAtView()
{
transform.position = Vector3.Lerp(transform.position, lookAt.position, Time.fixedDeltaTime * smooth);
transform.rotation = Quaternion.Lerp(transform.rotation, lookAt.rotation, Time.fixedDeltaTime * smooth);
}
}
}

View File

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

View File

@@ -0,0 +1,226 @@
//
// Mecanimのアニメーションデータが、原点で移動しない場合の Rigidbody付きコントローラ
// サンプル
// 2014/03/13 N.Kobyasahi
//
using UnityEngine;
using System.Collections;
namespace UnityChan
{
// 必要なコンポーネントの列記
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(Rigidbody))]
public class UnityChanControlScriptWithRgidBody : MonoBehaviour
{
// SReed33
// Static bool that controls freezing player input
public static bool controlsActive = true;
public float animSpeed = 1.5f; // アニメーション再生速度設定
public float lookSmoother = 3.0f; // a smoothing setting for camera motion
public bool useCurves = true; // Mecanimでカーブ調整を使うか設定する
// このスイッチが入っていないとカーブは使われない
public float useCurvesHeight = 0.5f; // カーブ補正の有効高さ(地面をすり抜けやすい時には大きくする)
// 以下キャラクターコントローラ用パラメタ
// 前進速度
public float forwardSpeed = 7.0f;
// 後退速度
public float backwardSpeed = 2.0f;
// 旋回速度
public float rotateSpeed = 2.0f;
// ジャンプ威力
public float jumpPower = 3.0f;
// キャラクターコントローラ(カプセルコライダ)の参照
private CapsuleCollider col;
private Rigidbody rb;
// キャラクターコントローラ(カプセルコライダ)の移動量
private Vector3 velocity;
// CapsuleColliderで設定されているコライダのHeiht、Centerの初期値を収める変数
private float orgColHight;
private Vector3 orgVectColCenter;
private Animator anim; // キャラにアタッチされるアニメーターへの参照
private AnimatorStateInfo currentBaseState; // base layerで使われる、アニメーターの現在の状態の参照
private GameObject cameraObject; // メインカメラへの参照
// アニメーター各ステートへの参照
static int idleState = Animator.StringToHash("Base Layer.Idle");
static int locoState = Animator.StringToHash("Base Layer.Locomotion");
static int jumpState = Animator.StringToHash("Base Layer.Jump");
static int restState = Animator.StringToHash("Base Layer.Rest");
// 初期化
void Start()
{
controlsActive = true;
// Animatorコンポーネントを取得する
anim = GetComponent<Animator>();
// CapsuleColliderコンポーネントを取得するカプセル型コリジョン
col = GetComponent<CapsuleCollider>();
rb = GetComponent<Rigidbody>();
//メインカメラを取得する
cameraObject = GameObject.FindWithTag("MainCamera");
// CapsuleColliderコンポーネントのHeight、Centerの初期値を保存する
orgColHight = col.height;
orgVectColCenter = col.center;
}
// 以下、メイン処理.リジッドボディと絡めるので、FixedUpdate内で処理を行う.
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal"); // 入力デバイスの水平軸をhで定義
float v = Input.GetAxis("Vertical"); // 入力デバイスの垂直軸をvで定義
anim.SetFloat("Speed", v); // Animator側で設定している"Speed"パラメタにvを渡す
anim.SetFloat("Direction", h); // Animator側で設定している"Direction"パラメタにhを渡す
anim.speed = animSpeed; // Animatorのモーション再生速度に animSpeedを設定する
currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
rb.useGravity = true;//ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする
// SReed33
// Freezes player controls, flips camera view accordingly
// + Used to show victory screen when level is won
// + Player can run in place, but no movement will be applied
if (!controlsActive)
{
cameraObject.SendMessage("setCameraPositionFrontView");
return;
}
// 以下、キャラクターの移動処理
velocity = new Vector3(0, 0, v); // 上下のキー入力からZ軸方向の移動量を取得
// キャラクターのローカル空間での方向に変換
velocity = transform.TransformDirection(velocity);
//以下のvの閾値は、Mecanim側のトランジションと一緒に調整する
if (v > 0.1)
{
velocity *= forwardSpeed; // 移動速度を掛ける
}
else if (v < -0.1)
{
velocity *= backwardSpeed; // 移動速度を掛ける
}
if (Input.GetButtonDown("Jump"))
{ // スペースキーを入力したら
//アニメーションのステートがLocomotionの最中のみジャンプできる
if (currentBaseState.fullPathHash == locoState)
{
//ステート遷移中でなかったらジャンプできる
if (!anim.IsInTransition(0))
{
rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
anim.SetBool("Jump", true); // Animatorにジャンプに切り替えるフラグを送る
}
}
}
// 上下のキー入力でキャラクターを移動させる
transform.localPosition += velocity * Time.fixedDeltaTime;
// 左右のキー入力でキャラクタをY軸で旋回させる
transform.Rotate(0, h * rotateSpeed, 0);
// 以下、Animatorの各ステート中での処理
// Locomotion中
// 現在のベースレイヤーがlocoStateの時
if (currentBaseState.fullPathHash == locoState)
{
//カーブでコライダ調整をしている時は、念のためにリセットする
if (useCurves)
{
resetCollider();
}
}
// JUMP中の処理
// 現在のベースレイヤーがjumpStateの時
else if (currentBaseState.fullPathHash == jumpState)
{
// Sreed33
// Commented the below line out to remove jump camera view
// cameraObject.SendMessage ("setCameraPositionJumpView"); // ジャンプ中のカメラに変更
// ステートがトランジション中でない場合
if (!anim.IsInTransition(0))
{
// 以下、カーブ調整をする場合の処理
if (useCurves)
{
// 以下JUMP00アニメーションについているカーブJumpHeightとGravityControl
// JumpHeight:JUMP00でのジャンプの高さ0〜1
// GravityControl:1⇒ジャンプ中重力無効、0⇒重力有効
float jumpHeight = anim.GetFloat("JumpHeight");
float gravityControl = anim.GetFloat("GravityControl");
if (gravityControl > 0)
rb.useGravity = false; //ジャンプ中の重力の影響を切る
// レイキャストをキャラクターのセンターから落とす
Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);
RaycastHit hitInfo = new RaycastHit();
// 高さが useCurvesHeight 以上ある時のみ、コライダーの高さと中心をJUMP00アニメーションについているカーブで調整する
if (Physics.Raycast(ray, out hitInfo))
{
if (hitInfo.distance > useCurvesHeight)
{
col.height = orgColHight - jumpHeight; // 調整されたコライダーの高さ
float adjCenterY = orgVectColCenter.y + jumpHeight;
col.center = new Vector3(0, adjCenterY, 0); // 調整されたコライダーのセンター
}
else
{
// 閾値よりも低い時には初期値に戻す(念のため)
resetCollider();
}
}
}
// Jump bool値をリセットするループしないようにする
anim.SetBool("Jump", false);
}
}
// IDLE中の処理
// 現在のベースレイヤーがidleStateの時
else if (currentBaseState.fullPathHash == idleState)
{
//カーブでコライダ調整をしている時は、念のためにリセットする
if (useCurves)
{
resetCollider();
}
// スペースキーを入力したらRest状態になる
if (Input.GetButtonDown("Jump"))
{
anim.SetBool("Rest", true);
}
}
// REST中の処理
// 現在のベースレイヤーがrestStateの時
else if (currentBaseState.fullPathHash == restState)
{
//cameraObject.SendMessage("setCameraPositionFrontView"); // カメラを正面に切り替える
// ステートが遷移中でない場合、Rest bool値をリセットするループしないようにする
if (!anim.IsInTransition(0))
{
anim.SetBool("Rest", false);
}
}
}
// キャラクターのコライダーサイズのリセット関数
void resetCollider()
{
// コンポーネントのHeight、Centerの初期値を戻す
col.height = orgColHight;
col.center = orgVectColCenter;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9001bcbd91e76437cb0f52f12764f2f0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,43 @@
// Sreed33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BreakableBlock : MonoBehaviour
{
[Tooltip("Seconds to wait before destroying the block")]
[SerializeField] private float destroyTime;
/**********************************************************************************************/
// Unity / game loop functions
void OnTriggerEnter(Collider other)
{
if (other.tag != "Player") return;
// When the player enters the zone, destroy the block
StartCoroutine(DestroyBlock());
}
/**********************************************************************************************/
// Implementation
IEnumerator DestroyBlock()
{
float intervalCount = 5.0f;
float interval = destroyTime / intervalCount;
// Toggle the block mesh off->on 5 times, based on the set destroyTime
for (int i = 0; i < intervalCount; i++)
{
GetComponent<MeshRenderer>().enabled = false;
// Wait for half this iteration's normal interval
yield return new WaitForSeconds(interval / 2.0f);
GetComponent<MeshRenderer>().enabled = true;
yield return new WaitForSeconds(interval / 2.0f);
}
Destroy(this.gameObject);
}
}

View File

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

View File

@@ -0,0 +1,108 @@
// SReed33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class HealthManager : MonoBehaviour
{
[Header("Health Settings")]
[Tooltip("The amount to take from the player's score when being hit by a meteor")]
[SerializeField] private int scorePenalty = 500;
[Tooltip("The length of time for the player to be invincible after being hit")]
[SerializeField] private float invTime = 2.0f;
[Tooltip("The icon to show when the player is invincible")]
[SerializeField] private GameObject sheildIcon;
[Tooltip("The sphere that acts as a forcefield around the player when invincible")]
[SerializeField] private GameObject forceField;
[Tooltip("The HeartPanel to access player hearts")]
[SerializeField] private GameObject heartPanel;
[Tooltip("The YouDied UI panel to enable when the player dies")]
[SerializeField] private GameObject youDied;
[Tooltip("The FadeOut UI panel to enable when the player dies")]
[SerializeField] private GameObject fadeOut;
[Header("Health State")]
[Tooltip("Player hearts, automatically adjusts to UI elements")]
[SerializeField] private GameObject[] playerHearts;
[Tooltip("Player hits, initialized at game start based on heart count with playerHearts.Length")]
[SerializeField] private int playerHits;
[Tooltip("Currrent invincible state of the player")]
[SerializeField] private bool playerInvincible = false;
/**********************************************************************************************/
// Unity / game loop functions
// Start is called before the first frame update
void Start()
{
playerHits = heartPanel.transform.childCount;
}
/**********************************************************************************************/
// Implementation
// Called by Meteor.cs when a meteor hits the player
public void HurtPlayer()
{
// Do nothing if we are invincible; Don't try to reach before child index 0, it doesnt exist
if (playerInvincible) return;
if (playerHits < 0) return;
// Reduce the score of the player for being hit
GlobalScore.currentScore -= scorePenalty;
// Get the last child of the heart's UI panel and deactivate it
// Hides a heart from view on each hit
heartPanel.transform.GetChild(--playerHits).gameObject.SetActive(false);
// If we just removed the last heart, we died :(
if (playerHits == 0) StartCoroutine(KillPlayer());
else StartCoroutine(Invincible()); // Otherwise, make player invincible for invTime
}
// Makes the player invincible for the time set in the editor
IEnumerator Invincible()
{
// Set the invincibility UI element to active
forceField.SetActive(true);
sheildIcon.SetActive(true);
playerInvincible = true;
yield return new WaitForSeconds(invTime);
// Deactivate invincibility after waiting is done
forceField.SetActive(false);
sheildIcon.SetActive(false);
playerInvincible = false;
}
// Ends the game when the player loses all their health
IEnumerator KillPlayer()
{
// Disable player controls and level BGM
UnityChan.UnityChanControlScriptWithRgidBody.controlsActive = false;
GameObject.Find("LevelAudio").GetComponent<AudioSource>().Pause();
// Activate youDied, fadeOut overlays and load next scene
youDied.SetActive(true);
yield return new WaitForSeconds(2);
fadeOut.SetActive(true);
yield return new WaitForSeconds(1);
SceneManager.LoadScene(Level.thisLevel);
}
}

View File

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

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Level : MonoBehaviour
{
[Tooltip("The fadeIn gameobject to activate when the level starts")]
[SerializeField] public GameObject fadeIn;
[Tooltip("The name of the next level to load")]
[SerializeField] private string _nextLevel;
[Tooltip("The name of this level")]
[SerializeField] private string _thisLevel;
// Static values used to control game sequence
public static string nextLevel;
public static string thisLevel;
void Start()
{
nextLevel = _nextLevel;
thisLevel = _thisLevel;
GlobalScore.currentScore = 0;
// Reset gravity to default on level start
Physics.gravity = Vector3.down * 9.81f;
StartCoroutine(FadeIn());
}
IEnumerator FadeIn()
{
fadeIn.SetActive(true);
yield return new WaitForSeconds(1);
fadeIn.SetActive(false);
}
}

View File

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

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadNextLevel : MonoBehaviour
{
[Header("Load Screen Settings")]
[Tooltip("Object(s) to activate when the scene starts")]
[SerializeField] private GameObject[] someObjects;
[Tooltip("The amount of time to wait before loading the next level")]
[SerializeField] private float waitTime;
[Tooltip("The name of the next level to load")]
[SerializeField] private string levelToLoad;
/**********************************************************************************************/
// Unity / game loop functions
void Start()
{
StartCoroutine(Transition());
}
/**********************************************************************************************/
// Implementation
IEnumerator Transition()
{
yield return new WaitForSeconds(0.5f);
// Activate the objeccts set in the inspector, then waitTime
foreach (GameObject o in someObjects) o.SetActive(true);
yield return new WaitForSeconds(waitTime);
// Load the next levelToLoad
SceneManager.LoadScene(levelToLoad);
}
}

View File

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

View File

@@ -0,0 +1,120 @@
// Sreed33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Meteor : MonoBehaviour
{
[Header("Meteor Settings")]
[Tooltip("The root gameobject to enable for playing explosion effects")]
[SerializeField] private GameObject explosionEffect;
[Tooltip("The radius of the explosion force created on impact")]
[SerializeField] private float explosionRadius;
[Tooltip("The force of the explosion")]
[SerializeField] private float explosionForce;
[Tooltip("The upwards lift from the explosion")]
[SerializeField] private float explosionLift;
[Tooltip("The radius used to damage the player")]
[SerializeField] private float damageRadius;
[Tooltip("The radius used to destroy blocks")]
[SerializeField] private float destroyRadius;
[Tooltip("The maximum number of blocks to destroy")]
[SerializeField] private int destroyBlocksCount;
[Tooltip("Set true if the meteor should destroy blocks on collision")]
// Large meteors are set in the editor to destroy blocks
[SerializeField] private bool destroyBlocks = false;
[Header("Meteor State")]
[Tooltip("Once this boolean is false, the meteor will not trigger events again")]
[SerializeField] private bool newMeteor = true;
/**********************************************************************************************/
// Unity / game loop functions
void OnTriggerEnter(Collider other)
{
if (other.GetComponent<GemPickup>()) return;
DamagePlayer();
// Track if this is the first collision for this meteor
if (newMeteor) newMeteor = false;
else return;
// If it has already collided, then do nothing
if (destroyBlocks) DestroyBlocks();
// Disable meteor components, enable explosion effect
GetComponent<MeshRenderer>().enabled = false;
GetComponent<SphereCollider>().enabled = false;
foreach (Light l in GetComponentsInChildren<Light>()) l.enabled = false;
// I attached box collider to explosion effects so they would collide with the ground
// Use it to enable the root gameobject and play all the nested effects
explosionEffect.SetActive(true);
// Check all colliders within a radius around the explosion
Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
foreach (Collider c in colliders)
{
// If it is not a player, do nothing; Otherwise hurt the player
if (c.gameObject.tag != "Player") continue;
// Apply a force to the player from the explosion
Rigidbody rb = c.gameObject.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(explosionForce, transform.position, explosionRadius, explosionLift, ForceMode.Impulse);
}
}
// Destroy the meteor
StartCoroutine(KillMeteor());
}
/**********************************************************************************************/
// Implementation
void DestroyBlocks()
{
int blocksDestroyed = 0;
Collider[] blocks = Physics.OverlapSphere(transform.position, destroyRadius);
foreach (Collider c in blocks)
{
if (c.gameObject.tag == "Blue")
{
Destroy(c.gameObject);
blocksDestroyed++;
if (blocksDestroyed >= destroyBlocksCount) return;
}
}
}
void DamagePlayer()
{
Collider[] blocks = Physics.OverlapSphere(transform.position, damageRadius);
foreach (Collider c in blocks)
{
if (c.gameObject.tag == "Player")
{
print("Ow: " + this.gameObject.name);
FindObjectOfType<HealthManager>().HurtPlayer();
}
}
}
IEnumerator KillMeteor()
{
// Wait two seconds before destroying this gameobject to let the explosion finish
yield return new WaitForSeconds(2.0f);
Destroy(this.gameObject);
}
}

View File

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

View File

@@ -0,0 +1,116 @@
// Sreed33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeteorZone : MonoBehaviour
{
[Header("Meteor Zone Settings")]
[Tooltip("The tag assigned to the GameObject that spawn meteors")]
[SerializeField] private string objectTag;
[Tooltip("Time between meteor spawns")]
[SerializeField] private float spawnInterval;
[Header("Meteor Prefab Assets")]
[Tooltip("Small meteor prefab")]
[SerializeField] private GameObject meteorSmall;
[Tooltip("Medium meteor prefab")]
[SerializeField] private GameObject meteorMedium;
[Tooltip("Large meteor prefab")]
[SerializeField] private GameObject meteorLarge;
[Header("Zone State")]
[Tooltip("Automatically initialized with spawn positions in this zone on game start")]
[SerializeField] private List<GameObject> meteorSpawners;
[Tooltip("A local bool that controls this zone spawning meteors")]
[SerializeField] private bool zoneSpawnMeteors = false;
[Tooltip("A local bool used to throttle the spawn rate of meteors")]
[SerializeField] private bool spawnPending = false;
// A static bool used to control the spawning of meteors across the entire level
public static bool spawnMeteors = true;
/**********************************************************************************************/
// Unity / game loop functions
// Start is called before the first frame update
void Start()
{
spawnMeteors = true;
// Check each object that makes up this meteor zone
foreach (Transform child in this.transform.parent.GetComponentsInChildren<Transform>())
{
// If the object is tagged as a metor spawner, add it to the list
if (child.gameObject.tag == objectTag) meteorSpawners.Add(child.gameObject);
}
}
void FixedUpdate()
{
// Do nothing if either local zone or level meteor bool is false
if (!spawnMeteors || !zoneSpawnMeteors) return;
// StartCoroutine only after the previous meteor is spawned
if (!spawnPending) StartCoroutine(SpawnMeteor());
}
void OnTriggerEnter(Collider other)
{
// Do nothing if the object is not a player
if (other.gameObject.tag != "Player") return;
// Set local meteor spawn bool to true; Start spawning meteors in this zone
zoneSpawnMeteors = true;
}
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag != "Player") return;
// If there is a player in the zone and we are not spawning meteors, set zoneSpawnMeteors
if (!zoneSpawnMeteors) zoneSpawnMeteors = true;
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag != "Player") return;
// When the player leaves the zone, stop spawning meteors
zoneSpawnMeteors = false;
}
/**********************************************************************************************/
// Implementation
IEnumerator SpawnMeteor()
{
spawnPending = true;
// Wait for the set number of seconds until we spawn a meteor
yield return new WaitForSeconds(spawnInterval);
// Using the count of objects in the meteorSpawner list, get a random index to spawn at
int spawnSlot = Random.Range(0, meteorSpawners.Count);
Transform spawnPos = meteorSpawners[spawnSlot].transform;
// Using 10 values (0-9), get a large meteor(20%), medium meteor(30%), or small meteor(50%)
// + large = 0, 1; Medium = 4, 3, 2; Small = 5, 6, 7, 8, 9
int meteorType = Random.Range(0, 9);
GameObject newMeteor;
if (meteorType < 2) newMeteor = meteorLarge;
else if (meteorType < 5 && meteorType >= 2) newMeteor = meteorMedium;
else newMeteor = meteorSmall;
// Spawn this meteor
GameObject.Instantiate(newMeteor, spawnPos.position, meteorSpawners[0].transform.rotation);
// Spawn another meteor in FixedUpdate()
spawnPending = false;
}
}

View File

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

View File

@@ -0,0 +1,48 @@
// Sreed33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Portal : MonoBehaviour
{
[Tooltip("The linked portal to move the player to when entering here")]
[SerializeField] private GameObject friendPortal;
// Boolean to prevent teleporting back and forth infinitely
public static bool teleporting = false;
/**********************************************************************************************/
// Unity / game loop functions
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag != "Player") return;
// Only teleport if we are not teleporting
if (!teleporting) TeleportChan(other);
}
/**********************************************************************************************/
// Implementation
void TeleportChan(Collision player)
{
teleporting = true;
// Stop applying physics to the player until we finish teleporting
player.rigidbody.isKinematic = true;
// Move the player to the spawn position that is always the only child of Portal.cs
Transform spawnPos = friendPortal.GetComponentInChildren<Portal>().transform.GetChild(0);
player.transform.position = spawnPos.position;
player.transform.rotation = spawnPos.rotation;
// Always force the player down towards whatever surface they are waling on
// + Allows player to walk on walls and ceilings after TP using local->world axis
Physics.gravity = spawnPos.up * -9.81f;
// Resume physics
player.rigidbody.isKinematic = false;
teleporting = false;
}
}

View File

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