Item Gedöns bissl benüüüützen
This commit is contained in:
@@ -30,6 +30,7 @@ public class Client : MonoBehaviour
|
||||
[SerializeField] private GameObject layout2;
|
||||
[SerializeField] private Image[] uiItems;
|
||||
[SerializeField] private Item[] items;
|
||||
[SerializeField] private Button[] itemButtons;
|
||||
|
||||
private int playerAmount = 0;
|
||||
|
||||
@@ -44,6 +45,11 @@ public class Client : MonoBehaviour
|
||||
{
|
||||
thisClient = this;
|
||||
|
||||
foreach(Image img in uiItems)
|
||||
{
|
||||
img.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
playerInfo[i].SetActive(false);
|
||||
@@ -142,6 +148,8 @@ public class Client : MonoBehaviour
|
||||
script.nextField = nextField;
|
||||
script.dice = dice;
|
||||
script.camera = cam;
|
||||
|
||||
itemButtons[job.data[5]].interactable = true;
|
||||
}
|
||||
//player is not playable
|
||||
else
|
||||
@@ -155,6 +163,8 @@ public class Client : MonoBehaviour
|
||||
script.nextField = nextField;
|
||||
script.dice = dice;
|
||||
script.camera = cam;
|
||||
|
||||
itemButtons[job.data[5]].interactable = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -19,6 +19,6 @@ public class Item : MonoBehaviour
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Mushroom = 0, DoubleDice = 1
|
||||
None = -1, Mushroom = 0, DoubleDice = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NoPlayablePlayer : Player
|
||||
{
|
||||
@@ -31,6 +32,8 @@ public class NoPlayablePlayer : Player
|
||||
|
||||
activated = false;
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void BuyStar()
|
||||
@@ -56,6 +59,13 @@ public class NoPlayablePlayer : Player
|
||||
{
|
||||
wurfelt = true;
|
||||
this.wurfelZahl = wurfelZahl;
|
||||
|
||||
if (activeItem == Item.Type.Mushroom)
|
||||
{
|
||||
wurfelZahl += 3;
|
||||
activeItem = Item.Type.None;
|
||||
}
|
||||
|
||||
//nächstes Feld anvisieren
|
||||
TargetNextField();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Mail;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayablePlayer : Player
|
||||
{
|
||||
@@ -36,6 +37,7 @@ public class PlayablePlayer : Player
|
||||
QualitySettings.vSyncCount = 0;
|
||||
Application.targetFrameRate = 61;
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -53,25 +55,30 @@ public class PlayablePlayer : Player
|
||||
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
|
||||
if ((Input.GetMouseButtonUp(0) && !uiHandler.MapOpen) && wurfelZahl == 0 && !wurfelt)
|
||||
{
|
||||
if(!Physics.Raycast(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -200), Vector3.forward))
|
||||
if (!Physics.Raycast(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -200), Vector3.forward))
|
||||
{
|
||||
wurfelt = true;
|
||||
wurfelZahl = Random.Range(1, 7);
|
||||
|
||||
if (activeItem == Item.Type.Mushroom)
|
||||
{
|
||||
wurfelt = true;
|
||||
wurfelZahl = Random.Range(1, 7);
|
||||
textLeftMoves.text = wurfelZahl + "";
|
||||
|
||||
client.SendWurfeln(wurfelZahl);
|
||||
|
||||
//nächstes Feld anvisieren
|
||||
TargetNextField();
|
||||
|
||||
//stop the dice
|
||||
diceScript.StopRandom(wurfelZahl);
|
||||
|
||||
//delay for walk start
|
||||
timeSinceWurfeln = Time.time;
|
||||
wurfelZahl += 3;
|
||||
activeItem = Item.Type.None;
|
||||
}
|
||||
|
||||
|
||||
|
||||
textLeftMoves.text = wurfelZahl + "";
|
||||
|
||||
client.SendWurfeln(wurfelZahl);
|
||||
|
||||
//nächstes Feld anvisieren
|
||||
TargetNextField();
|
||||
|
||||
//stop the dice
|
||||
diceScript.StopRandom(wurfelZahl);
|
||||
|
||||
//delay for walk start
|
||||
timeSinceWurfeln = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public abstract class Player : MonoBehaviour
|
||||
public UIHandler uiHandler;
|
||||
public Item[] items = new Item[3];
|
||||
public Image[] uiItems;
|
||||
public Item.Type activeItem = Item.Type.None;
|
||||
|
||||
//for coin animation
|
||||
private AnimationHandler animationHandler;
|
||||
@@ -84,11 +85,19 @@ public abstract class Player : MonoBehaviour
|
||||
{
|
||||
items[i] = item;
|
||||
uiItems[i].sprite = item.sprite;
|
||||
uiItems[i].gameObject.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ActivateItem(int index, Item.Type type)
|
||||
{
|
||||
uiItems[index].gameObject.SetActive(false);
|
||||
items[index] = null;
|
||||
activeItem = type;
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider c)
|
||||
{
|
||||
eventstop = true;
|
||||
|
||||
@@ -108,6 +108,12 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.GetComponent<ItemShop>().Init(currentPlayer);
|
||||
}
|
||||
|
||||
//TODO: Only temp, make additional function for Item selection
|
||||
public void ActivateLayoutItemSelect()
|
||||
{
|
||||
currentPlayer.ActivateItem(0, Item.Type.Mushroom);
|
||||
}
|
||||
|
||||
public void ButtonBuyStar()
|
||||
{
|
||||
((PlayablePlayer)currentPlayer).BuyStar(true);
|
||||
|
||||
Reference in New Issue
Block a user