private void ExploseHere(Vector2 pose, int _owner) { foreach (KeyValuePair <int, Client> _ply in allPlayer) { if (_ply.Value.alive) { Vector2Int _plypose = BM.Vec3To2int(PhotonView.Find(_ply.Value.plyInstancePvId).gameObject.transform.position); if (_plypose == pose) { allPlayer[_ply.Key].alive = false; //PhotonView.Find(_ply.Value.plyInstancePvId).RequestOwnership(); //PhotonNetwork.Destroy(PhotonView.Find(_ply.Value.plyInstancePvId).gameObject); StartCoroutine(KillPlayer(_ply.Value.plyInstancePvId)); if (_ply.Key != _owner) { allPlayer[_owner].kill += 1; } else { allPlayer[_owner].kill -= 1; } } } } StreamSendData(StreamDataType.Players); }
void MapShrinking(int _shrinking) { for (int x = 0; x <= roominfo.mapSize; x++) { for (int y = 0; y <= roominfo.mapSize; y++) { bool _xAct = x <= _shrinking || x >= roominfo.mapSize - _shrinking; bool _yAct = y <= _shrinking || y >= roominfo.mapSize - _shrinking; if (_xAct || _yAct) { map.SetStatus(x, y, BlockState.unbrekable); foreach (KeyValuePair <int, Client> _ply in allPlayer) { if (_ply.Value.alive) { bool _die = BM.Vec3To2int(PhotonView.Find(_ply.Value.plyInstancePvId).transform.position) == new Vector2Int(x, y); if (_die) { StartCoroutine(KillPlayer(_ply.Value.plyInstancePvId)); } } } } } } StreamSendData(StreamDataType.Map); }
public bool UseMyteryPower(Client _ply) { Debug.LogFormat("Player {0} use {1}", _ply.name, _ply.GetPly().mysteryPower.ToString()); switch (_ply.GetPly().mysteryPower) { case MysteryPowers.tp: if (roomManager.roominfo.safeTp) { Vector2Int tpPose; do { tpPose = new Vector2Int(Random.Range(0, map.Maps.GetLength(0)), Random.Range(0, map.Maps.GetLength(1))); } while (!(tpPose.x % 2 == 1 && tpPose.y % 2 == 1)); roomManager.MakeHole(tpPose.x, tpPose.y); photonView.RPC("TP", RpcTarget.All, tpPose.x + 0.5f, tpPose.y + 0.5f); } else { List <Vector2> _tpPosibilitis = new List <Vector2>(); for (int y = 0; y < map.Maps.GetLength(1); y++) { for (int x = 0; x < map.Maps.GetLength(0); x++) { if (map.Maps[x, y].state == BlockState.destroyer) { _tpPosibilitis.Add(new Vector2(x, y)); } } } Vector2 _pos = _tpPosibilitis[Random.Range(0, _tpPosibilitis.Count)]; photonView.RPC("TP", RpcTarget.All, _pos.x + 0.5f, _pos.y + 0.5f); } return(true); case MysteryPowers.megaBombe: Vector3 _bombePos = new Vector3(Mathf.Floor(transform.position.x), 0f, Mathf.Floor(transform.position.z)); foreach (GameObject _bombe in GameObject.FindGameObjectsWithTag("Bombe")) { if (BM.Vec3To2int(_bombe.transform.position) == BM.Vec3To2int(_bombePos)) { return(false); } } StartCoroutine(roomManager.TimerBombe(_bombePos, photonView.OwnerActorNr, true)); return(true); } return(false); }
public void UpdateMap(List <Box> _boxSync) { for (int i = 0; i < transform.childCount; i++) { GameObject boxGo = transform.GetChild(i).gameObject; Box box = null; bool continu = false; foreach (Box boxInBoxsync in _boxSync) { if (BM.Vec3To2int(boxGo.transform.position) == boxInBoxsync.pos) { box = boxInBoxsync; continu = true; break; } } if (!continu) { continue; } GameObject gfx = boxGo.transform.Find("GFX").gameObject; if (gfx.activeSelf != box.GetBoxActive()) { gfx.SetActive(box.GetBoxActive()); boxGo.GetComponent <BoxCollider>().isTrigger = !box.GetBoxActive(); } if (gfx.activeSelf) { if (gfx.GetComponent <Renderer>().material.color != box.GetBoxColor()) { gfx.GetComponent <Renderer>().material.color = box.GetBoxColor(); } continue; } GameObject powerUpGFX = boxGo.transform.Find("PowerUP GFX").gameObject; if (powerUpGFX.activeSelf != box.GetPowerUpActive()) { powerUpGFX.SetActive(box.GetPowerUpActive()); } if (powerUpGFX.activeSelf && powerUpGFX.GetComponent <Renderer>().material.color != box.GetPowerUpColor()) { powerUpGFX.GetComponent <Renderer>().material.color = box.GetPowerUpColor(); } } }
void CreatBombe(float _x, float _y, int _owner) { Vector3 _bombePos = new Vector3(Mathf.Floor(_x), 0f, Mathf.Floor(_y)); bool _bombeHere = false; foreach (GameObject _bombe in GameObject.FindGameObjectsWithTag("Bombe")) { if (BM.Vec3To2int(_bombe.transform.position) == BM.Vec3To2int(_bombePos)) { _bombeHere = true; break; } } if (!_bombeHere && allPlayer[_owner].GetPly().BombeCount < (int)allPlayer[_owner].GetPly().powerUps[PowerUps.moreBombe] + 1) { StartCoroutine(TimerBombe(_bombePos, _owner, false)); } }