Better Coin Animation
This commit is contained in:
@@ -7,9 +7,14 @@ public class AnimationHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Animator anim;
|
||||
|
||||
public void StartAnimation()
|
||||
public void StartAnimation(Player.AnimationType type)
|
||||
{
|
||||
anim.SetInteger("value", 1);
|
||||
switch (type)
|
||||
{
|
||||
case Player.AnimationType.Coin:
|
||||
anim.SetInteger("value", 1);
|
||||
break;
|
||||
}
|
||||
Invoke("Stop", 0.6f);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,18 @@ public class NoPlayablePlayer : Player
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
}
|
||||
|
||||
public void CoinFieldAction(int action)
|
||||
{
|
||||
if (action == 0)
|
||||
{
|
||||
AddCoins(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddCoins(-3);
|
||||
}
|
||||
}
|
||||
|
||||
public void Wurfeln(int wurfelZahl)
|
||||
{
|
||||
wurfelt = true;
|
||||
|
||||
@@ -101,7 +101,12 @@ public class PlayablePlayer : Player
|
||||
switch (fieldReturnStatus)
|
||||
{
|
||||
case 0:
|
||||
PlayAnimation(AnimationType.Coin);
|
||||
client.SendCoinFieldAction(0);
|
||||
AddCoins(3);
|
||||
break;
|
||||
case 1:
|
||||
client.SendCoinFieldAction(1);
|
||||
AddCoins(-3);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Player : MonoBehaviour
|
||||
@@ -15,6 +16,7 @@ public abstract class Player : MonoBehaviour
|
||||
protected Vector3 cameraOffset = new Vector3(-2.81f, 8.13f, 5.6f);
|
||||
public int index;
|
||||
public int coins = 0;
|
||||
public TMP_Text textCoinsInfo;
|
||||
|
||||
//for coin animation
|
||||
private AnimationHandler animationHandler;
|
||||
@@ -41,16 +43,18 @@ public abstract class Player : MonoBehaviour
|
||||
|
||||
public void PlayAnimation(AnimationType animationType)
|
||||
{
|
||||
switch (animationType)
|
||||
{
|
||||
case AnimationType.Coin:
|
||||
animationHandler.StartAnimation();
|
||||
break;
|
||||
}
|
||||
animationHandler.StartAnimation(animationType);
|
||||
}
|
||||
|
||||
public enum AnimationType
|
||||
{
|
||||
Coin
|
||||
}
|
||||
|
||||
protected void AddCoins(int amount)
|
||||
{
|
||||
coins += amount;
|
||||
textCoinsInfo.text = coins + "";
|
||||
PlayAnimation(AnimationType.Coin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerInfoElements : MonoBehaviour
|
||||
{
|
||||
public TMP_Text textCoinInfo;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b65775f940b73c46b505f5402bf704b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user