This commit is contained in:
brausjonas
2023-01-24 19:38:27 +01:00
parent 025d4b974f
commit 5ca5b8c4f2
84 changed files with 14567 additions and 150 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f3fa0c2e94605d4a808fedc264e3b85
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random;
public class Dice : MonoBehaviour
{
[SerializeField] private TMP_Text[] numbers;
[SerializeField] private Rigidbody rb;
private bool started;
private void Start()
{
rb.useGravity = false;
gameObject.SetActive(false);
}
public void StartRandom()
{
if (!started)
{
rb.useGravity = false;
gameObject.SetActive(true);
started = true;
InvokeRepeating("RandomNumbers", 0f, 0.1f);
}
}
public void StopRandom(int dec)
{
started = false;
CancelInvoke("RandomNumbers");
rb.useGravity = true;
rb.angularVelocity = new Vector3(Random.Range(5, 10), Random.Range(5, 10), Random.Range(5, 10));
foreach (TMP_Text t in numbers)
{
t.text = dec.ToString();
}
}
private void RandomNumbers()
{
int random = Random.Range(1, 7);
rb.angularVelocity = new Vector3(Random.Range(5, 10), Random.Range(5, 10), Random.Range(5, 10));
foreach (TMP_Text t in numbers)
{
t.text = random.ToString();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70821f71a92e74a458d3c9851df96456
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+25 -5
View File
@@ -9,6 +9,7 @@ public class Player : MonoBehaviour
[SerializeField] private Field nextField;
private Field currentField;
[SerializeField] private GameObject dice;
private Dice diceScript;
private Vector3 moveTo = Vector3.zero;
private Vector3 lastPos = Vector3.zero;
private float speed = 5;
@@ -17,10 +18,15 @@ public class Player : MonoBehaviour
private bool activated = true;
private bool wait = false;
private bool lastActivated = false;
private float timeSinceWurfeln = 0;
private Vector3 useLess = new Vector3();
private void Start()
{
diceScript = dice.GetComponent<Dice>();
}
private void Update()
@@ -28,12 +34,18 @@ public class Player : MonoBehaviour
if(activated)
{
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
if (Input.GetKeyDown(KeyCode.Space) && wurfelZahl == 0)
if ((Input.GetMouseButtonDown(0)) && wurfelZahl == 0)
{
wurfelZahl = Random.Range(1, 7);
Debug.Log("Test: gewürfelt wurde " + wurfelZahl);
//nächstes Feld anvisieren
TargetNextField();
//stop the dice
diceScript.StopRandom(wurfelZahl);
//delay for walk start
timeSinceWurfeln = Time.time;
}
}
}
@@ -47,7 +59,12 @@ public class Player : MonoBehaviour
//Laufe zum nöchsten Feld, falls noch Züge übrig sind
if (interPol < 1 && wurfelZahl > 0)
{
InterPolerate();
//delay
if(Time.time - timeSinceWurfeln > 1)
{
InterPolerate();
}
}
//Würfelzahl um 1 verringern falls noch züge übrig sind
else if (wurfelZahl > 0 )
@@ -63,7 +80,10 @@ public class Player : MonoBehaviour
//Der Spieler steht gerade
else
{
//start the dice
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
}
}
else