consolidate all repos to one for archive
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.XR.CoreUtils;
|
||||
//using UnityEngine.UIElements;
|
||||
|
||||
public class GameLogicSk3 : MonoBehaviour
|
||||
{
|
||||
public GameObject[] spPoints;
|
||||
public GameObject[] objInScene;
|
||||
public string[] objOrder;
|
||||
public Transform mizaPos;
|
||||
public TextMeshProUGUI mssg;
|
||||
List<int> usedIndices = new List<int>();
|
||||
GameObject Base;
|
||||
|
||||
int searchForObjIdx;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
int index = UnityEngine.Random.Range(0, spPoints.Length); ;
|
||||
|
||||
for (int i = 0; i < objInScene.Length; i++)
|
||||
{
|
||||
|
||||
|
||||
while (usedIndices.Contains(index))
|
||||
{
|
||||
index = UnityEngine.Random.Range(0, spPoints.Length);
|
||||
}
|
||||
GameObject target = spPoints[index];
|
||||
usedIndices.Add(index);
|
||||
|
||||
GameObject.Instantiate(objInScene[i], target.transform.position, target.transform.rotation);
|
||||
}
|
||||
searchForObjIdx = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
mssg.text = "Išči objekt: " + objOrder[searchForObjIdx];
|
||||
|
||||
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
|
||||
{
|
||||
Ray raycast = Camera.current.ScreenPointToRay(Input.GetTouch(0).position);
|
||||
RaycastHit raycastHit;
|
||||
|
||||
if (Physics.Raycast(raycast, out raycastHit))
|
||||
{
|
||||
if (raycastHit.collider.gameObject.tag == objOrder[searchForObjIdx])
|
||||
{
|
||||
if(raycastHit.collider.gameObject.tag == "Miza")
|
||||
{
|
||||
raycastHit.collider.gameObject.transform.position = mizaPos.transform.position;
|
||||
raycastHit.collider.gameObject.transform.rotation = mizaPos.transform.rotation;
|
||||
Vector3 TmvV = mizaPos.transform.position;
|
||||
TmvV.y += (float)0.5;
|
||||
mizaPos.transform.position = TmvV;
|
||||
Base = raycastHit.collider.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (raycastHit.collider.gameObject.tag == "Stol")
|
||||
{
|
||||
Transform trns = Base.transform.GetChild(9).transform;
|
||||
raycastHit.collider.gameObject.transform.position = trns.transform.position;
|
||||
//raycastHit.collider.gameObject.transform.rotation = trns.transform.rotation;
|
||||
raycastHit.collider.gameObject.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (raycastHit.collider.gameObject.tag == "Prenosnik")
|
||||
{
|
||||
Transform trns = Base.transform.GetChild(5).transform;
|
||||
raycastHit.collider.gameObject.transform.position = trns.transform.position;
|
||||
raycastHit.collider.gameObject.transform.rotation = trns.transform.rotation;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
raycastHit.collider.gameObject.transform.position = mizaPos.transform.position;
|
||||
raycastHit.collider.gameObject.transform.rotation = mizaPos.transform.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
searchForObjIdx++;
|
||||
|
||||
if (searchForObjIdx == objInScene.Length)
|
||||
{
|
||||
mssg.text = " ";
|
||||
TimerSk3 tmr = GetComponent<TimerSk3>();
|
||||
tmr.StopTimer();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Na novo razmeci objekte
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f2456904c6f8799abe1f3ea4a2ee424
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a0752cde4ee02b7ab66005f55986afb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
public class TimerSk3 : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI mssg;
|
||||
float timePlaying;
|
||||
|
||||
private bool gameOn;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
timePlaying = 0;
|
||||
gameOn = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (gameOn)
|
||||
{
|
||||
timePlaying += Time.deltaTime;
|
||||
|
||||
int sec = (int)timePlaying % 60;
|
||||
int min = (int)(timePlaying / 60);
|
||||
|
||||
mssg.text = string.Format("{0:00}:{1:00}", min, sec);
|
||||
}
|
||||
}
|
||||
|
||||
public void StopTimer()
|
||||
{
|
||||
gameOn = false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dca4f116cfe5f8f39bb55196dffcb7c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
|
||||
public class myScript : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI mssg1;
|
||||
|
||||
public TextMeshProUGUI mssg2;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public List<GameObject> objects;
|
||||
|
||||
readonly List<Vector3> positions = new();
|
||||
|
||||
readonly List<GameObject> spawned = new();
|
||||
|
||||
int count = 0;
|
||||
float timePlaying = 0;
|
||||
bool gameOn = true;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
foreach (GameObject obj in objects)
|
||||
{
|
||||
positions.Add(obj.transform.position);
|
||||
Vector2 pos = Random.insideUnitCircle;
|
||||
Vector3 newPos = new(pos.x, obj.transform.position.y, pos.y);
|
||||
spawned.Add(Instantiate(obj, newPos, obj.transform.rotation));
|
||||
}
|
||||
mssg2.text = "Find";
|
||||
mssg1.text = objects[0].tag;
|
||||
}
|
||||
|
||||
void reTrow()
|
||||
{
|
||||
foreach (GameObject obj in spawned)
|
||||
{
|
||||
Vector2 pos = Random.insideUnitCircle;
|
||||
Vector3 newPos = new(pos.x, obj.transform.position.y, pos.y);
|
||||
obj.transform.position = newPos;
|
||||
obj.GetComponent<BoxCollider>().enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
void Update()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (!gameOn) return;
|
||||
|
||||
timePlaying += Time.deltaTime;
|
||||
|
||||
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(Input.GetTouch(0).position);
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit))
|
||||
{
|
||||
GameObject pressedObject = hit.collider.gameObject;
|
||||
|
||||
if (pressedObject.CompareTag(objects[count].tag))
|
||||
{
|
||||
pressedObject.GetComponent<BoxCollider>().enabled = false;
|
||||
pressedObject.transform.position = positions[count];
|
||||
count++;
|
||||
|
||||
if (count > objects.Count - 1)
|
||||
{
|
||||
mssg2.text = "You Win";
|
||||
int sec = (int)timePlaying % 60;
|
||||
int min = (int)(timePlaying / 60);
|
||||
mssg1.text = string.Format("{0:00}:{1:00}", min, sec);
|
||||
gameOn = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mssg1.text = objects[count].tag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
mssg1.text = objects[0].tag;
|
||||
reTrow();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
mssg1.text = e.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 566653adcce3ba534a1c2f6757c48bde
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user