Pinguin als Standardcharacter mit Animation
This commit is contained in:
@@ -45,8 +45,8 @@ public class Dice : MonoBehaviour
|
||||
{
|
||||
started = false;
|
||||
|
||||
rb.angularVelocity = new Vector3(5, 5, 5);
|
||||
rb.useGravity = true;
|
||||
rb.angularVelocity = new Vector3(0, 0, 0);
|
||||
transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
|
||||
foreach (TMP_Text t in numbers)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NamesText : MonoBehaviour
|
||||
{
|
||||
public float orgY;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0, orgY, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02c404c54096ffb47993bd51b2a3e8d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,6 +24,11 @@ public class NoPlayablePlayer : Player
|
||||
private Vector3 useLess = new Vector3();
|
||||
|
||||
private bool checkDoubleDice = false;
|
||||
|
||||
//Animation:
|
||||
private Vector3 lastPosAnim = Vector3.zero;
|
||||
private bool jumpRequest = false;
|
||||
private float lastTimeDoneIdleAction = 0, idleActionDelay = 5;
|
||||
|
||||
|
||||
public override void Init()
|
||||
@@ -34,7 +39,50 @@ public class NoPlayablePlayer : Player
|
||||
activated = false;
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
base.Start();
|
||||
lastPosAnim = transform.position;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// //Animation Control
|
||||
if (Vector3.Distance(transform.position, lastPosAnim) > 0f)
|
||||
{
|
||||
animator.SetInteger("value", 1);
|
||||
}
|
||||
else if(jumpRequest)
|
||||
{
|
||||
jumpRequest = false;
|
||||
animator.SetInteger("value", 2);
|
||||
}
|
||||
else if(Time.time - lastTimeDoneIdleAction > idleActionDelay)
|
||||
{
|
||||
lastTimeDoneIdleAction = Time.time;
|
||||
idleActionDelay = Random.Range(2f, 5f);
|
||||
int randomAction = Random.Range(3, 6);
|
||||
animator.SetInteger("value", randomAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.SetInteger("value", 0);
|
||||
}
|
||||
//END
|
||||
|
||||
if (activated && wurfelZahl > 0 && !wait)
|
||||
{
|
||||
//delay
|
||||
if (Time.time - timeSinceWurfeln > 2)
|
||||
{
|
||||
InterPolerate();
|
||||
}
|
||||
}
|
||||
|
||||
lastPosAnim = transform.position;
|
||||
}
|
||||
|
||||
public void BuyStar()
|
||||
@@ -58,6 +106,8 @@ public class NoPlayablePlayer : Player
|
||||
|
||||
public void Wurfeln(int wurfelZahl)
|
||||
{
|
||||
jumpRequest = true;
|
||||
|
||||
wurfelt = true;
|
||||
this.wurfelZahl = wurfelZahl;
|
||||
|
||||
@@ -102,15 +152,11 @@ public class NoPlayablePlayer : Player
|
||||
//Laufe zum nöchsten Feld, falls noch Züge übrig sind
|
||||
if (interPol < 1 && wurfelZahl > 0)
|
||||
{
|
||||
//delay
|
||||
if (Time.time - timeSinceWurfeln > 2)
|
||||
{
|
||||
InterPolerate();
|
||||
}
|
||||
}
|
||||
//Würfelzahl um 1 verringern falls noch züge übrig sind
|
||||
else if (wurfelZahl > 0)
|
||||
{
|
||||
InterPolerate();
|
||||
wurfelZahl--;
|
||||
textLeftMoves.text = wurfelZahl + "";
|
||||
|
||||
@@ -123,6 +169,10 @@ public class NoPlayablePlayer : Player
|
||||
//Der Spieler steht gerade
|
||||
else
|
||||
{
|
||||
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
|
||||
currentRotation.y = -34;
|
||||
transform.rotation = Quaternion.Euler(currentRotation);
|
||||
|
||||
if (!wurfelt)
|
||||
{
|
||||
StartDice();
|
||||
@@ -172,6 +222,16 @@ public class NoPlayablePlayer : Player
|
||||
if (!eventstop)
|
||||
{
|
||||
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
|
||||
//Rotation in move direction
|
||||
Vector3 lookPos = nextPoint - transform.position;
|
||||
lookPos.y = 0;
|
||||
if(lookPos != Vector3.zero)
|
||||
{
|
||||
Quaternion rotation = Quaternion.LookRotation(lookPos);
|
||||
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping);
|
||||
}
|
||||
//END
|
||||
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
|
||||
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
|
||||
}
|
||||
@@ -200,7 +260,7 @@ public class NoPlayablePlayer : Player
|
||||
{
|
||||
//start the dice
|
||||
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
|
||||
transform.position + Vector3.up * 2, ref useLess, 0.2f);
|
||||
transform.position + Vector3.up * 3, ref useLess, 0.2f);
|
||||
diceScript.StartRandom();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@ public class PlayablePlayer : Player
|
||||
public Client client;
|
||||
|
||||
private static PlayablePlayer instance;
|
||||
|
||||
//Animation:
|
||||
private Vector3 lastPosAnim = Vector3.zero;
|
||||
private Quaternion rotation = Quaternion.identity;
|
||||
private bool jumpRequest = false;
|
||||
private float lastTimeDoneIdleAction = 0, idleActionDelay = 5;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
@@ -49,15 +55,37 @@ public class PlayablePlayer : Player
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
base.Start();
|
||||
lastPosAnim = transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
/*
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
//Animation Control
|
||||
if (Vector3.Distance(transform.position, lastPosAnim) > 0)
|
||||
{
|
||||
eventstop = false;
|
||||
client.EventStopFinished();
|
||||
animator.SetInteger("value", 1);
|
||||
}
|
||||
*/
|
||||
else if(jumpRequest)
|
||||
{
|
||||
jumpRequest = false;
|
||||
animator.SetInteger("value", 2);
|
||||
}
|
||||
else if(Time.time - lastTimeDoneIdleAction > idleActionDelay)
|
||||
{
|
||||
lastTimeDoneIdleAction = Time.time;
|
||||
idleActionDelay = Random.Range(2f, 5f);
|
||||
int randomAction = Random.Range(3, 6);
|
||||
animator.SetInteger("value", randomAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.SetInteger("value", 0);
|
||||
}
|
||||
//END
|
||||
|
||||
if (activated && !name.Equals(""))
|
||||
{
|
||||
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
|
||||
@@ -69,10 +97,23 @@ public class PlayablePlayer : Player
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activated && wurfelZahl > 0 && !wait)
|
||||
{
|
||||
//delay
|
||||
if (Time.time - timeSinceWurfeln > 2)
|
||||
{
|
||||
InterPolerate();
|
||||
}
|
||||
}
|
||||
|
||||
lastPosAnim = transform.position;
|
||||
}
|
||||
|
||||
private void DiceRollRoutine()
|
||||
{
|
||||
jumpRequest = true;
|
||||
|
||||
wurfelt = true;
|
||||
wurfelZahl = Random.Range(1, 7);
|
||||
|
||||
@@ -88,17 +129,6 @@ public class PlayablePlayer : Player
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
if (activeItem == Item.Type.Mushroom)
|
||||
{
|
||||
wurfelZahl += 3;
|
||||
activeItem = Item.Type.None;
|
||||
}else if (activeItem == Item.Type.DoubleDice)
|
||||
{
|
||||
checkDoubleDice = true;
|
||||
}
|
||||
*/
|
||||
|
||||
textLeftMoves.text = wurfelZahl + "";
|
||||
|
||||
client.SendWurfeln(wurfelZahl);
|
||||
@@ -125,11 +155,6 @@ public class PlayablePlayer : Player
|
||||
//Laufe zum nöchsten Feld, falls noch Züge übrig sind
|
||||
if (interPol < 1 && wurfelZahl > 0)
|
||||
{
|
||||
//delay
|
||||
if (Time.time - timeSinceWurfeln > 2)
|
||||
{
|
||||
InterPolerate();
|
||||
}
|
||||
}
|
||||
//Würfelzahl um 1 verringern falls noch züge übrig sind
|
||||
else if (wurfelZahl > 0)
|
||||
@@ -149,6 +174,10 @@ public class PlayablePlayer : Player
|
||||
//Der Spieler steht gerade
|
||||
else
|
||||
{
|
||||
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
|
||||
currentRotation.y = -34;
|
||||
transform.rotation = Quaternion.Euler(currentRotation);
|
||||
|
||||
//TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde
|
||||
if (wurfelt)
|
||||
{
|
||||
@@ -233,6 +262,7 @@ public class PlayablePlayer : Player
|
||||
{
|
||||
wait = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Bewegt den Player von einem Punkt(lastPos) zu einem anderen Punkt(moveTo) mit konstanter Geschwindigkeit
|
||||
@@ -244,6 +274,17 @@ public class PlayablePlayer : Player
|
||||
if (!eventstop)
|
||||
{
|
||||
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
|
||||
|
||||
//Rotation in move direction
|
||||
Vector3 lookPos = nextPoint - transform.position;
|
||||
lookPos.y = 0;
|
||||
if(lookPos != Vector3.zero)
|
||||
{
|
||||
Quaternion rotation = Quaternion.LookRotation(lookPos);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping);
|
||||
}
|
||||
//END
|
||||
|
||||
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
|
||||
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
|
||||
}
|
||||
@@ -307,7 +348,7 @@ public class PlayablePlayer : Player
|
||||
{
|
||||
//start the dice
|
||||
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
|
||||
transform.position + Vector3.up * 2, ref useLess, 0.2f);
|
||||
transform.position + Vector3.up * 3f, ref useLess, 0.2f);
|
||||
diceScript.StartRandom();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,16 @@ public abstract class Player : MonoBehaviour
|
||||
public UIHandler uiHandler;
|
||||
public Item[] items = new Item[3];
|
||||
public Item.Type activeItem = Item.Type.None;
|
||||
protected float rotationDamping = 10;
|
||||
|
||||
protected Animator animator;
|
||||
|
||||
//for coin animation
|
||||
private AnimationHandler animationHandler;
|
||||
|
||||
private void Start()
|
||||
protected void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
animationHandler = GetComponentInChildren<AnimationHandler>();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,13 +56,13 @@ public class UIHandler : MonoBehaviour
|
||||
|
||||
public void ActivateLayoutMiniMap()
|
||||
{
|
||||
layout0.SetActive(false);
|
||||
layout1.SetActive(false);
|
||||
layoutMiniMap.SetActive(true);
|
||||
layoutBuyStar.SetActive(false);
|
||||
layout2.SetActive(false);
|
||||
layoutItemShop.SetActive(false);
|
||||
layoutSelectItem.SetActive(false);
|
||||
// layout0.SetActive(false);
|
||||
// layout1.SetActive(false);
|
||||
// layoutMiniMap.SetActive(true);
|
||||
// layoutBuyStar.SetActive(false);
|
||||
// layout2.SetActive(false);
|
||||
// layoutItemShop.SetActive(false);
|
||||
// layoutSelectItem.SetActive(false);
|
||||
}
|
||||
|
||||
public void ActivateLayoutBuyStar(Player player)
|
||||
|
||||
Reference in New Issue
Block a user