public override void SetTarget(Transform tag) { if (target == null) { target = tag; EnemySendClientManager._Instance.SendEnemyTargetMsg(NetworkTools.GetLocalIP(), id, listNum); } }
public void Awake() { if (!NetworkTools.GetLocalIP().Equals(RoomSingle.roomIP)) { Destroy(gameObject); return; } }
public override void ReduceHP(float hurt) { base.ReduceHP(hurt); EventCenterManager._Instance.SendMessage(EventType.UpdatePlayerUI, NetworkTools.GetLocalIP(), playerData.MaxHp, playerData.Hp); if (playerData.Hp <= 0) { SwitchPlayerState(PlayerState.Death); } }
public void Awake() { base.BaseAwake(); if (!NetworkTools.GetLocalIP().Equals(RoomSingle.roomIP)) { Destroy(gameObject); return; } NetworkManager._Instance.AddCallBack(63, GetNetworkMsgCallBack); }
private void OnDestroy() { if (isTest) { NetworkManager._Instance.CloseBattleServer(); return; } if (RoomSingle.roomIP.Equals(NetworkTools.GetLocalIP())) { NetworkManager._Instance.CloseBattleServer(); } }
public void Awake() { base.BaseAwake(); if (!NetworkTools.GetLocalIP().Equals(RoomSingle.roomIP)) { Destroy(this); return; } boss = GetComponent <Boss>(); NetworkManager._Instance.AddCallBack(71, GetNetworkMsgCallBack); NetworkManager._Instance.AddCallBack(72, GetNetworkMsgCallBack); }
protected override void GetNetworkMsgCallBack(params object[] obj_arr) { NetworkMessage message = (NetworkMessage)obj_arr[0]; if (message.type == 72 && !message.ip.Equals(NetworkTools.GetLocalIP())) { AddMessage(message); } else if (message.type == 71 && !message.ip.Equals(NetworkTools.GetLocalIP())) { AddMessage(message); } }
void SwitchGunCallBack(params object[] obj_arr) { int id = (int)obj_arr[0]; if (id == RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID) { gun1Use.SetActive(true); gun2Use.SetActive(false); } else if (id == RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID) { gun1Use.SetActive(false); gun2Use.SetActive(true); } }
public override void Open() { gunTxt.Clear(); gunIm.Clear(); base.Open(); foreach (var item in playerDic.Keys) { Destroy(playerDic[item]); } playerDic.Clear(); foreach (var item in RoomSingle.GetInfos().Keys) { if (NetworkTools.GetLocalIP().Equals(item)) { continue;//忽略自己 } GameObject obj = Instantiate <GameObject>(playerPrefab, playerParent.transform); obj.SetActive(true); obj.transform.localScale = Vector3.one; BattlePlayerUI bpui = obj.GetComponent <BattlePlayerUI>(); bpui.UpdatePanel(item, 1, 1);//初始让其满血 playerDic.Add(item, bpui); } gunIm.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, gun1Image); gunIm.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, gun2Image); gunTxt.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, gun1Text); gunTxt.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, gun2Text); gun1Image.sprite = Resources.Load <Sprite>("UI/WeaponIcon/Gun" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID); gun2Image.sprite = Resources.Load <Sprite>("UI/WeaponIcon/Gun" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID); GunRow g1Row = GunModel_S.Instance.GetGunInfo(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID); UpdateGunMessage(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, g1Row.Cartridge, g1Row.CarryCap); GunRow g2Row = GunModel_S.Instance.GetGunInfo(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID); UpdateGunMessage(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, g2Row.Cartridge, g2Row.CarryCap); hpImage.fillAmount = 1; gun1Use.SetActive(true); gun2Use.SetActive(false); EventCenterManager._Instance.AddListener(EventType.UpdatePlayerUI, UpdatePlayerMsgCallBack); EventCenterManager._Instance.AddListener(EventType.UpdateBattleGunUI, UpdateGunMsgCallBack); EventCenterManager._Instance.AddListener(EventType.SwitchGun, SwitchGunCallBack); EventCenterManager._Instance.AddListener(EventType.OpenAimed, OpenAniedCallBack); }
void UpdatePlayerMessage(string ip, float max, float current) { if (NetworkTools.GetLocalIP().Equals(ip)) { float temp = current / max; if (temp < hpImage.fillAmount) { hurtTipAnim.SetTrigger("Hurt"); } hpImage.fillAmount = temp; return; } if (playerDic.ContainsKey(ip)) { playerDic[ip].UpdatePanel(ip, max, current); } }
void Awake() { Instance = this; UIManager._Instance.OpenWindow(WindowName.Battle); GameObject player = GameObject.FindGameObjectWithTag("Player"); playerDic.Add(NetworkTools.GetLocalIP(), player.GetComponent <PlayerBase>()); foreach (string item in RoomSingle.GetInfos().Keys) { if (!item.Equals(NetworkTools.GetLocalIP())) { PlayerInfoMessage m = RoomSingle.GetInfos()[item]; InstancePlayerAI(item, m.ID, m.gun1ID, m.gun2ID); } } Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
// Use this for initialization void Awake() { if (isTest) { NetworkManager._Instance.StartBattleServer(ips); return; } //判断自己是不是房主 if (RoomSingle.roomIP.Equals(NetworkTools.GetLocalIP())) { Debug.Log("启动战斗服务器"); ips = new string[RoomSingle.GetInfos().Count]; int i = 0; foreach (var item in RoomSingle.GetInfos().Keys) { ips[i] = item; i++; } NetworkManager._Instance.StartBattleServer(ips); } }
protected override void GetNetworkMsgCallBack(params object[] obj_arr) { NetworkMessage message = (NetworkMessage)obj_arr[0]; if (message.type == 70) { EnemyInfoMessage info = EnemyInfoMessage.GetMessage(message.message); net.SetTarget(info); } else { if (message.type == 72) { if (!message.ip.Equals(NetworkTools.GetLocalIP())) { AddMessage(message); } } else { AddMessage(message); } } }
// Use this for initialization void Start() { guns = new GunBase[2]; GameObject gun1 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID)); guns[0] = gun1.GetComponent <GunBase>(); GameObject gun2 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID)); guns[1] = gun2.GetComponent <GunBase>(); base.BaseStart(); myRotation.y = transform.rotation.eulerAngles.y; watchPointRotation.x = watchPoint.rotation.eulerAngles.x; watchPointRotation.y = watchPoint.rotation.eulerAngles.y; gunAngle = watchPointRotation.x; Cursor.visible = false; //控制鼠标显示和隐藏, true显示, false时隐藏 Cursor.lockState = CursorLockMode.Locked; //把鼠标锁定在窗口内,防止鼠标拖到边缘是显示 for (int i = 0; i < guns.Length; i++) { guns[i].SetPhysicGunPos(physicGunPos, myCamera, watchPoint); } currentGun.InitSight(); }