void CmdHide(HideInfo hideInfo) { if (hasAuthority) { InjectHide(hideInfo); } }
private void OnHide(HideInfo hideInfo) { if (!hasAuthority) { this.hideInfo = hideInfo; Box box = BoxMgr.instance.GetBox(hideInfo.id); if (box != null) { box.Open(); if (hideInfo.hide) { thisTransform.position = box.transform.position; } else { thisTransform.position = box.GetOutPos(); thisTransform.rotation = box.GetOutRotation(); } } } if (hideInfo.hide) { controller.enabled = false; stateMachine.SetState(PlayerStateMachine.PlayerState.Jump); Scheduler.Create(this, (sche, t, s) => { if (this.hideInfo.hide) { stateMachine.SetState(PlayerStateMachine.PlayerState.Idle); model.SetActive(false); } }, 0f, 0f, 0.4f); } else { controller.enabled = true; model.SetActive(true); } if (!hideInfo.hide && sightController.InSight) { if (hudControl != null) { hudControl.Show(); } else if (hudControl != null) { hudControl.Hide(); } } if (isLocalPlayer) { EventMgr.instance.TriggerEvent <bool>("SwitchHide", hideInfo.hide); } }
void InjectHide(HideInfo hideInfo) { if (this.hideInfo.hide == hideInfo.hide && this.hideInfo.id == hideInfo.id) { return; } Box box = BoxMgr.instance.GetBox(hideInfo.id); if (box == null) { return; } if (hideInfo.hide) { TestController player = box.GetHider(); if (player == null) { // 箱子里没人,则躲进箱子 thisTransform.position = box.transform.position; box.SetHider(this); this.hideInfo = hideInfo; RpcHide(netId, hideInfo); } else { // 箱子里有人,则抓人 BeCaught(player); HideInfo newhideInfo; newhideInfo.hide = false; newhideInfo.id = hideInfo.id; player.InjectHide(newhideInfo); RpcHide(player.netId, newhideInfo); } } else { // 跳出箱子 this.hideInfo = hideInfo; thisTransform.position = box.GetOutPos(); thisTransform.rotation = box.GetOutRotation(); box.SetHider(null); RpcHide(netId, hideInfo); } }
public void RpcHide(NetworkInstanceId netId, HideInfo hideInfo) { if (mySelf == null) { return; } Box box = BoxMgr.instance.GetBox(hideInfo.id); if (box == null) { return; } if (SightMgr.instance.Check(mySelf.sightController, mySelf.sightRange, mySelf.sightAngle, mySelf.bodyRadius * 4, box.gameObject)) { return; } if (mySelf.hudControl != null && Vector3.Distance(box.transform.position, mySelf.thisTransform.position) < WARN_DISTANCE) { mySelf.hudControl.ShowWarnIcon(1.0f); mySelf.hudControl.ShoweHudTip("听到箱子的声音!"); } }