Esempio n. 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="character">The character to check for</param>
    /// <returns>true if it is within a tile spacing</returns>
    public bool IsEnemyNearby(CHARACTERS character)
    {
        Vector2Int characterTilePosition = Vector2Int.zero;
        Vector2    characterPosition     = Vector2.zero;

        // it is already targetting the player
        if (targetObject == playerObject)
        {
            return(false);
        }


        if (character == CHARACTERS.PLAYER)
        {
            characterPosition     = playerObject.transform.position;
            characterTilePosition = MapManager.Instance.GetWorldToTilePos(playerObject.transform.position);
        }

        Vector2Int currentTilePosition = MapManager.Instance.GetWorldToTilePos(transform.position);

        DIRECTIONS characterDirection = GetTargetDirection(characterPosition);

        // it is within 1 tile
        if (Vector2Int.Distance(currentTilePosition, characterTilePosition) <= 1)
        {
            // check if its through the wall
            if (CheckIfClear(characterDirection, characterPosition))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 2
0
    public override bool CheckForCharacters(CHARACTERS characterToCheck, Vector2Int tilePosition)
    {
        Vector2Int mouseTilePos;
        Vector2Int playerTilePos;

        if (characterToCheck == CHARACTERS.MOUSE)
        {
            mouseTilePos = MapManager.Instance.GetWorldToTilePos(ratObject.transform.position);
            if (mouseTilePos == tilePosition)
            {
                return(true);
            }
        }
        else if (characterToCheck == CHARACTERS.PLAYER)
        {
            playerTilePos = MapManager.Instance.GetWorldToTilePos(playerObject.transform.position);
            if (playerTilePos == tilePosition)
            {
                return(true);
            }
        }



        return(false);
    }
Esempio n. 3
0
        /// <summary>
        /// Set the position of this rotor.
        /// This may trigger a rotation (if you choose to implement it!).
        /// </summary>
        /// <param name="ch"></param>
        /// <returns>True if the notch has been passed.</returns>
        public bool SetPosition(char ch)
        {
            if (!CHARACTERS.Contains(ch))
            {
                throw new EnigmaRulesException("Invalid character to set position.");
            }

            int  i        = CHARACTERS.IndexOf(ch);
            bool rollover = false;

            while (Offset != i)
            {
                rollover = rollover || this.Increment();
            }

            return(rollover);
        }
Esempio n. 4
0
        /// <summary>
        /// Get the Encyphered character from the input pass through this rotor.
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public char In(char ch)
        {
            int i = (CHARACTERS.IndexOf(ch) + Offset) % 26;

            return(Mapping[i]);
        }
Esempio n. 5
0
        public char Reflect(char ch)
        {
            int i = CHARACTERS.IndexOf(ch);

            return(Mapping[i]);
        }
Esempio n. 6
0
    /// <summary>
    /// Checks the area infront of the character
    /// Returns the characters it finds
    /// </summary>
    /// <returns></returns>
    public virtual CHARACTERS DetectInView()
    {
        Vector2Int currentTilePos = MapManager.Instance.GetWorldToTilePos(transform.position);
        //Vector2Int playerTilePos = MapManager.Instance.GetWorldToTilePos(playerObject.transform.position);
        //Vector2Int mouseTilePos = MapManager.Instance.GetWorldToTilePos(ratObject.transform.position);

        CHARACTERS characterFound = CHARACTERS.NONE;

        // Increment it first because you shouldn't check ur own position
        // thats not a good idea lmao
        switch (viewDir)
        {
        case DIRECTIONS.UP:
            currentTilePos.y++;
            break;

        case DIRECTIONS.DOWN:
            currentTilePos.y--;
            break;

        case DIRECTIONS.LEFT:
            currentTilePos.x--;
            break;

        case DIRECTIONS.RIGHT:
            currentTilePos.x++;
            break;

        default:
            Debug.Log("It shouldn't reach here lol if it does then fuk we screwed");
            break;
        }

        // Loop through a fixed amount of times
        for (int index = 0; index < SightDistance; ++index)
        {
            // Checks the tile if any of the objects are here
            if (MapManager.Instance.IsThereTileOnMap(currentTilePos))
            {
                return(CHARACTERS.NONE);
            }

            // use a function to check
            characterFound = CheckForCharacters(currentTilePos);

            // If no character was found
            // go next
            // if not then return that character
            if (characterFound != CHARACTERS.NONE)
            {
                return(characterFound);
            }

            // move on to the next tile position
            switch (viewDir)
            {
            case DIRECTIONS.UP:
                currentTilePos.y++;
                break;

            case DIRECTIONS.DOWN:
                currentTilePos.y--;
                break;

            case DIRECTIONS.LEFT:
                currentTilePos.x--;
                break;

            case DIRECTIONS.RIGHT:
                currentTilePos.x++;
                break;

            default:
                Debug.Log("It shouldn't reach here lol if it does then fuk we screwed");
                break;
            }
        }

        // It didnt find anything here
        return(CHARACTERS.NONE);
    }
Esempio n. 7
0
    public virtual bool DetectInView(CHARACTERS characterToCheck)
    {
        Vector2Int currentTilePos = MapManager.Instance.GetWorldToTilePos(transform.position);
        bool       characterFound = false;

        // Increment it first because you shouldn't check ur own position
        // thats not a good idea lmao
        switch (viewDir)
        {
        case DIRECTIONS.UP:
            currentTilePos.y++;
            break;

        case DIRECTIONS.DOWN:
            currentTilePos.y--;
            break;

        case DIRECTIONS.LEFT:
            currentTilePos.x--;
            break;

        case DIRECTIONS.RIGHT:
            currentTilePos.x++;
            break;

        default:
            Debug.Log("It shouldn't reach here lol if it does then fuk we screwed");
            break;
        }

        for (int index = 0; index < SightDistance; ++index)
        {
            // Checks the tile if any of the objects are here
            if (MapManager.Instance.IsThereTileOnMap(currentTilePos))
            {
                return(false);
            }

            // use a function to check
            characterFound = CheckForCharacters(characterToCheck, currentTilePos);

            // If no character was found
            // go next
            // if not then return that character
            //if (characterFound != CHARACTERS.NONE)
            //    return characterFound;
            if (characterFound == true)
            {
                return(true);
            }

            // move on to the next tile position
            switch (viewDir)
            {
            case DIRECTIONS.UP:
                currentTilePos.y++;
                break;

            case DIRECTIONS.DOWN:
                currentTilePos.y--;
                break;

            case DIRECTIONS.LEFT:
                currentTilePos.x--;
                break;

            case DIRECTIONS.RIGHT:
                currentTilePos.x++;
                break;

            default:
                Debug.Log("It shouldn't reach here lol if it does then fuk we screwed");
                break;
            }
        }


        return(false);
    }
Esempio n. 8
0
 public virtual bool CheckForCharacters(CHARACTERS characterToCheck, Vector2Int tilePosition)
 {
     return(false);
 }