Coin Animation (not synced)

AnimationHandler
This commit is contained in:
brausjonas
2023-01-31 23:21:50 +01:00
parent b479594017
commit 4157107813
16 changed files with 420 additions and 16 deletions
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationHandler : MonoBehaviour
{
[SerializeField] private Animator anim;
public void StartAnimation()
{
anim.SetInteger("value", 1);
Invoke("Stop", 0.6f);
}
private void Stop()
{
anim.SetInteger("value", 0);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 787dbc4f3dfef2342a9cc6b5a6b706e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -43,7 +43,7 @@ public class PlayablePlayer : Player
if ((Input.GetMouseButtonDown(0)) && wurfelZahl == 0 && !wurfelt)
{
wurfelt = true;
wurfelZahl = Random.Range(1, 7);
wurfelZahl = Random.Range(3, 4);
client.SendWurfeln(wurfelZahl);
@@ -96,7 +96,15 @@ public class PlayablePlayer : Player
//TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde
if (wurfelt)
{
currentField.Action(index);
int fieldReturnStatus = currentField.Action(index);
switch (fieldReturnStatus)
{
case 0:
PlayAnimation(AnimationType.Coin);
break;
}
Invoke("Finish", 2);
activated = false;
}
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -15,6 +16,14 @@ public abstract class Player : MonoBehaviour
public int index;
public int coins = 0;
//for coin animation
private AnimationHandler animationHandler;
private void Start()
{
animationHandler = GetComponentInChildren<AnimationHandler>();
}
//Aktiviert den Player
public void Activate()
{
@@ -29,4 +38,19 @@ public abstract class Player : MonoBehaviour
}
public abstract void Init();
public void PlayAnimation(AnimationType animationType)
{
switch (animationType)
{
case AnimationType.Coin:
animationHandler.StartAnimation();
break;
}
}
public enum AnimationType
{
Coin
}
}