/// <summary> /// 接收到物品被扔消息 /// </summary> public void OnDropItem(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; int startIndex = 0; p.GetString(startIndex, ref startIndex); int GroundItemID = p.GetInt(startIndex, ref startIndex); float posX = p.GetFloat(startIndex, ref startIndex); float posY = p.GetFloat(startIndex, ref startIndex); float posZ = p.GetFloat(startIndex, ref startIndex); if (Items.ContainsKey(GroundItemID)) { Items[GroundItemID].Show(); Items[GroundItemID].transform.position = new Vector3(posX, posY, posZ); } }
/// <summary> /// 更新网络玩家数据 /// </summary> /// <param name="protocol"></param> public void UpdatePlayerInfo(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; int startIndex = 0; p.GetString(startIndex, ref startIndex); string playerName = p.GetString(startIndex, ref startIndex); float HP = p.GetFloat(startIndex, ref startIndex); float posX = p.GetFloat(startIndex, ref startIndex); float posY = p.GetFloat(startIndex, ref startIndex); float posZ = p.GetFloat(startIndex, ref startIndex); float rotX = p.GetFloat(startIndex, ref startIndex); float rotY = p.GetFloat(startIndex, ref startIndex); float rotZ = p.GetFloat(startIndex, ref startIndex); string CurrentAction = p.GetString(startIndex, ref startIndex); //自己的消息 if (playerName == NetworkManager.PlayerName) { BagManager.Instance.characterStatus.HP = HP; } if (ScenePlayers.ContainsKey(playerName)) { ScenePlayers[playerName].SetPlayerInfo(HP, CurrentAction); ScenePlayers[playerName].SetPlayerTransform(posX, posY, posZ, rotX, rotY, rotZ); } }
/// <summary> /// 毒圈回调 /// </summary> /// <param name="protocol"></param> public void OnCirclefieldBack(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; int startIndex = 0; p.GetString(startIndex, ref startIndex); float X = p.GetFloat(startIndex, ref startIndex); float Y = p.GetFloat(startIndex, ref startIndex); float shrinkPercent = p.GetFloat(startIndex, ref startIndex); int Movetime = p.GetInt(startIndex, ref startIndex); //HUDUI倒计时显示 countdownTime = Movetime; Moving = true; CircleCenter = new Vector3(X, 0, Y); isBegin = true; iTween.ScaleTo(Circlefield, iTween.Hash("x", Circlefield.transform.localScale.x * shrinkPercent, "y", Circlefield.transform.localScale.y * shrinkPercent, "time", Movetime, "easeType", iTween.EaseType.linear)); iTween.MoveTo(Circlefield, iTween.Hash("position", new Vector3(X, 0, Y), "time", Movetime, "easeType", iTween.EaseType.linear)); }
private void OnPlayerGetBuff(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; int startIndex = 0; p.GetString(startIndex, ref startIndex); string playerName = p.GetString(startIndex, ref startIndex); int bufftype = p.GetInt(startIndex, ref startIndex); float buffTime = p.GetFloat(startIndex, ref startIndex); if (playerName == NetworkManager.PlayerName) { CameraBase.Instance.player.GetComponent <PlayerController>().GetDeBuffInTime((BuffType)bufftype, buffTime, BagManager.Instance.characterStatus); } }
/// <summary> /// 魔法回调 /// </summary> /// <param name="protocol"></param> private void OnPlayerMagicBack(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; int startIndex = 0; p.GetString(startIndex, ref startIndex); string MagicName = p.GetString(startIndex, ref startIndex); float posX = p.GetFloat(startIndex, ref startIndex); float posY = p.GetFloat(startIndex, ref startIndex); float posZ = p.GetFloat(startIndex, ref startIndex); float rotX = p.GetFloat(startIndex, ref startIndex); float rotY = p.GetFloat(startIndex, ref startIndex); float rotZ = p.GetFloat(startIndex, ref startIndex); NetPoolManager.Instantiate(MagicName, new Vector3(posX, posY, posZ), Quaternion.Euler(rotX, rotY, rotZ)); }
/// <summary> /// 魔法回调 /// </summary> /// <param name="protocol"></param> private void OnPlayerMagicBack(BaseProtocol protocol) { BytesProtocol p = protocol as BytesProtocol; RaycastHit hitInfo; Vector3 targetPoint; int startIndex = 0; p.GetString(startIndex, ref startIndex); string MagicName = p.GetString(startIndex, ref startIndex); float posX = p.GetFloat(startIndex, ref startIndex); float posY = p.GetFloat(startIndex, ref startIndex); float posZ = p.GetFloat(startIndex, ref startIndex); float rotX = p.GetFloat(startIndex, ref startIndex); float rotY = p.GetFloat(startIndex, ref startIndex); float rotZ = p.GetFloat(startIndex, ref startIndex); GameObject go = NetPoolManager.Instantiate(MagicName, new Vector3(posX, posY, posZ), Quaternion.Euler(rotX, rotY, rotZ)); go.GetComponent <MagicBehaviour>().isHit = true; Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); }