private void AnimateMovement() { Vector3 motion = (myTile.GetOccupyingCoordinates(false, false) - gameObject.transform.position).normalized * animationSpeed * Time.deltaTime; if (motion == Vector3.zero || motion.magnitude > (myTile.GetOccupyingCoordinates(false, false) - gameObject.transform.position).magnitude) { gameObject.transform.position = myTile.GetOccupyingCoordinates(false, false); if (movePath.Count == 0) { HitTarget(); DungeonManager.instance.mode = DungeonManager.Mode.Move; Destroy(gameObject); } else { myTile = movePath[0]; movePath.Remove(myTile); } } else { gameObject.transform.position += motion; gameObject.transform.localScale = new Vector3(Mathf.Clamp(motion.x, 0.1f, 0.6f), Mathf.Clamp(motion.y, 0.1f, 0.6f), 0.1f); } }
internal bool IsInLineOfSight(Program observer, DungeonTile tile) { Vector3 direction = (tile.GetOccupyingCoordinates(true, false) - observer.myTile.GetOccupyingCoordinates(observer.IsFlying(), false)).normalized; float distance = (tile.GetOccupyingCoordinates(true, false) - observer.myTile.GetOccupyingCoordinates(observer.IsFlying(), false)).magnitude; return(!Physics.Raycast(observer.myTile.GetOccupyingCoordinates(observer.IsFlying(), false), direction, distance, LayerMask.GetMask("Ground"))); }
internal void DeploySecurity(EnemyProgram enemy, DungeonTile dungeonTile) { enemy.SetTile(dungeonTile); enemy.transform.position = dungeonTile.GetOccupyingCoordinates(enemy.IsFlying(), false); enemyPrograms.Add(enemy); dungeonTile.Occupy(enemy); }
internal override void Proc(DungeonTile targetTile) { AudioSource.PlayClipAtPoint(teleportSound, FindObjectOfType <Camera>().transform.position, PlayerPrefs.GetFloat(Options.sfxVolumeKey)); if (!targetTile.isOccupied) { if (targetTile.IsVisible() && ((!targetTile.isBlocked) || Program.selectedProgram.IsFlying())) { Instantiate(teleportEffect, Program.selectedProgram.transform.position, Quaternion.identity); Instantiate(teleportEffect, targetTile.GetOccupyingCoordinates(Program.selectedProgram.IsFlying(), false), Quaternion.identity); Program.selectedProgram.myTile.Vacate(Program.selectedProgram); Program.selectedProgram.myTile = targetTile; targetTile.Occupy(Program.selectedProgram); Program.selectedProgram.gameObject.transform.position = targetTile.GetOccupyingCoordinates(Program.selectedProgram.IsFlying(), false); EndProc(); } } }
internal void GeneratePorts(Vector3Int[] portLocations) { foreach (Vector3Int portLocation in portLocations) { DungeonTile tile = tileGrid[portLocation.x][portLocation.z]; Port newPort = Instantiate(port, tile.GetOccupyingCoordinates(false, true), Quaternion.identity).GetComponent <Port>(); DungeonManager.instance.hackableObjects.Add(newPort); newPort.myTile = tile; } }
internal void GenerateSecurityHubs(Vector3Int[] hubPlacements) { foreach (Vector3Int hubLocation in hubPlacements) { DungeonTile tile = tileGrid[hubLocation.x][hubLocation.z]; SecurityNode newNode = Instantiate(hubPrefab, tile.GetOccupyingCoordinates(false, true), Quaternion.identity).GetComponent <SecurityNode>(); DungeonManager.instance.securityNodes.Add(newNode); newNode.myTile = tile; } }
internal void GenerateTerminals(Vector3Int[] terminalLocations) { foreach (Vector3Int terminalLocation in terminalLocations) { DungeonTile tile = tileGrid[terminalLocation.x][terminalLocation.z]; Terminal newTerminal = Instantiate(terminal, tile.GetOccupyingCoordinates(false, true), Quaternion.identity).GetComponent <Terminal>(); DungeonManager.instance.terminals.Add(newTerminal); newTerminal.myTile = tile; } }
private void HandleMovement() { if (isAnimating) { Vector3 motion = GetMotionVector(); if (!IsFlying()) { HandleRampClimbRotation(motion); } if (motion == Vector3.zero || motion.magnitude > (myTile.GetOccupyingCoordinates(IsFlying(), false) - gameObject.transform.position).magnitude) { gameObject.transform.position = myTile.GetOccupyingCoordinates(IsFlying(), false); if (movePath.Count == 0) { isAnimating = false; DungeonManager.instance.Resume(); } else { myTile = movePath[0]; AttemptCollectLoot(); movePath.Remove(myTile); DungeonManager.instance.UpdateVisibility(); if (Program.selectedProgram == this && GetComponent <Hackable>() && !IsControlledByPlayer())//if selected and enemy, update sight preview { ((EnemyProgram)this).GenerateLineOfSightIndicators(); } } CheckStealth(); } else { gameObject.transform.position += motion; } } }
internal void GenerateFirewalls(Vector3Int[] firewallLocations) { foreach (Vector3Int firewallLocation in firewallLocations) { if (IsValidCoordinates(firewallLocation.x, firewallLocation.z)) { DungeonTile tile = tileGrid[firewallLocation.x][firewallLocation.z]; Firewall newFirewall = Instantiate(firewall, tile.GetOccupyingCoordinates(true, true), Quaternion.identity).GetComponent <Firewall>(); DungeonManager.instance.hackableObjects.Add(newFirewall); newFirewall.myTile = tile; } else { Debug.LogWarning("Attempeted to place firewall at invalid coordinates " + firewallLocation.ToString()); } } }
internal void GenerateSwitches(List <Vector3Int> switchLocations) { foreach (Vector3Int switchLocation in switchLocations) { if (IsValidCoordinates(switchLocation.x, switchLocation.z)) { DungeonTile tile = tileGrid[switchLocation.x][switchLocation.z]; SwitchBridge newSwitch = Instantiate(bridgeSwitch, tile.GetOccupyingCoordinates(true, true), Quaternion.identity).GetComponent <SwitchBridge>(); DungeonManager.instance.hackableObjects.Add(newSwitch); DungeonManager.instance.switchBridges.Add(newSwitch); newSwitch.myTile = tile; } else { Debug.LogWarning("Attempeted to place switch at invalid coordinates " + switchLocation.ToString()); } } }
internal void DeploySelected(DungeonTile dungeonTile) { if (Mathf.Abs(DeploymentZone.instance.myCoords.x - dungeonTile.xCoord) <= DeploymentZone.instance.range && Mathf.Abs(DeploymentZone.instance.myCoords.z - dungeonTile.zCoord) <= DeploymentZone.instance.range && grid.CanDeployHere(dungeonTile)) { Program.selectedProgram.myTile = dungeonTile; Program.selectedProgram.transform.position = dungeonTile.GetOccupyingCoordinates(Program.selectedProgram.IsFlying(), false); Program.selectedProgram.BeginPlay(); dungeonTile.Occupy(Program.selectedProgram); } else { Debug.Log((Mathf.Abs(DeploymentZone.instance.myCoords.x - dungeonTile.xCoord)).ToString()); Debug.Log((Mathf.Abs(DeploymentZone.instance.myCoords.z - dungeonTile.zCoord)).ToString()); Debug.Log(DeploymentZone.instance.range.ToString()); Debug.Log(grid.CanDeployHere(dungeonTile).ToString()); } }
private GameObject CreateLineOfSightIndicator(DungeonTile tile) { return(Instantiate(sightIndicator, tile.GetOccupyingCoordinates(false, true) + Vector3.up * sightPreviewOffset, tile.getPreviewRotation())); }