Esempio n. 1
0
        protected override void ActionMethod(Pathfinding.Pathfinder pathfinder)
        {
            PseudoBlock pseudo = new PseudoBlock(m_block, m_forward, m_upward);

            pathfinder.NavSet.Settings_Task_NavRot.LandingBlock = pseudo;
            pathfinder.NavSet.LastLandingBlock = pseudo;
        }
Esempio n. 2
0
        void Update()
        {
            if (start)
            {
                start = false;

                Pathfinding.Pathfinder path = new Pathfinding.Pathfinder();

                int N1x = Random.Range(1, 11);
                int N1y = Random.Range(1, 3);
                int N2x = Random.Range(1, 11);
                int N2y = Random.Range(11, 13);

                Node startNode = grid [N1x, N1y];
                Node end       = grid [N2x, N2y];

                path.start = startNode;
                path.end   = end;

                List <Node> p = path.FindPath();

                reset = p;

                startNode.vis.SetActive(false);

                reset.Add(startNode);

                foreach (Node n in p)
                {
                    n.vis.SetActive(false);
                }
            }
        }
Esempio n. 3
0
 protected override void ActionMethod(Pathfinding.Pathfinder pathfinder)
 {
     pathfinder.NavSet.Settings_Task_NavRot.DestinationBlock = new Data.BlockNameOrientation(m_searchBlockName.ToString(), m_forward, m_upward);
 }
Esempio n. 4
0
        /// <summary>
        /// Ran on a thread and handles walking and pathfinding. All status updates are sent to all room users.
        /// </summary>
        private void cycleStatuses()
        {
            List<int> toRemove = new List<int>();
            while (true)
            {
                try
                {
                    foreach (virtualRoomUser roomUser in _Users.Values)
                    #region Virtual user status handling
                    {
                        if (roomUser.goalX == -1) // No destination set, user is not walking/doesn't start to walk, advance to next user
                            continue;

                        // If the goal is a seat, then allow to 'walk' on the seat, so seat the user
                        squareState[,] stateMap = (squareState[,])sqSTATE.Clone();
                        try
                        {
                            if (stateMap[roomUser.goalX, roomUser.goalY] == squareState.Seat || stateMap[roomUser.goalX, roomUser.goalY] == squareState.Bed)
                                stateMap[roomUser.goalX, roomUser.goalY] = squareState.Open;
                            if (sqUNIT[roomUser.goalX, roomUser.goalY])
                                stateMap[roomUser.goalX, roomUser.goalY] = squareState.Blocked;
                        }
                        catch { }
                        // Use AStar pathfinding to get the next step to the goal
                        int[] nextCoords = new Pathfinding.Pathfinder(stateMap, sqFLOORHEIGHT, sqUNIT).getNext(roomUser.X, roomUser.Y, roomUser.goalX, roomUser.goalY);

                        roomUser.statusManager.removeStatus("mv");
                        if (nextCoords == null) // No next steps found, destination reached/stuck
                        {
                            roomUser.goalX = -1; // Next time the thread cycles this user, it won't attempt to walk since destination has been reached
                            if (sqTRIGGER[roomUser.X, roomUser.Y] != null)
                            {
                                squareTrigger Trigger = sqTRIGGER[roomUser.X, roomUser.Y];
                                if (this.hasSwimmingPool) // This virtual room has a swimming pool
                                #region Swimming pool triggers
                                {
                                    if (Trigger.Object == "curtains1" || Trigger.Object == "curtains2") // User has entered a swimming pool clothing booth
                                    {
                                        roomUser.walkLock = true;
                                        roomUser.User.sendData("A`");
                                        sendSpecialCast(Trigger.Object, "close");
                                    }
                                    else if (roomUser.swimOutfit != "") // User wears a swim outfit and hasn't entered a swimming pool clothing booth
                                    {

                                        if (Trigger.Object.Contains("Splash")) // User has entered/left a swimming pool
                                        {
                                            sendData("AG" + Trigger.Object);
                                            if (Trigger.Object.Substring(8) == "enter")
                                            {
                                                roomUser.statusManager.dropCarrydItem();
                                                roomUser.statusManager.addStatus("swim", "");
                                            }
                                            else
                                                roomUser.statusManager.removeStatus("swim");
                                            moveUser(roomUser, Trigger.stepX, Trigger.stepY, false);

                                            roomUser.goalX = Trigger.goalX;
                                            roomUser.goalY = Trigger.goalY;
                                        }
                                    }
                                }

                                #endregion
                                else
                                {
                                    // Different trigger species here
                                }
                            }
                            else if (roomUser.walkDoor) // User has clicked the door to leave the room (and got stuck while walking or reached destination)
                            {
                                if (_Users.Count > 1)
                                {
                                    removeUser(roomUser.roomUID, true, "");
                                    continue;
                                }
                                else
                                {
                                    removeUser(roomUser.roomUID, true, "");
                                    return;
                                }
                            }
                            _statusUpdates.Append(roomUser.statusString + Convert.ToChar(13));
                        }

                        else // Next steps found by pathfinder
                        {
                            int nextX = nextCoords[0];
                            int nextY = nextCoords[1];
                            squareState nextState = sqSTATE[nextX, nextY];

                            sqUNIT[roomUser.X, roomUser.Y] = false; // Free last position, allow other users to use that spot again
                            sqUNIT[nextX, nextY] = true; // Block the spot of the next steps
                            roomUser.Z1 = Pathfinding.Rotation.Calculate(roomUser.X, roomUser.Y, nextX, nextY); // Calculate the users new rotation
                            roomUser.Z2 = roomUser.Z1;
                            roomUser.statusManager.removeStatus("sit");
                            roomUser.statusManager.removeStatus("lay");

                            double nextHeight = 0;
                            if (nextState == squareState.Rug) // If next step is on a rug, then set user's height to that of the rug [floating stacked rugs in mid-air, petals etc]
                                nextHeight = sqITEMHEIGHT[nextX, nextY];
                            else
                                nextHeight = (double)sqFLOORHEIGHT[nextX, nextY];

                            // Add the walk status to users status manager + add users whole status string to stringbuilder
                            roomUser.statusManager.addStatus("mv", nextX + "," + nextY + "," + nextHeight.ToString().Replace(',', '.'));
                            _statusUpdates.Append(roomUser.statusString + Convert.ToChar(13));

                            // Set new coords for virtual room user
                            roomUser.X = nextX;
                            roomUser.Y = nextY;
                            roomUser.H = nextHeight;
                            if (nextState == squareState.Seat) // The next steps are on a seat, seat the user, prepare the sit status for next cycle of thread
                            {
                                roomUser.statusManager.removeStatus("dance"); // Remove dance status
                                roomUser.Z1 = sqITEMROT[nextX, nextY]; //
                                roomUser.Z2 = roomUser.Z1;
                                roomUser.statusManager.addStatus("sit", sqITEMHEIGHT[nextX, nextY].ToString().Replace(',', '.'));
                            }
                            else if (nextState == squareState.Bed)
                            {
                                roomUser.statusManager.removeStatus("dance"); // Remove dance status
                                roomUser.Z1 = sqITEMROT[nextX, nextY]; //
                                roomUser.Z2 = roomUser.Z1;
                                roomUser.statusManager.addStatus("lay", sqITEMHEIGHT[nextX, nextY].ToString().Replace(',', '.'));
                            }
                        }
                    }
                    foreach (int toKick in toRemove)
                    {
                        removeUser(toKick, true, "");
                    }
                    toRemove.Clear();
                }
                catch (Exception e) { Out.WriteError(e.Message); }

                    #endregion

                #region Roombot walking
                foreach (virtualBot roomBot in _Bots.Values)
                {
                    if (roomBot.goalX == -1)
                        continue;

                    // If the goal is a seat, then allow to 'walk' on the seat, so seat the user
                    squareState[,] stateMap = (squareState[,])sqSTATE.Clone();
                    try
                    {
                        if (stateMap[roomBot.goalX, roomBot.goalY] == squareState.Seat)
                            stateMap[roomBot.goalX, roomBot.goalY] = squareState.Open;
                        if (sqUNIT[roomBot.goalX, roomBot.goalY])
                            stateMap[roomBot.goalX, roomBot.goalY] = squareState.Blocked;
                    }
                    catch { }

                    int[] nextCoords = new Pathfinding.Pathfinder(stateMap, sqFLOORHEIGHT, sqUNIT).getNext(roomBot.X, roomBot.Y, roomBot.goalX, roomBot.goalY);

                    roomBot.removeStatus("mv");
                    if (nextCoords == null) // No next steps found, destination reached/stuck
                    {
                        if (roomBot.X == roomBot.goalX && roomBot.Y == roomBot.goalY)
                        {
                            roomBot.checkOrders();
                        }
                        roomBot.goalX = -1;
                        _statusUpdates.Append(roomBot.statusString + Convert.ToChar(13));
                    }
                    else
                    {
                        int nextX = nextCoords[0];
                        int nextY = nextCoords[1];

                        sqUNIT[roomBot.X, roomBot.Y] = false; // Free last position, allow other users to use that spot again
                        sqUNIT[nextX, nextY] = true; // Block the spot of the next steps
                        roomBot.Z1 = Pathfinding.Rotation.Calculate(roomBot.X, roomBot.Y, nextX, nextY); // Calculate the bot's new rotation
                        roomBot.Z2 = roomBot.Z1;
                        roomBot.removeStatus("sit");

                        double nextHeight = (double)sqFLOORHEIGHT[nextX, nextY];
                        if (sqSTATE[nextX, nextY] == squareState.Rug) // If next step is on a rug, then set bot's height to that of the rug [floating stacked rugs in mid-air, petals etc]
                            nextHeight = sqITEMHEIGHT[nextX, nextY];
                        else
                            nextHeight = (double)sqFLOORHEIGHT[nextX, nextY];

                        roomBot.addStatus("mv", nextX + "," + nextY + "," + nextHeight.ToString().Replace(',', '.'));
                        _statusUpdates.Append(roomBot.statusString + Convert.ToChar(13));

                        // Set new coords for the bot
                        roomBot.X = nextX;
                        roomBot.Y = nextY;
                        roomBot.H = nextHeight;
                        if (sqSTATE[nextX, nextY] == squareState.Seat) // The next steps are on a seat, seat the bot, prepare the sit status for next cycle of thread
                        {
                            roomBot.removeStatus("dance"); // Remove dance status
                            roomBot.Z1 = sqITEMROT[nextX, nextY]; //
                            roomBot.Z2 = roomBot.Z1;
                            roomBot.addStatus("sit", sqITEMHEIGHT[nextX, nextY].ToString().Replace(',', '.'));
                        }
                    }
                }
                #endregion

                // Send statuses to all room users [if in stringbuilder]
                try
                {
                    if (_statusUpdates.Length > 0)
                    {
                        sendData("@b" + _statusUpdates.ToString());
                        _statusUpdates = new StringBuilder();
                    }
                }
                catch { }

                Thread.Sleep(410);

            } // Repeat (infinite loop on thread)
            // }
            //      // thread aborted
        }
Esempio n. 5
0
 protected override void ActionMethod(Pathfinding.Pathfinder pathfinder)
 {
     new UnLander(pathfinder, new Data.PseudoBlock(m_block, m_forward, m_upward));
 }
Esempio n. 6
0
        public void Flee(float mag, GameObject caster)
        {
            //I'm stealing large swathes of this code from the launching code I wrote earlier, hence some of the variables.
            Vector2 direct = this.transform.position - caster.transform.position;

            RaycastHit2D[] hit = Physics2D.RaycastAll(this.transform.position, direct, mag);
            Debug.DrawRay(this.transform.position, direct, Color.red, 100, false);


            bool hitWall = false;

            foreach (RaycastHit2D h in hit)
            {
                if (h.collider.gameObject.tag != "Tile")
                {
                    hitWall = true;
                }
                else if (h.collider.gameObject.GetComponent <CoordinateHolder>().isWall == true)
                {
                    hitWall = true;
                }
            }

            if (hitWall == false)
            {
                Node  sendNode = null;
                float tempDist = 0f;
                foreach (RaycastHit2D h in hit)
                {
                    if (h.collider.gameObject.tag == "Tile")
                    {
                        Node n = GridHandler.instance.GetNode(Mathf.RoundToInt(h.collider.gameObject.GetComponent <CoordinateHolder>().corX), Mathf.RoundToInt(h.collider.gameObject.GetComponent <CoordinateHolder>().corY));
                        if (Vector2.Distance(this.gameObject.transform.position, n.worldObject.transform.position) > tempDist)
                        {
                            tempDist = Vector2.Distance(this.gameObject.transform.position, n.worldObject.transform.position);
                            sendNode = n;
                        }
                    }
                }

                if (sendNode != null)
                {
                    Pathfinding.Pathfinder path = new Pathfinding.Pathfinder();

                    Node startNode = GridHandler.instance.GetNode(Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corX), Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corY));
                    Node end       = sendNode;

                    path.startPosition = startNode;
                    path.endPosition   = end;
                    path.pather        = this.gameObject;

                    controller.pathway     = path.FindPath();
                    controller.fleeingMove = true;

                    if (controller.pathway != null)
                    {
                        controller.Movement(controller.pathway);
                    }

                    controller.actionCount++;
                    fledCheck = false;
                }
                else if (mag > 0.01f)
                {
                    Flee(mag - 0.01f, caster);
                }
                else
                {
                    fledCheck = false;
                    controller.cannotActRepair();
                }
            }
            else if (mag > 0.01f)
            {
                Flee(mag - 0.01f, caster);
            }
            else
            {
                fledCheck = false;
                controller.cannotActRepair();
            }
        }
Esempio n. 7
0
 protected abstract void ActionMethod(Pathfinding.Pathfinder pathfinder);
        void Update()
        {
            if (this.gameObject.GetComponent <CharacterData>().isUnconscious == true)
            {
                willHostile = false;
                hostile     = false;
                canAct      = false;
            }

            if (hostile == false && willHostile == true && FactionHandler.instance.hasSetUp == true && GridHandler.instance.hasGenerated == true)
            {
                if (this.gameObject.GetComponent <CharacterData>().canSee == true)
                {
                    actors = GameObject.FindGameObjectsWithTag("Actor");
                    foreach (GameObject g in actors)
                    {
                        foreach (PhysicalProperties.Relationship r in this.gameObject.GetComponent <PhysicalProperties>().animate.mind.relationships)
                        {
                            if (r.relTarget == g && r.relationshipNumber < -100)
                            {
                                if (Vector3.Distance(g.transform.position, this.gameObject.transform.position) < this.gameObject.GetComponent <CharacterData>().hostileDist)
                                {
                                    hostile = true;
                                    rnd.Startuptime();
                                }
                            }
                            else if (r.relTarget == g && r.relationshipNumber < -25 && this.gameObject.GetComponent <CharacterData>().factionArray.relationships[g.gameObject.GetComponent <CharacterData>().factionID].atWar == true)
                            {
                                if (Vector3.Distance(g.transform.position, this.gameObject.transform.position) < this.gameObject.GetComponent <CharacterData>().hostileDist)
                                {
                                    hostile = true;
                                    rnd.Startuptime();
                                }
                            }
                        }
                    }
                }
            }
            else if (willHostile == false && hostile == true)
            {
                hostile = false;
            }
            else if (hostile == true && willHostile == true && rnd.inCombat == false)
            {
                rnd.Startuptime();
            }



            myPosition = this.transform.position;

            if (isLaunching == true)
            {
                if (hasAn == false)
                {
                    hasAn = true;
                }
                Vector3 weightlessMod = new Vector3(0, 0, 0);

                if (isWeightless == false)
                {
                    transform.position = Vector3.Lerp(myPosition, landNode.worldObject.transform.position + this.gameObject.GetComponent <CharacterData>().alignMod, 0.1f * launchSpeed);
                }
                else
                {
                    weightlessMod      = new Vector3(myPosition.x, this.gameObject.GetComponent <PhysicalProperties>().floatPosition.y, 0f);
                    transform.position = Vector3.Lerp(myPosition, landNode.worldObject.transform.position + this.gameObject.GetComponent <CharacterData>().alignMod + weightlessMod, 0.1f * launchSpeed);
                }

                if (Vector2.Distance(landNode.worldObject.transform.position + this.gameObject.GetComponent <CharacterData>().alignMod + weightlessMod, this.transform.position) < 0.05f)
                {
                    this.transform.parent = landNode.worldObject.transform;
                    if (this.gameObject.GetComponent <PhysicalProperties>().xMomentum == 0 && this.gameObject.GetComponent <PhysicalProperties>().yMomentum == 0)
                    {
                        canAct = true;
                        stunCounter++;
                        isLaunching = false;
                        landNode    = null;
                        launchSpeed = 0f;
                        hasAn       = false;
                    }
                }
            }
            // if (isWeightless == true) {
            //     transform.position = Vector3.Lerp(this.transform.position, this.gameObject.GetComponent<PhysicalProperties>().floatPosition, 0.05f);
            // }

            if (Input.GetButtonDown("Pick Up") && grabbingItems == false && isMoving == false && bookOpen == false && this.gameObject.GetComponent <CharacterData>().isDead == false && isCasting == false)
            {
                grabbingItems = true;
                items         = new List <GameObject>();
                foreach (GameObject g in GameObject.FindGameObjectsWithTag("Item"))
                {
                    if (g.GetComponent <ItemData>().isInInven == false)
                    {
                        items.Add(g);
                    }
                }

                int t = 0;
                if (items != null)
                {
                    pickableItems = new List <GameObject>();
                    foreach (GameObject i in items)
                    {
                        if (Vector2.Distance(i.transform.position, this.transform.position) <= 0.25f && i.GetComponent <ItemData>().isInInven == false)
                        {
                            pickableItems.Add(i);
                            t++;
                        }
                    }
                }
            }
            else if (Input.GetButtonDown("Pick Up") && grabbingItems == true)
            {
                grabbingItems = false;
                items         = null;
                pickableItems = null;
            }

            if (isMoving == true)
            {
                grabbingItems = false;
                items         = null;
                pickableItems = null;
            }

            if (this.gameObject.GetComponent <CharacterData>().isDead == true)
            {
                isTurn = false;
                rnd.NextRound();
            }

            if (hasTakenTurn == true && isTurn == true)
            {
                if (this.gameObject.GetComponent <CharacterData>().bleedCounter > 0)
                {
                    this.gameObject.GetComponent <PhysicalProperties>().TakeBioDamage(5f, (PhysicalProperties.DamageType) 4);
                    this.gameObject.GetComponent <CharacterData>().bleedCounter--;
                }

                isTurn = false;
                Invoke("AllowTurn", 1f);
            }

            tiles = GameObject.FindGameObjectsWithTag("Tile");

            if (this.transform.parent != null && isMoving == false && isLaunching == false && isWeightless == false)
            {
                this.transform.position = this.transform.parent.position + this.gameObject.GetComponent <CharacterData>().alignMod;
            }

            if (isMoving == true)
            {
                if (myPosition.x > destination.x)
                {
                    isFlipped = true;
                    this.GetComponent <SpriteRenderer>().flipX = true;
                }
                if (myPosition.x < destination.x)
                {
                    isFlipped = false;
                    this.GetComponent <SpriteRenderer>().flipX = false;
                }

                if (Manager.instance.walkType == 1)
                {
                    transform.position = Vector3.MoveTowards(transform.position, destination, this.gameObject.GetComponent <CharacterData>().speed *Time.deltaTime);
                }
                else if (Manager.instance.walkType == 2)
                {
                    transform.position = Vector3.Lerp(myPosition, destination, this.GetComponent <CharacterData>().speed * 10 * Time.deltaTime);
                }
                if (Vector2.Distance(myPosition, destination) < 0.01f)
                {
                    if (isRoaming == true)
                    {
                        FreeMovement(pathway);
                    }
                    if (isRoaming == false && isRepairing == false)
                    {
                        Movement(pathway);
                    }
                }
            }

            if (stunCounter > 0 && isTurn == true && hasTakenTurn == false)
            {
                stunCounter--;
                actionCount  = 0;
                hasTakenTurn = true;
                AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " is stunned.", false);
            }

            if (isTurn == true && hasTakenTurn == false && canAct == false)
            {
                actionCount  = 0;
                hasTakenTurn = true;
            }

            if (isTurn == true && hasTakenTurn == false && isLaunching == false && canAct == true)
            {
                if (this.GetComponent <CharacterData>().isPlayer == false)
                {
                    if (actionCount < maxActionCount && isMoving == false && isAttacking == false)
                    {
                        actors   = null;
                        actors   = GameObject.FindGameObjectsWithTag("Actor");
                        enemTarg = NearestEnemyCalc().worldObject.transform.GetChild(0).gameObject;

                        if (hostile == true)
                        {
                            Pathfinding.Pathfinder path = new Pathfinding.Pathfinder();

                            Node startNode = gridBase.GetNode(Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corX), Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corY));
                            Node end       = targNode;

                            path.startPosition = startNode;
                            path.endPosition   = end;
                            path.pather        = this.gameObject;

                            pathway = path.FindPath();

                            if (pathway != null && pathway.Count > 2)
                            {
                                farPlay = true;
                            }
                            else if (pathway != null && pathway.Count == 2)
                            {
                                semiPlay = true;
                            }
                            else if (pathway != null && pathway.Count == 1)
                            {
                                nearPlay = true;
                            }
                            else if (pathway.Count == 0)
                            {
                                herePlay = true;
                            }
                            else if (farPlay != true && semiPlay != true && nearPlay != true && herePlay != true)
                            {
                                Invoke("cannotActRepair", 1.5f);
                            }
                        }
                        else if (actionCount >= maxActionCount)
                        {
                            Invoke("cannotActRepair", 1.5f);
                        }
                    }
                }

                if (this.GetComponent <CharacterData>().isPlayer == true && CharacterData.instance.isDead == false)
                {
                    if (actionCount < maxActionCount && isMoving == false && EquipmentRenderer.instance.testInven == false && bookOpen == false && isCasting == false && isAttacking == false)
                    {
                        if (moveTake == true && this.gameObject.GetComponent <CharacterData>().moveDistance > 0 && canMove == true)
                        {
                            moveSelect = false;
                            moveTake   = false;

                            FindSelectedTile();

                            Pathfinding.Pathfinder path = new Pathfinding.Pathfinder();

                            Node startNode = gridBase.GetNode(Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corX), Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corY));
                            Node end       = targNode;

                            path.startPosition = startNode;
                            path.endPosition   = end;
                            path.pather        = this.gameObject;

                            pathway = path.FindPath();

                            bool canPath = true;

                            if (pathway == null)
                            {
                                canPath = false;
                            }
                            else if (pathway != null)
                            {
                                if (pathway[0] == startNode)
                                {
                                    canPath = false;
                                }
                            }


                            if (pathway.Count > 0 && canPath == true)
                            {
                                actionCount++;
                                actionBar.GetComponent <ActionBar>().CutAction();
                                Movement(pathway);
                            }
                            else if (canPath != true)
                            {
                                AnnouncerManager.instance.ReceiveText("You cannnot move there.", true);
                            }
                        }

                        if (isAttacking == false && Input.GetButtonDown("ShiftA") && EquipmentRenderer.instance.weaponEquip.GetComponent <Animator>().enabled == true && this.gameObject.GetComponent <CharacterData>().canAttack == true)
                        {
                            isAttacking = true;
                            Node launchNode = gridBase.GetNode(Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corX), Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corY));
                            attackableNodes   = new List <Node>();
                            attackableEnemies = new List <GameObject>();
                            for (int x = -1 * Mathf.RoundToInt(CharacterData.instance.range); x <= Mathf.RoundToInt(CharacterData.instance.range); x++)
                            {
                                for (int y = -1 * Mathf.RoundToInt(CharacterData.instance.range); y <= Mathf.RoundToInt(CharacterData.instance.range); y++)
                                {
                                    if (x == 0 && y == 0)
                                    {
                                        //Nothing
                                    }
                                    else
                                    {
                                        Node searchPos = gridBase.GetNode(launchNode.x + x, launchNode.y + y);
                                        if (searchPos != null && searchPos.worldObject.transform.childCount > 0)
                                        {
                                            attackableNodes.Add(searchPos);
                                            if (searchPos.worldObject.transform.GetChild(0).transform.gameObject.tag == "Actor")
                                            {
                                                attackableEnemies.Add(searchPos.worldObject.transform.GetChild(0).transform.gameObject);
                                            }
                                        }
                                    }
                                }
                            }

                            foreach (Node n in attackableNodes)
                            {
                                n.worldObject.GetComponent <GridHighlight>().enabled  = false;
                                n.worldObject.GetComponent <SpriteRenderer>().enabled = true;
                                n.worldObject.GetComponent <SpriteRenderer>().color   = Color.red;
                            }
                            foreach (GameObject g in attackableEnemies)
                            {
                                g.GetComponent <NPCHandler>().recepientAttack = true;
                            }
                        }
                        else if (isAttacking == true && Input.GetButtonDown("ShiftA"))
                        {
                            isAttacking = false;
                            foreach (Node n in attackableNodes)
                            {
                                n.worldObject.GetComponent <GridHighlight>().enabled  = true;
                                n.worldObject.GetComponent <SpriteRenderer>().enabled = false;
                                n.worldObject.GetComponent <SpriteRenderer>().color   = Color.white;
                            }
                            foreach (GameObject g in attackableEnemies)
                            {
                                g.GetComponent <Renderer>().material = g.GetComponent <CharacterData>().stand;
                            }
                            attackableEnemies = null;
                            attackableNodes   = null;
                        }
                    }
                }
                else if (CharacterData.instance.isDead == true)
                {
                    //Do nothing for now.
                }
            }

            if (this.GetComponent <CharacterData>().isPlayer == true && freeRoam == true && isMoving == false && isAttacking == false && ItemManager.instance.isRummaging == false && bookOpen == false && isCasting == false)
            {
                canMove = true;
                if (moveTake == true)
                {
                    moveSelect = false;
                    moveTake   = false;

                    FindSelectedTile();

                    Pathfinding.Pathfinder path = new Pathfinding.Pathfinder();

                    Node startNode = gridBase.GetNode(Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corX), Mathf.RoundToInt(this.GetComponentInParent <CoordinateHolder>().corY));
                    Node end       = targNode;

                    path.startPosition = startNode;
                    path.endPosition   = end;
                    path.pather        = this.gameObject;

                    pathway = path.FindPath();

                    if (pathway.Count > 0)
                    {
                        isRoaming = true;
                        FreeMovement(pathway);
                    }
                }
            }

            if (align)
            {
                align = false;
            }

            if (Input.GetButtonDown("Pass Round") && this.GetComponent <CharacterData>().isPlayer == true && isMoving == false && isAttacking == false && ItemManager.instance.isRummaging == false && bookOpen == false && isCasting == false)
            {
                actionCount++;
                actionBar.GetComponent <ActionBar>().CutAction();

                if (RoundController.instance.inCombat == false && actionCount >= maxActionCount)
                {
                    RoundController.instance.ArtificialRound();
                }
                if (RoundController.instance.inCombat == true && actionCount >= maxActionCount)
                {
                    actionCount  = 0;
                    hasTakenTurn = true;
                }
            }
        }