Item Gedöns bissl benüüüützen

This commit is contained in:
brausjonas
2023-03-04 00:25:41 +01:00
parent 32f5b49c0d
commit fd0a36ccb7
11 changed files with 974 additions and 98 deletions
+1 -1
View File
@@ -134,7 +134,7 @@
<workItem from="1677516389539" duration="4730000" /> <workItem from="1677516389539" duration="4730000" />
<workItem from="1677521614865" duration="735000" /> <workItem from="1677521614865" duration="735000" />
<workItem from="1677789832911" duration="4364000" /> <workItem from="1677789832911" duration="4364000" />
<workItem from="1677881158579" duration="881000" /> <workItem from="1677881158579" duration="4292000" />
</task> </task>
<servers /> <servers />
</component> </component>
File diff suppressed because it is too large Load Diff
+10
View File
@@ -30,6 +30,7 @@ public class Client : MonoBehaviour
[SerializeField] private GameObject layout2; [SerializeField] private GameObject layout2;
[SerializeField] private Image[] uiItems; [SerializeField] private Image[] uiItems;
[SerializeField] private Item[] items; [SerializeField] private Item[] items;
[SerializeField] private Button[] itemButtons;
private int playerAmount = 0; private int playerAmount = 0;
@@ -44,6 +45,11 @@ public class Client : MonoBehaviour
{ {
thisClient = this; thisClient = this;
foreach(Image img in uiItems)
{
img.gameObject.SetActive(false);
}
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
playerInfo[i].SetActive(false); playerInfo[i].SetActive(false);
@@ -142,6 +148,8 @@ public class Client : MonoBehaviour
script.nextField = nextField; script.nextField = nextField;
script.dice = dice; script.dice = dice;
script.camera = cam; script.camera = cam;
itemButtons[job.data[5]].interactable = true;
} }
//player is not playable //player is not playable
else else
@@ -155,6 +163,8 @@ public class Client : MonoBehaviour
script.nextField = nextField; script.nextField = nextField;
script.dice = dice; script.dice = dice;
script.camera = cam; script.camera = cam;
itemButtons[job.data[5]].interactable = false;
} }
break; break;
+1 -1
View File
@@ -19,6 +19,6 @@ public class Item : MonoBehaviour
public enum Type 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 System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class NoPlayablePlayer : Player public class NoPlayablePlayer : Player
{ {
@@ -31,6 +32,8 @@ public class NoPlayablePlayer : Player
activated = false; activated = false;
diceScript = dice.GetComponent<Dice>(); diceScript = dice.GetComponent<Dice>();
} }
public void BuyStar() public void BuyStar()
@@ -56,6 +59,13 @@ public class NoPlayablePlayer : Player
{ {
wurfelt = true; wurfelt = true;
this.wurfelZahl = wurfelZahl; this.wurfelZahl = wurfelZahl;
if (activeItem == Item.Type.Mushroom)
{
wurfelZahl += 3;
activeItem = Item.Type.None;
}
//nächstes Feld anvisieren //nächstes Feld anvisieren
TargetNextField(); TargetNextField();
@@ -4,6 +4,7 @@ using System.Net.Mail;
using TMPro; using TMPro;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class PlayablePlayer : Player public class PlayablePlayer : Player
{ {
@@ -36,6 +37,7 @@ public class PlayablePlayer : Player
QualitySettings.vSyncCount = 0; QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 61; Application.targetFrameRate = 61;
diceScript = dice.GetComponent<Dice>(); diceScript = dice.GetComponent<Dice>();
} }
private void Update() private void Update()
@@ -53,10 +55,17 @@ public class PlayablePlayer : Player
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf //Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
if ((Input.GetMouseButtonUp(0) && !uiHandler.MapOpen) && wurfelZahl == 0 && !wurfelt) 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; wurfelt = true;
wurfelZahl = Random.Range(1, 7); wurfelZahl = Random.Range(1, 7);
if (activeItem == Item.Type.Mushroom)
{
wurfelZahl += 3;
activeItem = Item.Type.None;
}
textLeftMoves.text = wurfelZahl + ""; textLeftMoves.text = wurfelZahl + "";
client.SendWurfeln(wurfelZahl); client.SendWurfeln(wurfelZahl);
@@ -70,8 +79,6 @@ public class PlayablePlayer : Player
//delay for walk start //delay for walk start
timeSinceWurfeln = Time.time; timeSinceWurfeln = Time.time;
} }
} }
} }
} }
@@ -23,6 +23,7 @@ public abstract class Player : MonoBehaviour
public UIHandler uiHandler; public UIHandler uiHandler;
public Item[] items = new Item[3]; public Item[] items = new Item[3];
public Image[] uiItems; public Image[] uiItems;
public Item.Type activeItem = Item.Type.None;
//for coin animation //for coin animation
private AnimationHandler animationHandler; private AnimationHandler animationHandler;
@@ -84,11 +85,19 @@ public abstract class Player : MonoBehaviour
{ {
items[i] = item; items[i] = item;
uiItems[i].sprite = item.sprite; uiItems[i].sprite = item.sprite;
uiItems[i].gameObject.SetActive(true);
break; break;
} }
} }
} }
public void ActivateItem(int index, Item.Type type)
{
uiItems[index].gameObject.SetActive(false);
items[index] = null;
activeItem = type;
}
public void OnTriggerEnter(Collider c) public void OnTriggerEnter(Collider c)
{ {
eventstop = true; eventstop = true;
+6
View File
@@ -108,6 +108,12 @@ public class UIHandler : MonoBehaviour
layoutItemShop.GetComponent<ItemShop>().Init(currentPlayer); 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() public void ButtonBuyStar()
{ {
((PlayablePlayer)currentPlayer).BuyStar(true); ((PlayablePlayer)currentPlayer).BuyStar(true);
@@ -137,9 +137,7 @@ PlayerSettings:
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 0.1 bundleVersion: 0.1
preloadedAssets: preloadedAssets: []
- {fileID: -6230802382160794249, guid: 90cd1b71078984c4980fcd1aa03eaaa3, type: 2}
- {fileID: 11400000, guid: 48bf7376b3770c44cbfe3f40e77359ab, type: 2}
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 1
+1 -1
View File
@@ -89,7 +89,7 @@
<workItem from="1677445028345" duration="816000" /> <workItem from="1677445028345" duration="816000" />
<workItem from="1677520608630" duration="13000" /> <workItem from="1677520608630" duration="13000" />
<workItem from="1677789901008" duration="661000" /> <workItem from="1677789901008" duration="661000" />
<workItem from="1677881295823" duration="754000" /> <workItem from="1677881295823" duration="2233000" />
</task> </task>
<servers /> <servers />
</component> </component>
+18
View File
@@ -118,6 +118,16 @@ public class Room
timeOut = System.currentTimeMillis(); timeOut = System.currentTimeMillis();
/*
----------------------------------------
----------------------------------------
----------------------------------------
HERE IS THE ROOM / GAME LOGIC
----------------------------------------
----------------------------------------
----------------------------------------
*/
switch (readData[0]) switch (readData[0])
{ {
@@ -158,6 +168,8 @@ public class Room
} }
break; break;
//Es wurde auf ein CoinField getreten (Rot oder Blau)
//1 x, x = player; 2 y, y = Loose or Get
case 6: case 6:
for (int i = 0; i < players.length; i++) for (int i = 0; i < players.length; i++)
{ {
@@ -168,12 +180,15 @@ public class Room
} }
break; break;
//Eventstop (ItemShop, BuyStar, ...) ist fertig
//1 x, x = player
case 7: case 7:
for (int i = 0; i < players.length; i++) for (int i = 0; i < players.length; i++)
{ {
players[i].output.write(new byte[]{7, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0}); players[i].output.write(new byte[]{7, (byte)player, 0, 0, 0, 0, 0, 0, 0, 0});
} }
break; break;
//Spieler hat einen Stern gekauft
case 8: case 8:
for (int i = 0; i < players.length; i++) for (int i = 0; i < players.length; i++)
{ {
@@ -183,6 +198,9 @@ public class Room
} }
} }
break; break;
//Spieler hat ein Item Gekauft
//1 x, x = player; 2 y, y = Item.Type (byte)
case 9: case 9:
for (int i = 0; i < players.length; i++) for (int i = 0; i < players.length; i++)
{ {