Added bot for start screen and Apple Picker text
This commit is contained in:
parent
8ebf5e222b
commit
b436c41b0f
@ -191,6 +191,86 @@ Transform:
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &333221063
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 333221064}
|
||||
- component: {fileID: 333221066}
|
||||
- component: {fileID: 333221065}
|
||||
m_Layer: 5
|
||||
m_Name: Text (Legacy)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &333221064
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 333221063}
|
||||
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: 1391927209}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 83.5}
|
||||
m_SizeDelta: {x: -800, y: -527}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &333221065
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 333221063}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.6509434, g: 0.15659486, b: 0.15659486, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 48
|
||||
m_FontStyle: 1
|
||||
m_BestFit: 0
|
||||
m_MinSize: 3
|
||||
m_MaxSize: 48
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Apple Picker
|
||||
--- !u!222 &333221066
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 333221063}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -345,10 +425,10 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_FontSize: 16
|
||||
m_FontStyle: 1
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
@ -562,6 +642,7 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1394167064}
|
||||
- {fileID: 333221064}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AppleTree : MonoBehaviour
|
||||
{
|
||||
@ -23,6 +24,7 @@ public class AppleTree : MonoBehaviour
|
||||
{
|
||||
// Dropping apples every second
|
||||
Invoke("DropApple", 2f);
|
||||
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
|
||||
// Dropping rotten apples every 3 seconds
|
||||
Invoke("DropRottenApple", 2f);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ public class Basket : MonoBehaviour
|
||||
{
|
||||
[Header("Set Dynamically")]
|
||||
public Text scoreGT;
|
||||
float botSpeed = 15f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -23,7 +24,11 @@ public class Basket : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
|
||||
if (SceneManager.GetActiveScene().name == "_Scene_2") { GetBotInput(); }
|
||||
else { GetPlayerInput(); }
|
||||
}
|
||||
|
||||
void GetPlayerInput() {
|
||||
// Get the current screen position of the mouse from Input
|
||||
Vector3 mousePos2D = Input.mousePosition;
|
||||
// The Camera's z position sets how far to push the mouse into 3D
|
||||
@ -36,6 +41,23 @@ public class Basket : MonoBehaviour
|
||||
this.transform.position = pos;
|
||||
}
|
||||
|
||||
void GetBotInput() {
|
||||
float basketHeight = this.transform.position.y;
|
||||
float currentMin = 999;
|
||||
float directionToGo = this.transform.position.x;
|
||||
GameObject[] tAppleArray = GameObject.FindGameObjectsWithTag("Apple");
|
||||
foreach (GameObject tGO in tAppleArray) {
|
||||
if (tGO.transform.position.y - basketHeight < currentMin) {
|
||||
currentMin = tGO.transform.position.y - basketHeight;
|
||||
if (tGO.transform.position.x > this.transform.position.x) { directionToGo = 1; }
|
||||
else { directionToGo = -1; }
|
||||
}
|
||||
}
|
||||
Vector3 pos = transform.position;
|
||||
pos.x += botSpeed * Time.deltaTime * directionToGo;
|
||||
transform.position = pos;
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision coll) {
|
||||
// Find out what hit this basket
|
||||
GameObject collidedWith = coll.gameObject;
|
||||
|
Loading…
Reference in New Issue
Block a user