You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.3 KiB
97 lines
2.3 KiB
using AX.Network.Protocols; |
|
using AX.NetworkSystem; |
|
using AX.Serialization; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ForcibleCtrl : MonoBehaviour |
|
{ |
|
public ForcibleType ForcibleType; |
|
|
|
private float width; |
|
private float hight; |
|
public float widthOpen; |
|
public float hightOpen; |
|
|
|
public float Width |
|
{ |
|
get |
|
{ |
|
return width; |
|
} |
|
|
|
set |
|
{ |
|
width = value; |
|
SetWidth(value); |
|
} |
|
} |
|
|
|
public float Hight |
|
{ |
|
get |
|
{ |
|
return hight; |
|
} |
|
|
|
set |
|
{ |
|
hight = value; |
|
SetHight(value); |
|
} |
|
} |
|
private void Awake() |
|
{ |
|
Hight = transform.localScale.y; |
|
width = transform.localScale.x; |
|
NetworkMessageDispatcher.AddListener("FORCIBLE_SCALE_SYNC", ForcibleSyncFunc); |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
NetworkMessageDispatcher.RemoveListener("FORCIBLE_SCALE_SYNC", ForcibleSyncFunc); |
|
} |
|
private void ForcibleSyncFunc(BinaryMessage obj) |
|
{ |
|
var data = obj.Body.Deserialize<ForcibleSyncData>(); |
|
|
|
if (data.gameObjID == GetComponent<CloneGameObjInfo>().gameObjID) |
|
{ |
|
if (CurrentUserInfo.mySelf.Id != data.SendUserID) |
|
{ |
|
Set(data.Hight,data.Width); |
|
} |
|
} |
|
} |
|
private void SetHight(float hight) |
|
{ |
|
transform.localScale = new Vector3(transform.localScale.x, hight, transform.localScale.z); |
|
//if (ForcibleType == ForcibleType.ForcibleDoor) |
|
//{ |
|
// transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y + (hight - transform.localPosition.y) / 2, transform.localPosition.z); |
|
//} |
|
} |
|
private void SetWidth(float width) |
|
{ |
|
transform.localScale = new Vector3(width, transform.localScale.y, transform.localScale.z); |
|
} |
|
// Start is called before the first frame update |
|
public void RecordOpenData() |
|
{ |
|
hightOpen = transform.localScale.y; |
|
widthOpen = transform.localScale.x; |
|
} |
|
public void ResertAtOpenData() |
|
{ |
|
Hight = hightOpen; |
|
Width = widthOpen; |
|
} |
|
public void Set(float hight,float width) |
|
{ |
|
Hight = hight; |
|
Width = width; |
|
RecordOpenData(); |
|
} |
|
}
|
|
|