public void InstantiateLaser(uint netId) { bombNetId = netId; var temp = gameObject.GetComponent<BombController>().paramaters; var paramaters = new BombParams { radius = temp.radius, delayTime = temp.delayTime, warningTime = temp.warningTime, explodingDuration = temp.explodingDuration }; var location = new Vector2(AxisRounder.Round(gameObject.transform.position.x), AxisRounder.Round(gameObject.transform.position.y)); GameObject laser = Instantiate(laserCross, location, Quaternion.identity) as GameObject; //TODO refactor this too laser.GetComponent<LaserController>().creationTime = Time.time; laser.GetComponent<LaserController>().paramaters = paramaters; laser.GetComponent<LaserController>().bombNetId = bombNetId; InstantiateInDirection(location, Vector2.up, paramaters); InstantiateInDirection(location, Vector2.down, paramaters); InstantiateInDirection(location, Vector2.left, paramaters); InstantiateInDirection(location, Vector2.right, paramaters); }
private void InstantiateInDirection(Vector2 location, Vector2 direction, BombParams paramaters) { var emptySpace = Physics2D.RaycastAll(location, direction) .Where(h => h.distance != 0 && h.transform.tag != "Laser" && h.transform.tag != "Bomb" && h.transform.tag != "Player") .First(); int numLasers = emptySpace.distance < paramaters.radius ? (int)emptySpace.distance : paramaters.radius; if ((emptySpace.transform.tag == "Destructible" || emptySpace.transform.tag == "Upgrade") && emptySpace.distance <= paramaters.radius) if(isServer) CmdDestroyThis(emptySpace.transform.gameObject); for (int i = 1; i <= numLasers; i++) { GameObject laser; if (i == paramaters.radius) laser = Instantiate(GetLaser(direction), new Vector3(location.x + direction.x * i, location.y + direction.y * i, 0.0f), Quaternion.identity) as GameObject; else laser = Instantiate(GetMiddleLaser(direction), new Vector3(location.x + direction.x * i, location.y + direction.y * i, 0.0f), Quaternion.identity) as GameObject; //TODO refactor all of this to make it cleaner/faster laser.GetComponent<LaserController>().creationTime = Time.time; laser.GetComponent<LaserController>().paramaters = paramaters; laser.GetComponent<LaserController>().bombNetId = bombNetId; } }
public TinyBombsPlayerControllerModifier(IPlayerController playerController) { _startTime = Time.time; _playerController = playerController; _temp = new BombParams(); _temp.delayTime = _playerController.bombParams.delayTime; _temp.explodingDuration = _playerController.bombParams.explodingDuration; _temp.radius = 1; _temp.warningTime = _playerController.bombParams.warningTime; }
public void SetupBomb(GameObject player, float delayTime, float explodingDuration, int radius, float warningTime) { _startTime = Time.time; if (!isServer) _startTime -= 0.3f; paramaters = new BombParams(); paramaters.delayTime = delayTime; paramaters.explodingDuration = explodingDuration; paramaters.radius = radius; paramaters.warningTime = warningTime; parentPlayer = player; parentPlayer.GetComponent<PlayerControllerComponent>().currNumBombs--; transform.SetParent(player.transform.parent); }
void Start() { if(paramaters == null) paramaters = new BombParams(); }