using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//using Photon.Pun;
public class Movimento : MonoBehaviour
{
//MonoBehaviourPun // IPunObservable
public bool direita = false, esquerda = false;
public float moveSpeed = 6;
private Rigidbody2D rb;
private bool AllowMoving = true;
void Awake(){
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate(){
//if (photonView.IsMine && !isDead)
//{
MovimentoGame ();
//}
}
void MovimentoGame () {
int movement = 0;
if (direita) {
//sr.flipX = true;
movement -= 1;
}
if (esquerda) {
//sr.flipX = false;
movement += 1;
}
if (movement != 0)
//pv.RPC (movement > 0 ? "OnDirectionChange_LEFT" : "OnDirectionChange_RIGHT", RpcTarget.Others);
//m_Animator.SetBool ("Andando", movement != 0);
if (AllowMoving && Mathf.Abs (movement) > 0) {
Vector2 vel = rb.velocity;
vel.x = movement * moveSpeed;
rb.velocity = vel;
}
else {rb.velocity = new Vector2(0,rb.velocity.y);}
}
//[PunRPC]
//void OnDirectionChange_LEFT () {
// sr.flipX = false;
//}
//[PunRPC]
//void OnDirectionChange_RIGHT () {
//sr.flipX = true;
//}
}