public void Split(SectorController sector) { sectors.Remove(sector); switch (sector.type) { case SectorType.FULL: if (Random.value > 0.5) { // SpawnThird (sector.Angle); SpawnSector(3, thirdPrefab, sector.Angle, SectorController.fullAngle, SectorController.thirdAngle); } else { // SpawnHalf (sector.Angle); SpawnSector(2, halfPrefab, sector.Angle, SectorController.fullAngle, SectorController.halfAngle); } break; case SectorType.HALF: // SpawnQuarter (sector.Angle); SpawnSector(2, quarterPrefab, sector.Angle, SectorController.halfAngle, SectorController.quarterAngle); break; case SectorType.QUARTER: break; case SectorType.THIRD: // SpawnQuarter (sector.Angle); break; } // Symbol toRemove = new Symbol { color = sector.target.TargetColor, symbol = sector.target.TargetSymbol }; usedSymbols.Remove(sector.target.TargetSymbol); GameObject.Destroy(sector.gameObject); }
protected void BuildMineField() { SectorControllers = new SectorController[MineField.SectorsPerEdge, MineField.SectorsPerEdge, MineField.SectorsPerEdge]; for (int z = 0; z < MineField.SectorsPerEdge; z++) { for (int y = 0; y < MineField.SectorsPerEdge; y++) { for (int x = 0; x < MineField.SectorsPerEdge; x++) { GameObject go = Instantiate(SectorPrefab, transform); go.transform.position = new Vector3(x * SectorSize, y * SectorSize, z * SectorSize); go.name = $"Sector {MineField.Sectors[x, y, z].FieldPosition}"; SectorController controller = go.GetComponent <SectorController>(); if (controller == null) { Debug.LogError("MineFieldController.BuildMineField: Sector prefab has no SectorController."); } SectorControllers[x, y, z] = controller; } } } }
public void HitClosestSector(float zAngle) { float minAngle = float.MaxValue; SectorController closestSector = null; foreach (SectorController sector in sectors) { if (Mathf.Abs(sector.Angle - zAngle) < minAngle) { minAngle = Mathf.Abs(sector.Angle - zAngle); closestSector = sector; } } if (closestSector.target.Equals(targetController.currentTarget)) { closestSector.Hit(); Symbol nextTarget = usedSymbols [Random.Range(0, usedSymbols.Count)]; while (nextTarget.Equals(closestSector.target.TargetSymbol)) { nextTarget = usedSymbols [Random.Range(0, usedSymbols.Count)]; } targetController.UpdateTarget(nextTarget); } else { HitError(); } }
void OnDestroy() { SectorController sc = null; if (currentSector != null) { if (currentSector.floorObject != null) { sc = currentSector.floorObject; } } if (sc != null) { if (dynamic) { sc.DynamicThings.Remove(this); } else { sc.StaticThings.Remove(this); } } RemoveFromGrid(); }
public void Init() { transform.rotation = Quaternion.Euler(0, thing.facing, 0); float x = thing.posX; float z = thing.posY; Vector3 origin = new Vector3(x, (float)MapLoader.maxZ / MapLoader.sizeDividor, z); //Vector3 target = new Vector3(x, (float)MapLoader.minZ / MapLoader.sizeDividor, z); RaycastHit hit; if (Physics.Raycast(origin, Vector3.down, out hit)) { transform.position = hit.point; SectorController sc = hit.collider.gameObject.GetComponent <SectorController>(); if (sc != null) { if (mr != null) { mr.GetPropertyBlock(materialProperties); materialProperties.SetFloat("_Brightness", alwaysBright ? 1f : sc.sector.brightness); mr.SetPropertyBlock(materialProperties); } if (dynamic) { sc.DynamicThings.AddFirst(this); } else { sc.StaticThings.Add(this); } } } else { Destroy(gameObject); } if (!string.IsNullOrEmpty(spriteName)) { Texture tex = TextureLoader.Instance.GetSpriteTexture(spriteName); //materialProperties.SetFloat("_ScaleX", (float)tex.width / MapLoader.sizeDividor); //materialProperties.SetFloat("_ScaleY", (float)tex.height / MapLoader.sizeDividor); Mesh mesh = Mesher.Instance.CreateBillboardMesh((float)tex.width / MapLoader.sizeDividor, (float)tex.height / MapLoader.sizeDividor, .5f, 0); GetComponent <MeshFilter>().mesh = mesh; SetTexture(tex); SetSpriteDirection(1); } }
void Start() { GameObject sectorController = GameObject.Find("SectorController"); if (sectorController != null) { sc = sectorController.GetComponent<SectorController>(); nc = sectorController.GetComponent<NPCController>(); } else { throw new System.Exception("Cannot find SectorController. Is it present and named 'SectorController'?"); } }
public virtual void Init() { materialProperties = new MaterialPropertyBlock(); cell.x = Mathf.FloorToInt(transform.position.x); cell.y = Mathf.FloorToInt(transform.position.z); AddToGrid(); Triangle sectorTriangle = TheGrid.GetExactTriangle(transform.position); if (sectorTriangle == null) { Debug.Log("Thing \"" + thingName + "\" no sector found."); Destroy(gameObject); return; } currentSector = sectorTriangle.sector; transform.position = new Vector3(transform.position.x, currentSector.floorHeight, transform.position.z); if (mr != null) { mr.GetPropertyBlock(materialProperties); materialProperties.SetFloat("_SectorLight", alwaysBright ? 1f : currentSector.brightness); mr.SetPropertyBlock(materialProperties); } CreateBillboard(); if (currentSector.Dynamic) { dynamic = true; //things need to update when on elevators, crushers, etc } if (!dynamic) { enabled = false; } SectorController sc = currentSector.floorObject; if (dynamic) { sc.DynamicThings.AddFirst(this); } else { sc.StaticThings.Add(this); } }
void Start() { GameObject sectorController = GameObject.Find("SectorController"); if (sectorController != null) { sc = sectorController.GetComponent <SectorController>(); nc = sectorController.GetComponent <NPCController>(); } else { throw new System.Exception("Cannot find SectorController. Is it present and named 'SectorController'?"); } }
void AssignSymbol(SectorController sector) { Symbol newSymbol = new Symbol(); newSymbol.color = (SectorColor)Random.Range(0, (float)SectorColor.COUNT); newSymbol.symbol = (SectorSymbol)Random.Range(0, (float)SectorSymbol.COUNT); while (usedSymbols.Contains(newSymbol)) { newSymbol.color = (SectorColor)Random.Range(0, (float)SectorColor.COUNT); newSymbol.symbol = (SectorSymbol)Random.Range(0, (float)SectorSymbol.COUNT); } sector.target.TargetSymbol = newSymbol; usedSymbols.Add(newSymbol); }
public SectorController GetClosestSector(float zAngle) { float minAngle = float.MaxValue; SectorController closestSector = null; foreach (SectorController sector in sectors) { if (Mathf.Abs(sector.Angle - zAngle) < minAngle) { minAngle = Mathf.Abs(sector.Angle - zAngle); closestSector = sector; } } return(closestSector); }
/// <summary> /// Setup and init /// </summary> /// <remarks> /// <para> /// Initialize the lists. Setup the NPC pools. Starts the POLICE and MINER /// spawning process so ther are in place as the player jumps in. /// </para> /// </remarks> void Start() { sc = GetComponent <SectorController>(); merchantNPCList = new List <GameObject>(); policeNPCList = new List <GameObject>(); minerNPCList = new List <GameObject>(); SetupMerchantPool(); SetupPolicePool(); SetupMinerPool(); //Spawn police and miners //TODO: Spawning will move into a check based on sim interval step and player presence CheckPoliceSpawnPermission(); CheckMinerSpawnPermission(); }
static void Main(string[] args) { Console.WriteLine("Stock/Sector Scraper."); var input = Choice(); if (input == "S") { var controller = new BeursController("splash.mathiascloet.com", 8050, "/home/cloet/Projects/school/bachelorproef/SplashScraper/data"); controller.ScrapeBeurs(); } if (input == "E") { var controller = new SectorController("splash.mathiascloet.com", 8050, "/home/cloet/Projects/school/bachelorproef/SplashScraper/data"); controller.ScrapeSectoren(); } }
public void Init(Sector sector) { sectorController = sector.floorObject; targetSector = sector; currentHeight = originalHeight = sector.ceilingHeight; targetHeight = sector.floorHeight; audioSource = GetComponentInChildren <AudioSource>(); if (audioSource == null) { GameObject audioPosition = new GameObject("Audio Position"); audioPosition.transform.position = GetComponent <MeshFilter>().mesh.bounds.center; audioPosition.transform.SetParent(transform, true); audioSource = audioPosition.AddComponent <AudioSource>(); //audioSource.minDistance = 5f; audioSource.playOnAwake = false; audioSource.spatialBlend = 1f; } foreach (Sidedef s in sector.Sidedefs) { if (s.Line.Back != null) { if (s.Line.Back.Sector == sector) { if (s.Line.TopFrontObject != null) { s.Line.TopFrontObject.transform.SetParent(transform); Rigidbody rb = s.Line.TopFrontObject.GetComponent <Rigidbody>(); if (rb == null) { rb = s.Line.TopFrontObject.AddComponent <Rigidbody>(); rb.isKinematic = true; rb.useGravity = false; } } } } } }
/// <summary> /// Set up references and initialize lists. Start the creation /// of the initial movement plan, and then start the movement. /// </summary> void Start() { //Init routeDestinations = new List <RouteDataObject>(); //References self = gameObject.GetComponent <NPC>(); GameObject sectorController = GameObject.Find("SectorController"); if (sectorController != null) { sc = sectorController.GetComponent <SectorController>(); nc = sectorController.GetComponent <NPCController>(); } else { throw new System.Exception("SectorController was not found. Is it present and named 'SectorController'?"); } //Plan setup SetMovementPlan(); }
private void Inicializa() { sectorController = new SectorController(); Malla.DataSource = sectorController.SelectAll(); }
void OnControllerColliderHit(ControllerColliderHit hit) { SectorController sc = hit.collider.GetComponent <SectorController>(); if (sc != null) { if (sc.sector.specialType > 0) { switch (sc.sector.specialType) { case 4: { environmentDamageCooldown = 1f; if (environmentDamageTime <= 0f) { Damage(20, DamageType.Environment); environmentDamageTime = 1f; } } break; case 5: { environmentDamageCooldown = 1f; if (environmentDamageTime <= 0f) { Damage(10, DamageType.Environment); environmentDamageTime = 1f; } } break; case 7: { environmentDamageCooldown = 1f; if (environmentDamageTime <= 0f) { Damage(5, DamageType.Environment); environmentDamageTime = 1f; } } break; case 9: { PlayerInfo.Instance.unfoundSecrets.Remove(sc.sector); PlayerInfo.Instance.foundSecrets.Add(sc.sector); sc.sector.specialType = 0; //so we don't loop through the lists every frame } break; case 11: { //TODO: remove godmode on touch and end level if player dies (this is the end of the shareware campaign) //currently the end is handled in the OnDamage method environmentDamageCooldown = 1f; if (environmentDamageTime <= 0f) { Damage(20, DamageType.Environment); environmentDamageTime = 1f; } } break; case 16: { environmentDamageCooldown = 1f; if (environmentDamageTime <= 0f) { Damage(20, DamageType.Environment); environmentDamageTime = 1f; } } break; } } } }
/// <summary> /// Set up references and initialize lists. Start the creation /// of the initial movement plan, and then start the movement. /// </summary> void Start() { //Init routeDestinations = new List<RouteDataObject>(); //References self = gameObject.GetComponent<NPC>(); GameObject sectorController = GameObject.Find("SectorController"); if (sectorController != null) { sc = sectorController.GetComponent<SectorController>(); nc = sectorController.GetComponent<NPCController>(); } else { throw new System.Exception("SectorController was not found. Is it present and named 'SectorController'?"); } //Plan setup SetMovementPlan(); }
public void Setup() { _sectorServiceMock = new Mock <ISectorService>(); _sectorController = new SectorController(_sectorServiceMock.Object); }
void Update() { if (GameManager.Paused) { return; } if (playerThing.Dead) { PlayerCamera.Instance.bopActive = false; if (PlayerWeapon.Instance != null) { PlayerWeapon.Instance.bopActive = false; } if (deathTime < 1f) { deathTime += Time.deltaTime; } else { if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) { deathTime = 0; viewDirection = Vector2.zero; playerThing.hitpoints = 100; playerThing.armor = 0; if (PlayerWeapon.Instance != null) { Destroy(PlayerWeapon.Instance.gameObject); PlayerWeapon.Instance = null; } PlayerInfo.Instance.Reset(); GameManager.Instance.ChangeMap = MapLoader.CurrentMap; } } return; } if (pokeSoundTime > 0) { pokeSoundTime -= Time.deltaTime; } viewDirection.y += Input.GetAxis("Mouse X") * Options.MouseSensitivity.x; viewDirection.x -= Input.GetAxis("Mouse Y") * Options.MouseSensitivity.y; //so you don't fall when no-clipping bool outerSpace = false; //smoother elevator movement bool stickTofloor = false; { Triangle t = TheGrid.GetExactTriangle(transform.position); if (t != null) { if (playerThing.currentSector != t.sector) { if (playerThing.currentSector != null) { playerThing.currentSector.floorObject.DynamicThings.Remove(playerThing); } t.sector.floorObject.DynamicThings.AddLast(playerThing); } playerThing.LastSector = playerThing.currentSector; playerThing.currentSector = t.sector; if (playerThing.LastSector != null && playerThing.currentSector != null) { if (playerThing.LastSector == playerThing.currentSector) { if (lastFloorHeight != playerThing.currentSector.floorHeight) { lastFloorHeight = playerThing.currentSector.floorHeight; if (controller.isGrounded) { float diff = Mathf.Abs((transform.position.y - centerHeight) - playerThing.currentSector.floorHeight); if (diff <= MapLoader._4units) { transform.position = new Vector3(transform.position.x, playerThing.currentSector.floorHeight + centerHeight, transform.position.z); stickTofloor = true; } } } } else { lastFloorHeight = playerThing.currentSector.floorHeight; } } //so we can no-clip from lower platform to higher if (transform.position.y < t.sector.floorHeight) { transform.position = new Vector3(transform.position.x, t.sector.floorHeight, transform.position.z); } } else { outerSpace = true; } } //read input if (Input.GetKey(KeyCode.LeftArrow)) { viewDirection.y -= Time.deltaTime * 90; } if (Input.GetKey(KeyCode.RightArrow)) { viewDirection.y += Time.deltaTime * 90; } if (viewDirection.y < -180) { viewDirection.y += 360; } if (viewDirection.y > 180) { viewDirection.y -= 360; } //if (viewDirection.x < -90) viewDirection.x = -90; //if (viewDirection.x > 90) viewDirection.x = 90; if (viewDirection.x < -45) { viewDirection.x = -45; } if (viewDirection.x > 45) { viewDirection.x = 45; } transform.rotation = Quaternion.Euler(0, viewDirection.y, 0); //used so player doesn't hit the elevator floor constantly and make the OOF sound lastFrameStickToFloor = stickTofloor; MovementInput(outerSpace, stickTofloor); //such vanity if (PlayerWeapon.Instance != null) { if (playerThing.currentSector != null) { SectorController sc = playerThing.currentSector.floorObject; PlayerWeapon.Instance.sectorLight = sc.sector.brightness; } } //poke stuff if (Input.GetKeyDown(KeyCode.Space)) { Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 2, ~((1 << 9) | (1 << 10)), QueryTriggerInteraction.Ignore)) { bool noway = true; Pokeable lc = hit.collider.gameObject.GetComponent <Pokeable>(); if (lc != null) { if (lc.Poke(gameObject)) { noway = false; } } if (noway && pokeSoundTime <= 0) { audioSource.clip = SoundLoader.Instance.LoadSound("DSNOWAY"); audioSource.Play(); pokeSoundTime = .175f; } } } //use weapon if (Input.GetMouseButton(0) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) { if (PlayerWeapon.Instance != null) { if (PlayerWeapon.Instance.Fire()) { if (PlayerWeapon.Instance.Noise > 0) { playerThing.CastNoise(PlayerWeapon.Instance.Noise); } } } } //swap weapon if (PlayerWeapon.Instance == null) { if (SwapWeapon == WeaponType.None) { SwapToBestWeapon(); } if (SwapWeapon > WeaponType.None) { PlayerWeapon.Instance = Instantiate(PlayerInfo.Instance.WeaponPrefabs[(int)SwapWeapon]); CurrentWeapon = SwapWeapon; SwapWeapon = WeaponType.None; } } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (!TrySwapWeapon(WeaponType.Chainsaw)) { TrySwapWeapon(WeaponType.Fist); } } if (Input.GetKeyDown(KeyCode.Alpha2)) { TrySwapWeapon(WeaponType.Pistol); } if (Input.GetKeyDown(KeyCode.Alpha3)) { TrySwapWeapon(WeaponType.Shotgun); } if (Input.GetKeyDown(KeyCode.Alpha4)) { TrySwapWeapon(WeaponType.Chainsaw); } if (Input.GetKeyDown(KeyCode.Alpha5)) { TrySwapWeapon(WeaponType.RocketLauncher); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
void Update() { if (GameManager.Paused) { return; } if (playerThing.Dead) { if (PlayerCamera.Instance != null) { PlayerCamera.Instance.bopActive = false; } if (PlayerWeapon.Instance != null) { PlayerWeapon.Instance.bopActive = false; } if (deathTime < 1f) { deathTime += Time.deltaTime; } else { if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) { deathTime = 0; viewDirection = Vector2.zero; playerThing.hitpoints = 100; playerThing.armor = 0; if (PlayerWeapon.Instance != null) { Destroy(PlayerWeapon.Instance.gameObject); PlayerWeapon.Instance = null; } PlayerInfo.Instance.Reset(); GameManager.Instance.ChangeMap = MapLoader.CurrentMap; } } return; } if (pokeSoundTime > 0) { pokeSoundTime -= Time.deltaTime; } viewDirection.y += Input.GetAxis("Mouse X") * Options.MouseSensitivity.x; viewDirection.x -= Input.GetAxis("Mouse Y") * Options.MouseSensitivity.y; //so you don't fall when no-clipping bool outerSpace = false; //smoother elevator movement bool sticktofloor = false; { Triangle t = TheGrid.GetExactTriangle(transform.position); if (t != null) { if (playerThing.currentSector != t.sector) { if (playerThing.currentSector != null) { playerThing.currentSector.floorObject.DynamicThings.Remove(playerThing); } t.sector.floorObject.DynamicThings.AddLast(playerThing); } playerThing.LastSector = playerThing.currentSector; playerThing.currentSector = t.sector; if (playerThing.LastSector != null && playerThing.currentSector != null) { if (playerThing.LastSector == playerThing.currentSector) { if (lastFloorHeight != playerThing.currentSector.floorHeight) { lastFloorHeight = playerThing.currentSector.floorHeight; if (controller.isGrounded) { float diff = Mathf.Abs((transform.position.y - centerHeight) - playerThing.currentSector.floorHeight); if (diff <= MapLoader._4units) { transform.position = new Vector3(transform.position.x, playerThing.currentSector.floorHeight + centerHeight, transform.position.z); sticktofloor = true; } } } } else { lastFloorHeight = playerThing.currentSector.floorHeight; } } //so we can no-clip from lower platform to higher if (transform.position.y < t.sector.floorHeight) { transform.position = new Vector3(transform.position.x, t.sector.floorHeight, transform.position.z); } } else { outerSpace = true; } } //read input if (Input.GetKey(KeyCode.LeftArrow)) { viewDirection.y -= Time.deltaTime * 90; } if (Input.GetKey(KeyCode.RightArrow)) { viewDirection.y += Time.deltaTime * 90; } if (viewDirection.y < -180) { viewDirection.y += 360; } if (viewDirection.y > 180) { viewDirection.y -= 360; } //restricted up/down looking angle as sprites look really bad when looked at steep angle //also the game doesn't really require such as originally there was no way to rotate camera pitch //if (viewDirection.x < -90) viewDirection.x = -90; //if (viewDirection.x > 90) viewDirection.x = 90; if (viewDirection.x < -45) { viewDirection.x = -45; } if (viewDirection.x > 45) { viewDirection.x = 45; } transform.rotation = Quaternion.Euler(0, viewDirection.y, 0); //qwerty and dvorak combatible =^-^= float forwardSpeed = 0f; if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.Comma) || Input.GetKey(KeyCode.UpArrow)) { forwardSpeed += 1f; } if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.O) || Input.GetKey(KeyCode.DownArrow)) { forwardSpeed -= 1f; } Vector3 forward = transform.TransformDirection(Vector3.forward) * forwardSpeed; float sidewaysSpeed = 0f; if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.E)) { sidewaysSpeed += 1f; } if (Input.GetKey(KeyCode.A)) { sidewaysSpeed -= 1f; } Vector3 right = transform.TransformDirection(Vector3.right) * sidewaysSpeed; //fall down or hit ground if (controller.isGrounded || outerSpace) { if (!lastFrameStickToFloor) { if (gravityAccumulator > gravityOofThreshold) { audioSource.clip = SoundLoader.Instance.LoadSound("DSOOF"); audioSource.Play(); } } gravityAccumulator = 0f; } else { gravityAccumulator += Time.deltaTime * GameManager.Instance.gravity; } //terminal velocity or in elevator if (gravityAccumulator > GameManager.Instance.terminalVelocity || sticktofloor) { gravityAccumulator = GameManager.Instance.terminalVelocity; } //apply move Vector3 move = Vector3.down * Time.deltaTime * gravityAccumulator; if (sidewaysSpeed != 0f || forwardSpeed != 0f) { move += (forward + right).normalized * speed * Time.deltaTime; } controller.Move(move); //used so player doesn't hit the elevator floor constantly and make the OOF sound lastFrameStickToFloor = sticktofloor; //apply bop if (Mathf.Abs(forwardSpeed) + Mathf.Abs(sidewaysSpeed) > .1f) { if (PlayerCamera.Instance != null) { PlayerCamera.Instance.bopActive = true; } if (PlayerWeapon.Instance != null) { PlayerWeapon.Instance.bopActive = true; } } else { if (PlayerCamera.Instance != null) { PlayerCamera.Instance.bopActive = false; } if (PlayerWeapon.Instance != null) { PlayerWeapon.Instance.bopActive = false; } } //such vanity if (PlayerWeapon.Instance != null) { if (playerThing.currentSector != null) { SectorController sc = playerThing.currentSector.floorObject; PlayerWeapon.Instance.sectorLight = sc.sector.brightness; } } //poke stuff if (Input.GetKeyDown(KeyCode.Space)) { Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 2, ~((1 << 9) | (1 << 10)), QueryTriggerInteraction.Ignore)) { bool noway = true; Pokeable lc = hit.collider.gameObject.GetComponent <Pokeable>(); if (lc != null) { if (lc.Poke(gameObject)) { noway = false; } } if (noway && pokeSoundTime <= 0) { audioSource.clip = SoundLoader.Instance.LoadSound("DSNOWAY"); audioSource.Play(); pokeSoundTime = .175f; } } } //use weapon if (Input.GetMouseButton(0) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) { if (PlayerWeapon.Instance != null) { if (PlayerWeapon.Instance.Fire()) { if (PlayerWeapon.Instance.Noise > 0) { playerThing.CastNoise(PlayerWeapon.Instance.Noise); } } } } //swap weapon if (PlayerWeapon.Instance == null) { if (SwapWeapon == -1) { SwapToBestWeapon(); } if (SwapWeapon > -1) { PlayerWeapon.Instance = Instantiate(PlayerInfo.Instance.WeaponPrefabs[SwapWeapon]); CurrentWeapon = SwapWeapon; SwapWeapon = -1; } } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (!TrySwapWeapon(1)) { TrySwapWeapon(0); } } if (Input.GetKeyDown(KeyCode.Alpha2)) { TrySwapWeapon(2); } if (Input.GetKeyDown(KeyCode.Alpha3)) { TrySwapWeapon(3); } if (Input.GetKeyDown(KeyCode.Alpha4)) { TrySwapWeapon(4); } if (Input.GetKeyDown(KeyCode.Alpha5)) { TrySwapWeapon(5); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
public SectorControllerTests() { sectorServiceMock = new Mock <ISectorService>(); bookingSectorServiceMock = new Mock <IBookingSectorService>(); sectorController = new SectorController(sectorServiceMock.Object, bookingSectorServiceMock.Object); }
public SectorControllerTests() { sectorService = Substitute.For <ISectorService>(); sectorController = new SectorController(sectorService); }
public void CreateMeshes() { Transform holder = new GameObject("MapMeshes").transform; holder.transform.SetParent(transform); //sectors { Triangulator triangulator = new Triangulator(); int index = 0; foreach (Sector s in MapLoader.sectors) { triangulator.Triangulate(s); //floor { GameObject sectorObject = new GameObject("Sector_" + index + "_floor"); sectorObject.transform.SetParent(holder); MeshRenderer mr = sectorObject.AddComponent <MeshRenderer>(); MeshFilter meshFilter = sectorObject.AddComponent <MeshFilter>(); Mesh mesh = new Mesh(); meshFilter.mesh = mesh; if (!MaterialManager.Instance.OverridesFlat(s.floorTexture, sectorObject, mr)) { mr.material = MaterialManager.Instance.defaultMaterial; } if (mr.material.mainTexture == null) { MaterialPropertyBlock materialProperties = new MaterialPropertyBlock(); materialProperties.SetTexture("_MainTex", TextureLoader.Instance.GetFlatTexture(s.floorTexture)); mr.SetPropertyBlock(materialProperties); } mesh.name = "Sector_" + index + "_floor_mesh"; int vc = Triangulator.vertices.Count; Vector3[] vertices = new Vector3[vc]; Vector3[] normals = new Vector3[vc]; Vector2[] uvs = new Vector2[vc]; Color[] colors = new Color[vc]; int[] indices = new int[vc]; int v = 0; foreach (Vector2D p in Triangulator.vertices) { vertices[v] = new Vector3(p.x, s.floorHeight, p.y); indices[v] = v; normals[v] = Vector3.up; uvs[v] = new Vector2(p.x / MapLoader.flatUVdividor, p.y / MapLoader.flatUVdividor); colors[v] = Color.white * s.brightness; v++; } mesh.vertices = vertices; mesh.triangles = indices; mesh.normals = normals; mesh.uv = uvs; mesh.colors = colors; mesh.RecalculateBounds(); MeshCollider mc = sectorObject.AddComponent <MeshCollider>(); mc.sharedMesh = mesh; SectorController controller = sectorObject.AddComponent <SectorController>(); s.floorObject = sectorObject; controller.sector = s; controller.Init(); } //ceiling Triangulator.vertices.Reverse(); { GameObject sectorObject = new GameObject("Sector_" + index + "_ceiling"); sectorObject.transform.SetParent(holder); MeshRenderer mr = sectorObject.AddComponent <MeshRenderer>(); MeshFilter meshFilter = sectorObject.AddComponent <MeshFilter>(); Mesh mesh = new Mesh(); meshFilter.mesh = mesh; mesh.name = "Sector_" + index + "_ceiling_mesh"; if (!MaterialManager.Instance.OverridesFlat(s.ceilingTexture, sectorObject, mr)) { mr.material = MaterialManager.Instance.defaultMaterial; } if (mr.material.mainTexture == null) { MaterialPropertyBlock materialProperties = new MaterialPropertyBlock(); materialProperties.SetTexture("_MainTex", TextureLoader.Instance.GetFlatTexture(s.ceilingTexture)); mr.SetPropertyBlock(materialProperties); } int vc = Triangulator.vertices.Count; Vector3[] vertices = new Vector3[vc]; Vector3[] normals = new Vector3[vc]; Vector2[] uvs = new Vector2[vc]; Color[] colors = new Color[vc]; int[] indices = new int[vc]; int v = 0; foreach (Vector2D p in Triangulator.vertices) { vertices[v] = new Vector3(p.x, s.ceilingHeight, p.y); indices[v] = v; normals[v] = -Vector3.up; uvs[v] = new Vector2(p.x / MapLoader.flatUVdividor, p.y / MapLoader.flatUVdividor); colors[v] = Color.white * s.brightness; v++; } mesh.vertices = vertices; mesh.triangles = indices; mesh.normals = normals; mesh.uv = uvs; mesh.colors = colors; mesh.RecalculateBounds(); MeshCollider mc = sectorObject.AddComponent <MeshCollider>(); mc.sharedMesh = mesh; SectorController controller = sectorObject.AddComponent <SectorController>(); s.ceilingObject = sectorObject; controller.sector = s; controller.Init(); } index++; } } //walls { int index = 0; foreach (Linedef l in MapLoader.linedefs) { if (l.Back != null) { //top part (front) if (l.Front.Sector.ceilingHeight > l.Back.Sector.ceilingHeight) { l.TopFrontObject = CreateLineQuad ( l.Front, l.Back.Sector.ceilingHeight, l.Front.Sector.ceilingHeight, l.Front.tHigh, l.Front.offsetX, (l.flags & (1 << 3)) != 0 ? l.Front.offsetY : -l.Front.offsetY, (l.flags & (1 << 3)) != 0 ? 0 : 1, false, l.Front.Sector.brightness, true, "Wall_" + index + "_top_front", holder ); } //top part (back) if (l.Front.Sector.ceilingHeight < l.Back.Sector.ceilingHeight) { l.TopBackObject = CreateLineQuad ( l.Back, l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight, l.Back.tHigh, l.Back.offsetX, (l.flags & (1 << 3)) != 0 ? l.Back.offsetY : l.Back.offsetY, (l.flags & (1 << 3)) != 0 ? 0 : 1, true, l.Back.Sector.brightness, true, "Wall_" + index + "_top_back", holder ); } //bottom part (front) if (l.Front.Sector.minimumFloorHeight < l.Back.Sector.floorHeight) { l.BotFrontObject = CreateLineQuad ( l.Front, l.Front.Sector.minimumFloorHeight, l.Back.Sector.floorHeight, l.Front.tLow, l.Front.offsetX, l.Front.offsetY, ((l.flags & (1 << 4)) != 0) ? 2 : 0, false, l.Front.Sector.brightness, true, "Wall_" + index + "_bot_front", holder ); } //bottom part (back) if (l.Front.Sector.floorHeight > l.Back.Sector.floorHeight) { l.BotBackObject = CreateLineQuad ( l.Back, l.Back.Sector.floorHeight, l.Front.Sector.floorHeight, l.Back.tLow, l.Back.offsetX, l.Front.offsetY, ((l.flags & (1 << 4)) != 0) ? 2 : 0, true, l.Back.Sector.brightness, true, "Wall_" + index + "_bot_back", holder ); } //middle (front) if (l.Front.tMid != "-") { l.MidFrontObject = CreateLineQuad ( l.Front, Mathf.Max(l.Front.Sector.floorHeight, l.Back.Sector.floorHeight), Mathf.Min(l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight), l.Front.tMid, l.Front.offsetX, l.Front.offsetY, ((l.flags & (1 << 4)) != 0) ? 1 : 0, false, l.Front.Sector.brightness, false, "Wall_" + index + "_mid_front", holder ); } //middle (back) if (l.Back.tMid != "-") { l.MidBackObject = CreateLineQuad ( l.Back, Mathf.Max(l.Front.Sector.floorHeight, l.Back.Sector.floorHeight), Mathf.Min(l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight), l.Back.tMid, l.Back.offsetX, l.Back.offsetY, ((l.flags & (1 << 4)) != 0) ? 1 : 0, true, l.Back.Sector.brightness, false, "Wall_" + index + "_mid_back", holder ); } if ((l.flags & (1 << 0)) != 0) { CreateInvisibleBlocker ( l, Mathf.Max(l.Front.Sector.floorHeight, l.Back.Sector.floorHeight), Mathf.Min(l.Front.Sector.ceilingHeight, l.Back.Sector.ceilingHeight), "Wall_" + index + "_blocker", holder ); } } else //solid wall { CreateLineQuad ( l.Front, l.Front.Sector.minimumFloorHeight, l.Front.Sector.maximumCeilingHeight, l.Front.tMid, l.Front.offsetX, l.Front.offsetY, ((l.flags & (1 << 4)) != 0) ? 1 : 0, false, l.Front.Sector.brightness, true, "Wall_" + index, holder ); } index++; } } }
/// <summary> /// Setup and init /// </summary> /// <remarks> /// <para> /// Initialize the lists. Setup the NPC pools. Starts the POLICE and MINER /// spawning process so ther are in place as the player jumps in. /// </para> /// </remarks> void Start() { sc = GetComponent<SectorController>(); merchantNPCList = new List<GameObject>(); policeNPCList = new List<GameObject>(); minerNPCList = new List<GameObject>(); SetupMerchantPool(); SetupPolicePool(); SetupMinerPool(); //Spawn police and miners //TODO: Spawning will move into a check based on sim interval step and player presence CheckPoliceSpawnPermission(); CheckMinerSpawnPermission(); }