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