Server fixes and attack anim
This commit is contained in:
parent
915775e834
commit
b345dfc48b
|
|
@ -17,29 +17,33 @@ public class PlayerAttack : NetworkBehaviour{
|
||||||
|
|
||||||
public GameObject leftAnim,rightAnim,upAnim,downAnim;
|
public GameObject leftAnim,rightAnim,upAnim,downAnim;
|
||||||
|
|
||||||
|
void Awake(){
|
||||||
|
pnet.playerAttack = this;
|
||||||
|
}
|
||||||
|
|
||||||
void Start(){
|
void Start(){
|
||||||
if(!isLocalPlayer){
|
if(!isLocalPlayer){
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Update(){
|
// void Update(){
|
||||||
//Get player look dir
|
// //Get player look dir
|
||||||
if(timeBetweenAttacks <=0){
|
// if(timeBetweenAttacks <=0){
|
||||||
if(Input.GetMouseButtonDown(0)){
|
// if(Input.GetMouseButtonDown(0)){
|
||||||
StartCoroutine(couroutineAttack());
|
// StartCoroutine(couroutineAttack());
|
||||||
timeBetweenAttacks = startTimeBtwAttacks;
|
// timeBetweenAttacks = startTimeBtwAttacks;
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
timeBetweenAttacks -= Time.deltaTime;
|
// timeBetweenAttacks -= Time.deltaTime;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
IEnumerator couroutineAttack(){
|
IEnumerator couroutineAttack(){
|
||||||
yield return new WaitForSecondsRealtime(0.6f);
|
yield return new WaitForSecondsRealtime(0.6f);
|
||||||
Attack();
|
Attack();
|
||||||
}
|
}
|
||||||
void Attack(){
|
public void Attack(){
|
||||||
|
|
||||||
Vector3 direction = GetPlayerLookDir();
|
Vector3 direction = GetPlayerLookDir();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@ public class gplayAuth : MonoBehaviour{
|
||||||
|
|
||||||
public TMP_InputField saveName, coins, item1, item2, item3 ;
|
public TMP_InputField saveName, coins, item1, item2, item3 ;
|
||||||
public TMP_Text saveStatText;
|
public TMP_Text saveStatText;
|
||||||
public TMP_Text saveNameTxt , coinsTxt, item1Txt, item2Txt, item3Txt;
|
public static string userNameCloud;
|
||||||
|
|
||||||
|
public TMP_Text saveNameTxt , coinsTxt, item1Txt, item2Txt, item3Txt;
|
||||||
|
#if UNITY_ANDROID
|
||||||
void Start() {
|
void Start() {
|
||||||
IsConnected =false;
|
IsConnected =false;
|
||||||
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestServerAuthCode(false)
|
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestServerAuthCode(false)
|
||||||
|
|
@ -37,7 +39,6 @@ public class gplayAuth : MonoBehaviour{
|
||||||
//GPGSLogin();
|
//GPGSLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string userNameCloud;
|
|
||||||
|
|
||||||
public void GPGSLogin(){
|
public void GPGSLogin(){
|
||||||
PlayGamesPlatform.Instance.Authenticate((success) => {
|
PlayGamesPlatform.Instance.Authenticate((success) => {
|
||||||
|
|
@ -241,4 +242,6 @@ public class gplayAuth : MonoBehaviour{
|
||||||
//load game scene
|
//load game scene
|
||||||
SceneManager.LoadScene("MenuScene");
|
SceneManager.LoadScene("MenuScene");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ using UnityEngine.UI;
|
||||||
|
|
||||||
public class playerNetwork : NetworkBehaviour
|
public class playerNetwork : NetworkBehaviour
|
||||||
{
|
{
|
||||||
|
public const float ATTACK_COOLDOWN = 0.6f;
|
||||||
|
|
||||||
//public const int XPFORLEVEL = 10;
|
//public const int XPFORLEVEL = 10;
|
||||||
[SyncVar(hook =nameof(OnHealthChanged))] public int health = 100;
|
[SyncVar(hook =nameof(OnHealthChanged))] public int health = 100;
|
||||||
public Character4D character;
|
public Character4D character;
|
||||||
|
|
@ -297,9 +299,14 @@ public class playerNetwork : NetworkBehaviour
|
||||||
character.AnimationManager.SetState((CharacterState)newVal);
|
character.AnimationManager.SetState((CharacterState)newVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float attackTimer = 0;
|
||||||
|
[HideInInspector]
|
||||||
|
public PlayerAttack playerAttack;
|
||||||
void Update(){
|
void Update(){
|
||||||
if(isLocalPlayer){
|
if(isLocalPlayer){
|
||||||
|
|
||||||
|
if(attackTimer >0){attackTimer-=Time.deltaTime;}
|
||||||
|
|
||||||
if(isServer){
|
if(isServer){
|
||||||
SetAnimationData(character.Direction, character.Animator.GetInteger("State"));
|
SetAnimationData(character.Direction, character.Animator.GetInteger("State"));
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -520,8 +527,14 @@ public class playerNetwork : NetworkBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAttack(){
|
public void OnAttack(){
|
||||||
|
if(attackTimer > 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
attackTimer = ATTACK_COOLDOWN;
|
||||||
if(isLocalPlayer){
|
if(isLocalPlayer){
|
||||||
PlayAttackAnim();
|
PlayAttackAnim();
|
||||||
|
playerAttack.Attack();
|
||||||
if(isServer){
|
if(isServer){
|
||||||
RpcPlayAttackAnim();
|
RpcPlayAttackAnim();
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -543,7 +556,7 @@ public class playerNetwork : NetworkBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayAttackAnim(){
|
void PlayAttackAnim(){
|
||||||
switch (character.WeaponType)
|
switch (character.WeaponType)
|
||||||
{
|
{
|
||||||
case WeaponType.Melee1H:
|
case WeaponType.Melee1H:
|
||||||
case WeaponType.Paired:
|
case WeaponType.Paired:
|
||||||
|
|
@ -607,7 +620,7 @@ public class playerNetwork : NetworkBehaviour
|
||||||
startClient.instance.networkManager.StopClient();
|
startClient.instance.networkManager.StopClient();
|
||||||
SceneManager.LoadScene("GameLogin");
|
SceneManager.LoadScene("GameLogin");
|
||||||
|
|
||||||
PlayGamesPlatform.Instance.SignOut();
|
// PlayGamesPlatform.Instance.SignOut();
|
||||||
Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();
|
Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user