Linked Rotator with Pink Field
This commit is contained in:
@@ -282,6 +282,14 @@ public class Client : MonoBehaviour
|
||||
case 12:
|
||||
((NoPlayablePlayer)players[job.data[1]]).pinkFieldLostItem(job.data[2]);
|
||||
break;
|
||||
case 13:
|
||||
int amount = job.data[2];
|
||||
if (job.data[1] == 0)
|
||||
{
|
||||
amount *= -1;
|
||||
}
|
||||
players[job.data[3]].AddCoins(amount);
|
||||
break;
|
||||
case 126:
|
||||
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
|
||||
break;
|
||||
@@ -387,4 +395,16 @@ public class Client : MonoBehaviour
|
||||
{
|
||||
stream.Write(new byte[]{12, index, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
|
||||
public void SendCoins(int amount)
|
||||
{
|
||||
byte isPositive = 1;
|
||||
if (amount < 0)
|
||||
{
|
||||
isPositive = 0;
|
||||
}
|
||||
|
||||
|
||||
stream.Write(new byte[]{13, isPositive, (byte)amount, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,7 @@ public class NoPlayablePlayer : Player
|
||||
currentRotation.y = -34;
|
||||
transform.rotation = Quaternion.Euler(currentRotation);
|
||||
|
||||
|
||||
if (!wurfelt)
|
||||
{
|
||||
StartDice();
|
||||
|
||||
@@ -19,6 +19,8 @@ public class PlayablePlayer : Player
|
||||
private float interPol = 0;
|
||||
private int wurfelZahl = 0;
|
||||
private bool checkDoubleDice = false;
|
||||
private RandomRotator rotator;
|
||||
private int rotatorStopIndex = 0;
|
||||
|
||||
private bool wait = false;
|
||||
|
||||
@@ -49,10 +51,6 @@ public class PlayablePlayer : Player
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
|
||||
instance = this;
|
||||
|
||||
AddItem(client.items[1]);
|
||||
AddItem(client.items[0]);
|
||||
AddItem(client.items[2]);
|
||||
}
|
||||
|
||||
public static PlayablePlayer GetCurrentInstance()
|
||||
@@ -112,7 +110,7 @@ public class PlayablePlayer : Player
|
||||
jumpRequest = true;
|
||||
|
||||
wurfelt = true;
|
||||
wurfelZahl = Random.Range(1, 7);
|
||||
wurfelZahl = Random.Range(4, 5);
|
||||
|
||||
switch (activeItem)
|
||||
{
|
||||
@@ -198,10 +196,15 @@ public class PlayablePlayer : Player
|
||||
currentRotation.y = -34;
|
||||
transform.rotation = Quaternion.Euler(currentRotation);
|
||||
|
||||
int fieldReturnStatus = -1;
|
||||
if (currentField != null)
|
||||
{
|
||||
fieldReturnStatus = currentField.Action(index);
|
||||
}
|
||||
|
||||
//TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde
|
||||
if (wurfelt)
|
||||
{
|
||||
int fieldReturnStatus = currentField.Action(index);
|
||||
|
||||
switch (fieldReturnStatus)
|
||||
{
|
||||
@@ -213,49 +216,96 @@ public class PlayablePlayer : Player
|
||||
client.SendCoinFieldAction(1);
|
||||
AddCoins(-3);
|
||||
break;
|
||||
case 2: //pinkes Feld
|
||||
int randyPinkField = Random.Range(4, 4);
|
||||
int tempCurrentItems = -1;
|
||||
switch (randyPinkField)
|
||||
// case 2: //pinkes Feld
|
||||
// int randyPinkField = Random.Range(4, 4);
|
||||
// int tempCurrentItems = -1;
|
||||
// switch (randyPinkField)
|
||||
// {
|
||||
// case 1:
|
||||
// client.SendCoinFieldAction(0);
|
||||
// int tempAddCoins = Random.Range(3, 6);
|
||||
// AddCoins(tempAddCoins);
|
||||
// break;
|
||||
// case 2:
|
||||
// client.SendCoinFieldAction(1);
|
||||
// int tempLoseCoins = Random.Range(-3, -6);
|
||||
// AddCoins(tempLoseCoins);
|
||||
// break;
|
||||
// case 3:
|
||||
// int tempAddItem = Random.Range(0, 3);
|
||||
// AddItem(client.items[tempAddItem]);
|
||||
// break;
|
||||
// case 4:
|
||||
// for (int i = 0; i < items.Length; i++)
|
||||
// {
|
||||
// if (items[i] != null)
|
||||
// {
|
||||
// tempCurrentItems++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (tempCurrentItems >= 0)
|
||||
// {
|
||||
// int pickRandomItem = Random.Range(0, tempCurrentItems);
|
||||
// client.items[pickRandomItem] = null;
|
||||
// itemInfoImages[pickRandomItem].color = new Color(0, 0, 0, 0);
|
||||
// client.SendLostItem((byte)pickRandomItem);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
case 2:
|
||||
|
||||
|
||||
int randCoins1 = Random.Range(2, 12);
|
||||
int randCoins2 = Random.Range(5, 10);
|
||||
int randCoins3 = Random.Range(-6, 0);
|
||||
|
||||
RandomRotator rotator = uiHandler.rotator.GetComponent<RandomRotator>();
|
||||
this.rotator = rotator;
|
||||
uiHandler.ActivateRotator();
|
||||
rotator.SetOptionsText(0, randCoins1 + " Coins");
|
||||
rotator.SetOptionsText(1, randCoins2 + " Coins");
|
||||
rotator.SetOptionsText(2, randCoins3 + " Coins");
|
||||
rotator.SetOptionsText(3, "Random Item");
|
||||
|
||||
rotator.StartRandom();
|
||||
|
||||
int randomOption = Random.Range(0, 4);
|
||||
switch (randomOption)
|
||||
{
|
||||
case 0:
|
||||
AddCoins(randCoins1);
|
||||
client.SendCoins(randCoins1);
|
||||
break;
|
||||
case 1:
|
||||
client.SendCoinFieldAction(0);
|
||||
int tempAddCoins = Random.Range(3, 6);
|
||||
AddCoins(tempAddCoins);
|
||||
AddCoins(randCoins2);
|
||||
client.SendCoins(randCoins2);
|
||||
break;
|
||||
case 2:
|
||||
client.SendCoinFieldAction(1);
|
||||
int tempLoseCoins = Random.Range(-3, -6);
|
||||
AddCoins(tempLoseCoins);
|
||||
AddCoins(randCoins3);
|
||||
client.SendCoins(randCoins3);
|
||||
break;
|
||||
case 3:
|
||||
int tempAddItem = Random.Range(0, 2);
|
||||
AddItem(client.items[tempAddItem]);
|
||||
break;
|
||||
case 4:
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
if (items[i] != null)
|
||||
{
|
||||
tempCurrentItems++;
|
||||
}
|
||||
}
|
||||
|
||||
if (tempCurrentItems >= 0)
|
||||
{
|
||||
int pickRandomItem = Random.Range(0, tempCurrentItems);
|
||||
client.items[pickRandomItem] = null;
|
||||
itemInfoImages[pickRandomItem].color = new Color(0, 0, 0, 0);
|
||||
client.SendLostItem((byte)pickRandomItem);
|
||||
}
|
||||
int randomItem = Random.Range(0, 3);
|
||||
AddItem(client.items[randomItem]);
|
||||
break;
|
||||
}
|
||||
|
||||
rotatorStopIndex = randomOption;
|
||||
Invoke("StopRotator", 4);
|
||||
Invoke("ActivateLayout1", 7.5f);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!checkDoubleDice)
|
||||
{
|
||||
Invoke("Finish", 2);
|
||||
if(fieldReturnStatus != 2)
|
||||
{
|
||||
Invoke("Finish", 2);
|
||||
}
|
||||
|
||||
activated = false;
|
||||
}
|
||||
else
|
||||
@@ -430,4 +480,15 @@ public class PlayablePlayer : Player
|
||||
}
|
||||
items[index] = null;
|
||||
}
|
||||
|
||||
private void ActivateLayout1()
|
||||
{
|
||||
uiHandler.ActivateLayout1();
|
||||
Finish();
|
||||
}
|
||||
|
||||
private void StopRotator()
|
||||
{
|
||||
rotator.Stop(rotatorStopIndex);
|
||||
}
|
||||
}
|
||||
@@ -13,17 +13,13 @@ public class RandomRotator : MonoBehaviour
|
||||
private int currentIndex = 0;
|
||||
private float lastTimeSwitched = 0;
|
||||
private int stopIndex = 0;
|
||||
public UIHandler uiHandler;
|
||||
|
||||
public void SetOptionsText(int index, string text)
|
||||
{
|
||||
textOptions[index].text = text;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartRandom();
|
||||
}
|
||||
|
||||
private void ColorOption(int index)
|
||||
{
|
||||
for (int i = 0; i < options.Length; i++)
|
||||
@@ -39,16 +35,17 @@ public class RandomRotator : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private float slowDown = 0.5f;
|
||||
private void Update()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
if (Time.time - lastTimeSwitched > 0.1f)
|
||||
if (Time.time - lastTimeSwitched > 0.2f)
|
||||
{
|
||||
lastTimeSwitched = Time.time;
|
||||
ColorOption(currentIndex);
|
||||
currentIndex++;
|
||||
if (currentIndex > options.Length - 1)
|
||||
if (currentIndex > options.Length)
|
||||
{
|
||||
currentIndex = 0;
|
||||
}
|
||||
@@ -56,7 +53,24 @@ public class RandomRotator : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorOption(stopIndex);
|
||||
if (currentIndex != stopIndex)
|
||||
{
|
||||
if (Time.time - lastTimeSwitched > slowDown)
|
||||
{
|
||||
slowDown += 0.2f;
|
||||
lastTimeSwitched = Time.time;
|
||||
ColorOption(currentIndex);
|
||||
currentIndex++;
|
||||
if (currentIndex > options.Length)
|
||||
{
|
||||
currentIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorOption(stopIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public class UIHandler : MonoBehaviour
|
||||
[SerializeField] private GameObject layoutItemShop;
|
||||
[SerializeField] private GameObject layoutSelectItem;
|
||||
[SerializeField] private GameObject layoutOptions;
|
||||
[SerializeField] public GameObject rotator;
|
||||
|
||||
private static UIHandler currentInstance;
|
||||
|
||||
@@ -45,6 +46,7 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
|
||||
currentInstance = this;
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
}
|
||||
|
||||
public void ActivateLayoutMiniMap()
|
||||
@@ -83,6 +86,7 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
|
||||
LayoutBuyStarController controller = layoutBuyStar.GetComponent<LayoutBuyStarController>();
|
||||
|
||||
@@ -110,6 +114,7 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
}
|
||||
|
||||
public void ActivateLayoutItemShop()
|
||||
@@ -123,6 +128,7 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.GetComponent<ItemShop>().Init(currentPlayer);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +146,7 @@ public class UIHandler : MonoBehaviour
|
||||
layout2.SetActive(false);
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(false);
|
||||
|
||||
layoutSelectItem.GetComponent<ItemSelector>().Init(currentPlayer.items);
|
||||
|
||||
@@ -157,6 +164,21 @@ public class UIHandler : MonoBehaviour
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(true);
|
||||
rotator.SetActive(false);
|
||||
}
|
||||
|
||||
public void ActivateRotator()
|
||||
{
|
||||
rotator.GetComponent<RandomRotator>().uiHandler = this;
|
||||
layout0.SetActive(false);
|
||||
layout1.SetActive(false);
|
||||
layoutMiniMap.SetActive(false);
|
||||
layoutBuyStar.SetActive(false);
|
||||
layout2.SetActive(false);
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
layoutOptions.SetActive(false);
|
||||
rotator.SetActive(true);
|
||||
}
|
||||
|
||||
public void ButtonBuyStar()
|
||||
|
||||
Reference in New Issue
Block a user