Added a retry scene and blocker
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Blocker : MonoBehaviour
|
||||
{
|
||||
[Header("Set in Inspector")]
|
||||
// Speed at which the AppleTree moves
|
||||
public float speed = 1f;
|
||||
// Distance where AppleTree turns around
|
||||
public float leftAndRightEdge = 10f;
|
||||
// Chance that the AppleTree will change directions
|
||||
public float chanceToChangeDirections = 0.1f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
// Basic Movement
|
||||
Vector3 pos = transform.position;
|
||||
pos.y += speed * Time.deltaTime;
|
||||
transform.position = pos;
|
||||
// Changing Direction
|
||||
if (pos.y < -leftAndRightEdge) {
|
||||
speed = Mathf.Abs(speed);
|
||||
} else if (pos.y > leftAndRightEdge) {
|
||||
speed = -Mathf.Abs(speed);
|
||||
}
|
||||
}
|
||||
|
||||
// Update exactly 50 times per second
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (Random.value < chanceToChangeDirections) {
|
||||
speed *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 083040736f312e125974884302b423e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public enum GameMode {
|
||||
idle,
|
||||
playing,
|
||||
@@ -45,7 +47,7 @@ public class MissionDemolition: MonoBehaviour {
|
||||
castle.transform.position = castlePos;
|
||||
shotsTaken = 0;
|
||||
// Reset the camera
|
||||
SwitchView("wShow Both");
|
||||
SwitchView("Show Both");
|
||||
ProjectileLine.s.Clear();
|
||||
// Reset the goal
|
||||
Goal.goalMet = false;
|
||||
@@ -67,7 +69,7 @@ public class MissionDemolition: MonoBehaviour {
|
||||
// Change mode to stop checking for level end
|
||||
mode = GameMode.levelEnd;
|
||||
// Zoom out
|
||||
SwitchView("Show Both" );
|
||||
SwitchView("Show Both");
|
||||
// Start the next level in 2 seconds
|
||||
Invoke("NextLevel", 2f);
|
||||
}
|
||||
@@ -76,7 +78,8 @@ public class MissionDemolition: MonoBehaviour {
|
||||
void NextLevel() {
|
||||
level++;
|
||||
if (level == levelMax) {
|
||||
level = 0;
|
||||
SceneManager.LoadScene("_Scene_1");
|
||||
return;
|
||||
}
|
||||
StartLevel();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Retry : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ChangeScene() {
|
||||
SceneManager.LoadScene("_Scene_0");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76102ab5725bbd237a2d5ee7baa59fbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user