Added RottenApples that GameOver if caught

This commit is contained in:
Trianta 2024-02-08 17:27:45 -06:00
parent b9fced5e18
commit 22c4d22165
12 changed files with 298 additions and 4 deletions

View File

@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Mat_RottenApple
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.3679245, g: 0.22651923, b: 0.1995817, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aac77a5a72d294e0caad700a8e462b26
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,7 +16,7 @@ GameObject:
- component: {fileID: -241090631759527902}
m_Layer: 9
m_Name: Apple
m_TagString: Apple
m_TagString: RottenApple
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

View File

@ -0,0 +1,129 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1428767985013339637
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1428767985013339632}
- component: {fileID: 1428767985013339633}
- component: {fileID: 1428767985013339634}
- component: {fileID: 1428767985013339635}
- component: {fileID: 1428767985013339636}
- component: {fileID: -559816898672518007}
m_Layer: 11
m_Name: RottenApple
m_TagString: RottenApple
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1428767985013339632
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1428767985013339633
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1428767985013339634
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: aac77a5a72d294e0caad700a8e462b26, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &1428767985013339635
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &1428767985013339636
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &-559816898672518007
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428767985013339637}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a833b002908db9212a4486fe67e0969a, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

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

View File

@ -815,6 +815,10 @@ PrefabInstance:
propertyPath: leftAndRightEdge
value: 20
objectReference: {fileID: 0}
- target: {fileID: 8871816599865554133, guid: 7f43e61e14d39c9608ac9a44321a0dc8, type: 3}
propertyPath: rottenApplePrefab
value:
objectReference: {fileID: 1428767985013339637, guid: db7d7f53e4b04e16596115dbcc4f31c1, type: 3}
- target: {fileID: 8871816599865554133, guid: 7f43e61e14d39c9608ac9a44321a0dc8, type: 3}
propertyPath: chanceToChangeDirections
value: 0.02

View File

@ -50,11 +50,26 @@ public class ApplePicker : MonoBehaviour
roundGT.text += numBaskets - basketList.Count + 1;
// If there are no Baskets left, restart the game
if (basketList.Count == 0) {
roundGT.text = "Game Over";
SceneManager.LoadScene("_Scene_0");
GameOver();
}
}
public void RottenAppleDestroyed() {
// Destroy all of the falling apples
GameObject[] tAppleArray = GameObject.FindGameObjectsWithTag("Apple");
foreach (GameObject tGO in tAppleArray) {
Destroy(tGO);
}
GameOver();
}
public void GameOver() {
Time.timeScale = 0;
roundGT.text = "Game Over";
SceneManager.LoadScene("_Scene_0");
Time.timeScale = 1;
}
// Update is called once per frame
void Update()
{

View File

@ -7,6 +7,7 @@ public class AppleTree : MonoBehaviour
[Header("Set in Inspector")]
// Prefab for instantiating apples
public GameObject applePrefab;
public GameObject rottenApplePrefab;
// Speed at which the AppleTree moves
public float speed = 1f;
// Distance where AppleTree turns around
@ -15,11 +16,15 @@ public class AppleTree : MonoBehaviour
public float chanceToChangeDirections = 0.1f;
// Rate at which Apples will be instantiated
public float secondsBetweenAppleDrops = 1f;
// Rate at which RottenApples will be instantiated
public float secondsBetweenRottenAppleDrops = 3f;
// Start is called before the first frame update
void Start()
{
// Dropping apples every second
Invoke("DropApple", 2f);
// Dropping rotten apples every 3 seconds
Invoke("DropRottenApple", 2f);
}
void DropApple() {
@ -28,6 +33,12 @@ public class AppleTree : MonoBehaviour
Invoke("DropApple", secondsBetweenAppleDrops);
}
void DropRottenApple() {
GameObject rottenApple = Instantiate<GameObject>(rottenApplePrefab);
rottenApple.transform.position = transform.position;
Invoke("DropRottenApple", secondsBetweenRottenAppleDrops);
}
// Update is called once per frame
void Update()
{

View File

@ -49,5 +49,10 @@ public class Basket : MonoBehaviour
HighScore.score = score;
}
}
if (collidedWith.tag == "RottenApple") {
Destroy(collidedWith);
ApplePicker apScript = Camera.main.GetComponent<ApplePicker>();
apScript.RottenAppleDestroyed();
}
}
}

View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RottenApple : MonoBehaviour
{
[Header("Set in Inspector")]
public static float bottomY = -20f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (transform.position.y < bottomY) {
Destroy(this.gameObject);
}
}
}

View File

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

View File

@ -5,6 +5,8 @@ TagManager:
serializedVersion: 2
tags:
- Apple
- RottenApple
- Undefined
layers:
- Default
- TransparentFX
@ -17,7 +19,7 @@ TagManager:
- AppleTree
- Apple
- Basket
-
- RottenApple
-
-
-