public void Init(Data.HeroData info) { _animator = GetComponent <Animator>(); if (_status == null) { _status = new HeroStatus(info); } Death += () => GameMng.Camera.SetCameraMode(Define.CameraMode.None); Death += () => GameMng.Input.TouchAction -= OnTouch; Death += DeathEffect; Death += () => Destroy(this.gameObject); ItemMng.Instance.SetStatus(_status); GameMng.Input.TouchAction -= OnTouch; GameMng.Input.TouchAction += OnTouch; _status.StartEquip(); UIMng.Instance.CallEvent(UIList.HUD, "RegistHero", this); FoV fov = new FoV(GameMng.Map.CurrMap, _radius); _fov = fov; }
public void FirstTurn() { FoV.GetPlayerFoV(player.position); UpdateVisibility(); isPlayerTurn = true; }
public void FinishPlayersTurn() { isPlayerTurn = false; FoV.GetPlayerFoV(player.position); UpdateVisibility(); //dungeonGenerator.DrawMap(true); EnemyTurn(); }
void Start() { dungeonGenerator = GetComponent <DungeonGenerator>(); dungeonGenerator.InitializeDungeon(); dungeonGenerator.GenerateDungeon(); FoV.Initialize(RangeOfView); FirstTurn(); }
// Use this for initialization void Start() { fov = GetComponentInChildren<FoV>(); player = GameObject.FindGameObjectWithTag("Player").transform; playerDetected = false; navAgent = GetComponent<NavMeshAgent>(); initPos = transform.position; InvokeRepeating ("UpdateFoV", 0, 0.1f); }
public static bool IsPlayerVisible(Vector2Int position, out Vector2Int player) { bool isVisible = false; player = new Vector2Int(); foreach (Vector2Int pos in FoV.GetEnemyFoV(position)) { if (MapManager.map[pos.x, pos.y].hasPlayer) { isVisible = true; player = pos; break; } } return(isVisible); }
void UpdateVisibility() { for (int y = 0; y < dungeonGenerator.mapHeight; y++) { for (int x = 0; x < dungeonGenerator.mapWidth; x++) { if (MapManager.map[x, y] != null) { FoV.VisibilityCheck(new Vector2Int(x, y)); if (MapManager.map[x, y].hasEnemy) { MapManager.map[x, y].enemyObject.GetComponent <EnemyVisibility>().VisibilityCheck(new Vector2Int(x, y)); } } } } }
void OnSceneGUI() { FoV fov = (FoV)target; Handles.color = Color.white; Handles.DrawWireArc(fov.transform.position, Vector3.up, Vector3.forward, 360, fov.viewRadius); Vector3 viewAngleA = fov.DirFromAngle(-fov.viewAngle / 2, false); Vector3 viewAngleB = fov.DirFromAngle(fov.viewAngle / 2, false); Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleA * fov.viewRadius); Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleB * fov.viewRadius); Handles.color = Color.red; foreach (Transform visibleTarget in fov.visibleTargets) { Handles.DrawLine(fov.transform.position, visibleTarget.position); } }
private void EnableDashBoard() { //Debug.Log(CategoryTitle); dashboard.GetComponent <Image>().CrossFadeAlpha(1f, 0.3f, false); CategoryTitle.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Overview.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Inventory.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Config.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Save.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Load.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Exit.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); Language.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); GraphicsQuality.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); TextureQuality.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); FoV.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); QualityValue.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); GQ_LeftArrow.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); GQ_RightArrow.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); LDD_Label.GetComponent <Text>().CrossFadeAlpha(1f, 0.3f, false); DashboardStatus = true; }
private void DisableDashBoard() { dashboard.GetComponent <Image>().CrossFadeAlpha(0.01f, 0.3f, false); CategoryTitle.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Overview.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Inventory.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Config.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Save.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Load.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Exit.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); PlayedTime.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Reputation.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); Language.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); GraphicsQuality.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); TextureQuality.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); FoV.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); QualityValue.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); GQ_LeftArrow.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); GQ_RightArrow.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); LDD_Label.GetComponent <Text>().CrossFadeAlpha(0.01f, 0.3f, false); LDD_Arrow.GetComponent <Image>().CrossFadeAlpha(0.01f, 0.3f, false); SetUICategoryContent(44); DashboardStatus = false; }
void Start() { fov = GetComponentInChildren<FoV>(); player = GameObject.FindGameObjectWithTag("Player").transform; }
private void SetUICategoryContent(int Category) { switch (Category) { default: PlayedTime.SetActive(true); Reputation.SetActive(true); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); FoVSliderValue.SetActive(false); break; case 1: PlayedTime.SetActive(true); Reputation.SetActive(true); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); FoVSliderValue.SetActive(false); break; case 2: PlayedTime.SetActive(false); Reputation.SetActive(false); Language.SetActive(true); GraphicsQuality.SetActive(true); TextureQuality.SetActive(true); FoV.SetActive(true); GQ_LeftArrow.SetActive(true); GQ_RightArrow.SetActive(true); LDD.SetActive(true); FoVSliderValue.SetActive(true); break; case 3: PlayedTime.SetActive(false); Reputation.SetActive(false); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); FoVSliderValue.SetActive(false); break; case 4: PlayedTime.SetActive(false); Reputation.SetActive(false); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); FoVSliderValue.SetActive(false); break; case 5: PlayedTime.SetActive(false); Reputation.SetActive(false); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); break; case 44: PlayedTime.SetActive(false); Reputation.SetActive(false); Language.SetActive(false); GraphicsQuality.SetActive(false); TextureQuality.SetActive(false); FoV.SetActive(false); GQ_LeftArrow.SetActive(false); GQ_RightArrow.SetActive(false); LDD.SetActive(false); FoVSliderValue.SetActive(false); break; } }
public override void Calculate(RoamingNPC t) { if (t.rootDuration > 0) { t.rootDuration--; } else if (t.rooted) { t.rooted = false; } if (t.enemySO._Behaviour != EnemiesScriptableObject.E_behaviour.npc) { if (t.sleeping) { int distance = Mathf.Max(Mathf.Abs(PlayerMovement.playerMovement.position.x - t.__position.x), Mathf.Abs(PlayerMovement.playerMovement.position.y - t.__position.y)); if (distance < 7) { t.sleeping = false; } else { //Debug.Log("I am sleeping"); return; } } if (!t.gameObject.transform.parent.gameObject.activeSelf) { return; } t.TriggerEffectTasks(); bool searchEnemy = true; if (t.Board.ContainsKey("Target")) { if (t.Board["Target"] != null && t.Board["Target"] is RoamingNPC) { //Debug.Log("Has Target"); RoamingNPC testNPC = (RoamingNPC)t.Board["Target"]; if ((testNPC == null) || Vector2Int.Distance(PlayerMovement.playerMovement.position, testNPC.__position) > 5 || testNPC.gameObject == null) { t.Board["Target"] = null; } else { searchEnemy = false; } } } if (searchEnemy) { //Debug.Log("Has to search enemy"); Vector2Int enemyPos = new Vector2Int(-100, -100); float minDis = 10000; bool found = false; foreach (Vector2Int pos in FoV.GetEnemyFoV(t.__position)) { try { int dis = Mathf.Max(Mathf.Abs(PlayerMovement.playerMovement.position.x - pos.x), Mathf.Abs(PlayerMovement.playerMovement.position.y - pos.y)); if (MapManager.map[pos.x, pos.y].enemy != null && MapManager.map[pos.x, pos.y].enemy != t.gameObject && MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>().enemySO.MyTurnAI != t.enemySO.MyTurnAI && dis <= 4) { if (dis < minDis) { minDis = dis; enemyPos = pos; found = true; } } } catch { } } if (found) { //Debug.Log("Found enemy"); t.Board["Target"] = MapManager.map[enemyPos.x, enemyPos.y].enemy.GetComponent <RoamingNPC>(); } } if (t.Board.ContainsKey("Target")) { //Debug.Log("Has enemy missing: " + (t.Board["Target"] == null)); } if (t.Board.ContainsKey("Target") && t.Board["Target"] != null && t.Board["Target"] is RoamingNPC npc) { //Debug.Log("Target aquired"); int distance = Mathf.Max(Mathf.Abs(npc.__position.x - t.__position.x), Mathf.Abs(npc.__position.y - t.__position.y)); // move to target and attack var att = GetAttack(t); if (att.InRange(t.__position, npc.pos)) { att.Calculate((t, npc)); return; } else { t.path = null; t.path = AStar.CalculatePath(t.__position, npc.__position); Debug.Log(t.path.Count); if (!(PlayerMovement.playerMovement.position == t.path[0] || PlayerMovement.playerMovement.position == t.path[1])) { // Debug.Log("Move to enemy"); t.MoveTo(t.path[0].x, t.path[0].y); return; } } } // move to player // check if next to player int pDistance = Mathf.Max(Mathf.Abs(PlayerMovement.playerMovement.position.x - t.__position.x), Mathf.Abs(PlayerMovement.playerMovement.position.y - t.__position.y)); //Debug.Log(pDistance); if (pDistance == 1) { // we are too close Vector2Int diff = t.__position - PlayerMovement.playerMovement.position; // we move away from the player if (MapUtility.IsMoveable(t.__position.x + diff.x, t.__position.y + diff.y)) { t.MoveTo(t.__position.x + diff.x, t.__position.y + diff.y); } else { // find another way Vector2Int[] alternatives = MapUtility.Box1 .Copy() .Check((pos) => MapUtility.IsMoveable(pos) && MapUtility.MoveDistance(pos, PlayerMovement.playerMovement.position) == 2); if (alternatives.Length > 0) { Vector2Int target = alternatives.GetRandom(); t.MoveTo(target.x, target.y); } } } else { // check how far away // if far away follow if (pDistance > 2) { t.path = null; //Debug.Log("Follow"); t.path = AStar.CalculatePath(t.__position, PlayerMovement.playerMovement.position); //Debug.Log(t.path.Count); t.MoveTo(t.path[0].x, t.path[0].y); } else { // else go random Vector2Int[] alternatives = MapUtility.Box1 .Copy().Combine(MapUtility.Origin.Copy()) .MoveCenter(t.__position) .Check((pos) => MapUtility.IsMoveable(pos) && MapUtility.MoveDistance(pos, PlayerMovement.playerMovement.position) > 1); if (alternatives.Length > 0) { Vector2Int target = alternatives.GetRandom(); t.MoveTo(target.x, target.y); } } } } }
public override void Calculate(RoamingNPC t) { if (t.rootDuration > 0) { t.rootDuration--; } else if (t.rooted) { t.rooted = false; } //t.playerDetected = false; if (t.enemySO._Behaviour != EnemiesScriptableObject.E_behaviour.npc) { if (t.sleeping) { return; } if (!t.gameObject.transform.parent.gameObject.activeSelf) { return; } t.TriggerEffectTasks(); if (t.CurrentTarget != null && t.CurrentTarget.currHp == 0) { t.CurrentTarget = null; } // check for out of sight enemy if (!(t.CurrentTarget == null)) { if (!FoV.InLineOfSight(t.pos, t.CurrentTarget.pos)) { // out of sight out of mind i guess t.LastKnownTargetPos = t.CurrentTarget.pos; t.CurrentTarget = null; // TODO: make enemy run to last known position } } // check if current target is still valid if (!(t.CurrentTarget == null)) { // we are targeting something // range here if (MapUtility.MoveDistance(t.pos, t.CurrentTarget.pos) == 1) { // the target is in attackrange so we dont change anything } else { // target may be running away. we are looking at other potential targets that are near us if (t.RetailiationList.Count > 0) { // we have recently been attacked by somebody var alt = t.RetailiationList.ToArray().Check((u) => MapUtility.MoveDistance(u.pos, t.pos) == 1); if (alt.Length > 0) { t.CurrentTarget = alt.GetRandom(); } } } } else { // look for possible target var view = FoV.GetEnemyFoV(t.__position).ToArray().Check((p) => MapManager.map[p.x, p.y].hasPlayer || MapManager.map[p.x, p.y].enemy != null); if (view.Length > 0) { List <IUnit> possibleTargets = new List <IUnit>(); IUnit nt = null; foreach (var pos in view) { if (MapManager.map[pos.x, pos.y].enemy != null && MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>().enemySO.MyTurnAI is HelperTurnBehaviour) { // we found a doggo to attack if (nt == null) { nt = MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>(); t.LastKnownTargetPos = nt.pos; } else { if (MapUtility.MoveDistance(t.pos, nt.pos) > MapUtility.MoveDistance(t.pos, pos)) { nt = MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>(); t.LastKnownTargetPos = nt.pos; } } } if (MapManager.map[pos.x, pos.y].hasPlayer) { if (nt == null && !GameManager.manager.playerStats.isInvisible) { if (t.enemySO.canSpeak) { int r = Random.Range(1, 4); if (r == 1) { GameManager.manager.UpdateMessages($"<b>{GameManager.manager.monsterDetectPlayer[Random.Range(0, GameManager.manager.monsterDetectPlayer.Count)]}</b> " + $"said <color=#{t.enemySO.E_color}>{t.enemySO.E_name}</color> in a terrifying voice."); } else if (r == 2) { GameManager.manager.UpdateMessages($"<color=#{t.enemySO.E_color}>{t.enemySO.E_name}</color> makes incomprehensible sounds."); } else if (r == 3) { GameManager.manager.UpdateMessages($"When <color=#{t.enemySO.E_color}>{t.enemySO.E_name}</color> noticed you it started screaming and moaning terribly."); } } nt = t.playerStats; try { t.LastKnownTargetPos = nt.pos; } catch { } } else { if (MapUtility.MoveDistance(t.pos, nt.pos) > MapUtility.MoveDistance(t.pos, pos)) { nt = t.playerStats; t.LastKnownTargetPos = nt.pos; } } } } if (nt != null) { // found the closest possible target: t.CurrentTarget = nt; t.LastKnownTargetPos = nt.pos; } } } switch (t.enemySO._Behaviour) { case EnemiesScriptableObject.E_behaviour.cowardly: if (t.__currentHp <= (t.maxHp / 2) && (int)Random.Range(0, 2) == 1 && t.runCounter > 0 || (t.runCounter > 0 && t.runCounter < 5)) //RUN FROM PLAYER { t.runDirection = t.__position - MapManager.playerPos; Vector2Int runCell = t.__position + t.runDirection; t.runCounter--; t.path = null; t.path = AStar.CalculatePath(t.__position, runCell); t.MoveTo(t.path[0].x, t.path[0].y); return; } else { t.runCounter = 5; } break; case EnemiesScriptableObject.E_behaviour.recovers: if (t.__currentHp <= (t.maxHp / 2) && t.hpRegenCooldown == 0) { t.hpRegenCooldown--; t.__currentHp += Mathf.FloorToInt(t.maxHp * .25f); return; } else if (t.hpRegenCooldown < 10 && t.hpRegenCooldown > 0) { t.hpRegenCooldown--; } break; } if (t.CurrentTarget != null) { var att = GetAttack(t); if (att.InRange(t.__position, t.CurrentTarget.pos)) { att.Calculate((t, t.CurrentTarget)); return; } /* * if (new Vector2Int(t.__position.x - 1, t.__position.y) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x + 1, t.__position.y) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x, t.__position.y - 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x, t.__position.y + 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x - 1, t.__position.y - 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x + 1, t.__position.y - 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x - 1, t.__position.y + 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } * else if (new Vector2Int(t.__position.x + 1, t.__position.y + 1) == MapManager.playerPos) * { * GetAttack(t).Attack(t, t.playerStats); * return; * } */ t.path = null; t.path = AStar.CalculatePath(t.__position, t.CurrentTarget.pos); t.MoveTo(t.path[0].x, t.path[0].y); } else { if (t._x > 0) { t._x--; t.path = null; t.path = AStar.CalculatePath(t.__position, MapManager.playerPos); t.MoveTo(t.path[0].x, t.path[0].y); } else { t.MoveTo(t.__position.x + Random.Range(-1, 2), t.__position.y + Random.Range(-1, 2)); //move to random direction } } } else { if (!t.gameObject.transform.parent.gameObject.activeSelf) { return; } if (t.enemySO.finishedDialogue) { t.MoveTo(t.__position.x + (int)Random.Range(-1, 2), t.__position.y + (int)Random.Range(-1, 2)); //move to random direction } } }
public override void Calculate(RoamingNPC t) { if (t.rootDuration > 0) { t.rootDuration--; } else if (t.rooted) { t.rooted = false; } //t.playerDetected = false; if (t.sleeping) { return; } if (!t.gameObject.transform.parent.gameObject.activeSelf) { return; } t.TriggerEffectTasks(); if (t.CurrentTarget != null && t.CurrentTarget.currHp == 0) { t.CurrentTarget = null; } // check for out of sight enemy if (!(t.CurrentTarget == null)) { if (!FoV.InLineOfSight(t.pos, t.CurrentTarget.pos)) { // out of sight out of mind i guess t.LastKnownTargetPos = t.CurrentTarget.pos; t.CurrentTarget = null; // TODO: make enemy run to last known position } } // check if current target is still valid if (!(t.CurrentTarget == null)) { // we are targeting something // range here if (MapUtility.MoveDistance(t.pos, t.CurrentTarget.pos) == 1) { // the target is in attackrange so we dont change anything } else { // target may be running away. we are looking at other potential targets that are near us if (t.RetailiationList.Count > 0) { // we have recently been attacked by somebody var alt = t.RetailiationList.ToArray().Check((u) => MapUtility.MoveDistance(u.pos, t.pos) == 1); if (alt.Length > 0) { t.CurrentTarget = alt.GetRandom(); } } } } else { // look for possible target var view = FoV.GetEnemyFoV(t.__position).ToArray().Check((p) => MapManager.map[p.x, p.y].hasPlayer || MapManager.map[p.x, p.y].enemy != null); if (view.Length > 0) { List <IUnit> possibleTargets = new List <IUnit>(); IUnit nt = null; foreach (var pos in view) { if (MapManager.map[pos.x, pos.y].enemy != null && MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>().enemySO.MyTurnAI is HelperTurnBehaviour) { // we found a doggo to attack if (nt == null) { nt = MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>(); t.LastKnownTargetPos = nt.pos; } else { if (MapUtility.MoveDistance(t.pos, nt.pos) > MapUtility.MoveDistance(t.pos, pos)) { nt = MapManager.map[pos.x, pos.y].enemy.GetComponent <RoamingNPC>(); t.LastKnownTargetPos = nt.pos; } } } if (MapManager.map[pos.x, pos.y].hasPlayer) { if (nt == null) { nt = t.playerStats; t.LastKnownTargetPos = nt.pos; } else { if (MapUtility.MoveDistance(t.pos, nt.pos) > MapUtility.MoveDistance(t.pos, pos)) { nt = t.playerStats; t.LastKnownTargetPos = nt.pos; } } } } if (nt != null) { // found the closest possible target: t.CurrentTarget = nt; t.LastKnownTargetPos = nt.pos; } } } if (t.CurrentTarget != null) { var att = GetAttack(t); if (att.BlobInRange(t.__position, t.CurrentTarget.pos)) { att.Calculate((t, t.CurrentTarget)); return; } t.path = null; t.path = AStar.CalculatePath(t.__position, t.CurrentTarget.pos); BlobMoveTo(t, t.path[0].x, t.path[0].y); } else { if (t._x > 0) { t._x--; t.path = null; t.path = AStar.CalculatePath(t.__position, MapManager.playerPos); BlobMoveTo(t, t.path[0].x, t.path[0].y); } else { //BlobMoveTo(t, t.__position.x + Random.Range(-1, 2), t.__position.y + Random.Range(-1, 2)); //move to random direction } } }
private void Update() { // advance time MoveCooldown = Mathf.Max(MoveCooldown - Time.deltaTime, 0); if (manager.isPlayerTurn && canMove) { if (MoveCooldown == 0) { Vector2Int move = new Vector2Int(); if (Controls.GetKeyDown(Controls.Inputs.MoveUp) || Controls.GetKey(Controls.Inputs.MoveUp)) { move.y = 1; } if (Controls.GetKeyDown(Controls.Inputs.MoveDown) || Controls.GetKey(Controls.Inputs.MoveDown)) { move.y = -1; } if (Controls.GetKeyDown(Controls.Inputs.MoveLeft) || Controls.GetKey(Controls.Inputs.MoveLeft)) { move.x = -1; } if (Controls.GetKeyDown(Controls.Inputs.MoveRight) || Controls.GetKey(Controls.Inputs.MoveRight)) { move.x = 1; } if (Controls.GetKeyDown(Controls.Inputs.MoveUpLeft) || Controls.GetKey(Controls.Inputs.MoveUpLeft)) { move.x = -1; move.y = 1; } if (Controls.GetKeyDown(Controls.Inputs.MoveUpRight) || Controls.GetKey(Controls.Inputs.MoveUpRight)) { move.x = 1; move.y = 1; } if (Controls.GetKeyDown(Controls.Inputs.MoveDownRight) || Controls.GetKey(Controls.Inputs.MoveDownRight)) { move.x = 1; move.y = -1; } if (Controls.GetKeyDown(Controls.Inputs.MoveDownLeft) || Controls.GetKey(Controls.Inputs.MoveDownLeft)) { move.x = -1; move.y = -1; } if (Controls.GetKeyDown(Controls.Inputs.CloseDoors) || Controls.GetKey(Controls.Inputs.CloseDoors)) { if (MapManager.map[position.x - 1, position.y + 1]?.structure is Door door) { door.CloseDoor(); } if (MapManager.map[position.x, position.y + 1]?.structure is Door door1) { door1.CloseDoor(); } if (MapManager.map[position.x + 1, position.y + 1]?.structure is Door door2) { door2.CloseDoor(); } if (MapManager.map[position.x + 1, position.y]?.structure is Door door4) { door4.CloseDoor(); } if (MapManager.map[position.x + 1, position.y - 1]?.structure is Door door5) { door5.CloseDoor(); } if (MapManager.map[position.x, position.y - 1]?.structure is Door door6) { door6.CloseDoor(); } if (MapManager.map[position.x - 1, position.y - 1]?.structure is Door door7) { door7.CloseDoor(); } if (MapManager.map[position.x - 1, position.y]?.structure is Door door8) { door8.CloseDoor(); } manager.FinishPlayersTurn(); } if (move.sqrMagnitude > 0) { Move(InputToVector(move.x, move.y)); MoveCooldown = MoveDelay; } } Selector.Current.SelectedTile(position.x, position.y); if (Controls.GetKeyUp(Controls.Inputs.Use)) { if (MapManager.map[position.x, position.y].item != null) { if (playerStats.maximumInventorySpace > playerStats.currentItems && playerStats.currentWeight + MapManager.map[position.x, position.y].item.GetComponent <Item>().iso.I_weight <= playerStats.maxWeight) { playerStats.currentWeight += MapManager.map[position.x, position.y].item.GetComponent <Item>().iso.I_weight; playerStats.Pickup(MapManager.map[position.x, position.y].item, MapManager.map[position.x, position.y].item.GetComponent <Item>().iso, target); MapManager.map[position.x, position.y].letter = ""; MapManager.map[position.x, position.y].baseChar = "."; MapManager.map[position.x, position.y].exploredColor = new Color(1, 1, 1); MapManager.map[position.x, position.y].hasPlayer = false; MapManager.map[position.x, position.y].timeColor = new Color(0, 0, 0); position = target; MapManager.map[position.x, position.y].hasPlayer = true; MapManager.map[position.x, position.y].baseChar = "."; MapManager.map[position.x, position.y].timeColor = new Color(0.5f, 1, 0); MapManager.map[position.x, position.y].letter = "@"; MapManager.playerPos = new Vector2Int(position.x, position.y); } else if (playerStats.maximumInventorySpace < playerStats.currentItems) { manager.UpdateMessages("Your backpack can't hold any more items!"); MapManager.map[position.x, position.y].letter = ""; MapManager.map[position.x, position.y].hasPlayer = false; MapManager.map[position.x, position.y].timeColor = new Color(0, 0, 0); position = target; MapManager.map[position.x, position.y].hasPlayer = true; MapManager.map[position.x, position.y].timeColor = new Color(0.5f, 1, 0); MapManager.map[position.x, position.y].letter = "@"; MapManager.playerPos = new Vector2Int(position.x, position.y); } else if (playerStats.currentWeight + MapManager.map[target.x, target.y].item.GetComponent <Item>().iso.I_weight > playerStats.maxWeight) { if (!MapManager.map[target.x, target.y].item.GetComponent <Item>().identified) { manager.UpdateMessages($"The {MapManager.map[target.x, target.y].item.GetComponent<Item>().iso.I_unInName} is too heavy. It weighs {MapManager.map[target.x, target.y].item.GetComponent<Item>().iso.I_weight}"); } else { manager.UpdateMessages($"The {MapManager.map[target.x, target.y].item.GetComponent<Item>().iso.I_name} is too heavy. It weighs {MapManager.map[target.x, target.y].item.GetComponent<Item>().iso.I_weight}"); } MapManager.map[position.x, position.y].letter = ""; MapManager.map[position.x, position.y].hasPlayer = false; MapManager.map[position.x, position.y].timeColor = new Color(0, 0, 0); position = target; MapManager.map[position.x, position.y].hasPlayer = true; MapManager.map[position.x, position.y].timeColor = new Color(0.5f, 1, 0); MapManager.map[position.x, position.y].letter = "@"; MapManager.playerPos = new Vector2Int(position.x, position.y); } } else if (MapManager.map[position.x, position.y].structure != null) { MapManager.map[position.x, position.y].structure.Use(); //FOVNEW.fv.Initialize(FOVNEW.fv.CanLightPass, FOVNEW.fv.SetToVisible, FOVNEW.fv.Distance); FoV.Initialize(); //manager.UpdateVisibility(); manager.StartPlayersTurn(); manager.fv.Compute(position, playerStats.viewRange); DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map); } } } else if (isStunned) { isStunned = false; canMove = true; manager.FinishPlayersTurn(); } }