Beispiel #1
0
    public List <Node> GetFullStackConnectionsFromDir(Direction dir)
    {
        List <Node> ns = new List <Node>();

        ConnectionSet[] conns = connectionStack.ToArray();
        foreach (ConnectionSet set in conns)
        {
            if (set[dir] != null)
            {
                Node n = GameManager.instance.map[(int)set[dir]];
                if (ns.Contains(n) == false)
                {
                    ns.Add(n);
                }
            }
        }
        return(ns);
    }
Beispiel #2
0
    void RunCheck(GameManager.Direction aDirection)
    {
        // log the direction
        m_CurrentDirection = aDirection;

        // make sure the ai doesn't hit walls or falls off the map
        if ((UseSensor(aDirection) & (GameManager.SensorData.Wall | GameManager.SensorData.OffGrid)) != 0)
        {
            // TODO: maybe store these to build an actual x,y grid idk yet
            return;
        }

        // check to see if the space we are checking is clear
        if ((UseSensor(aDirection) & GameManager.SensorData.Clear) != 0)
        {
            Node node = new Node();

            // check for bombs
            if ((UseSensor(aDirection) & GameManager.SensorData.Bomb) != 0)
            {
                node.transform.data.isBomb = true;
                node.transform.data.turnsSinceEnemyBomb++;
            }
            // check for enemy ai
            if ((UseSensor(aDirection) & GameManager.SensorData.Enemy) != 0)
            {
                node.transform.data.isEnemy = true;
            }
            // check for a beautiful diamond
            if ((UseSensor(aDirection) & GameManager.SensorData.Diamond) != 0)
            {
                node.transform.data.isDiamond = true;
            }
            // check for goal
            if ((UseSensor(aDirection) & GameManager.SensorData.Goal) != 0)
            {
                node.transform.data.isGoal = true;
            }

            node.transform.data.foundFrom = m_CurrentDirection;
            m_Map.AddNode(node);
            m_NumOfSquaresScanned++;
        }
    }
Beispiel #3
0
    /// <summary>
    /// return true if the node and the one it is connected to in that direction have mis-matching string, that would indicate that a one-way connection would cut the string if traveled over.
    /// </summary>
    /// <param name="node"></param>
    /// <param name="dir"></param>
    /// <returns></returns>
    public bool disjoint(Node node, GameManager.Direction dir)
    {
        Node other = this[node[(int)dir]];

        GameManager.Direction opposite = dir.inverse();
        if (            // if one node has an enter/exit for the string on the connection, and the other does not have the corresponding exit/enter
            ((node.hasEnter && (node.enter == dir)) && ((other.leave != opposite) || !other.hasLeave)) ||
            ((node.hasLeave && (node.leave == dir)) && ((other.enter != opposite) || !other.hasEnter)) ||
            ((other.hasEnter && (other.enter == opposite)) && ((node.leave != dir) || !node.hasLeave)) ||
            ((other.hasLeave && (other.leave == opposite)) && ((node.enter != dir) || !node.hasEnter))
            )
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
 /// <summary>
 /// Set the visiblity of this corner mask. True = visible, false = not visible.
 /// For corner masks on the diagonal, has two parts of the mask, one for each half
 /// of the mask that might be needed if the tiles shown on each side do not have
 /// the same lack/presence of a corner.
 /// </summary>
 /// <param name="set"></param>
 /// <param name="dir"></param>
 public void setCornerFromDir(bool set, Direction dir)
 {
     if ((dir == Direction.North) || (dir == Direction.South))               // if accessed from vertical direction, set vertical part of mask
     {
         foreach (SpriteMask mask in maskVertical)
         {
             if (mask != null)
             {
                 mask.gameObject.SetActive(!set);
             }
         }
         vertActive = !set;
     }
     else                // if accessed from horizontal direction, set horizontal part of mask
     {
         foreach (SpriteMask mask in maskHorizontal)
         {
             if (mask != null)
             {
                 mask.gameObject.SetActive(!set);
             }
         }
         horiActive = !set;
     }
     // The "line of sight" mask needs to be set visible if either the verical/horizontal corner is set visible, or visa-versa
     // If the sets of masks for horizontal/vertical was deleted because it was not needed, it does not need to be considered.
     if (((maskVertical.Length == 0) || vertActive) && ((maskHorizontal.Length == 0) || horiActive))
     {
         if (maskLineOfSight != null)
         {
             maskLineOfSight.gameObject.SetActive(false);
         }
     }
     else
     {
         if (maskLineOfSight != null)
         {
             maskLineOfSight.gameObject.SetActive(true);
         }
     }
 }
Beispiel #5
0
    public void SetLineFromDir(Direction dir, bool b)
    {
        switch (dir)
        {
        case Direction.North:
            northLine.gameObject.SetActive(b);
            break;

        case Direction.South:
            southLine.gameObject.SetActive(b);
            break;

        case Direction.East:
            eastLine.gameObject.SetActive(b);
            break;

        case Direction.West:
            westLine.gameObject.SetActive(b);
            break;
        }
    }
Beispiel #6
0
    // Use this for initialization
    public void initialize()
    {
        center = new Vector2Int(renderMap.dim / 2, renderMap.dim / 2);

        // drawPathInstructions does need to be hardcoded, but this algorithm makes it so only 1/4 of it needs to be written, since it is the same pattern in each of the 4 directions
        if (drawPathInstructions.Length < 4)
        {
            drawPathInstructions = new DrawPathInstruction[4];
            for (int i = 0; i < 4; i++)
            {
                Direction dir   = (Direction)i;
                Direction left  = dir.counterclockwise();
                Direction right = dir.clockwise();
                drawPathInstructions[i] = new DrawPathInstruction(dir, new DrawPathInstruction[] {
                    new DrawPathInstruction(dir, new DrawPathInstruction[] { new DrawPathInstruction(left, new DrawPathInstruction[] { }), new DrawPathInstruction(right, new DrawPathInstruction[] { }) }),
                    new DrawPathInstruction(left, new DrawPathInstruction[] { new DrawPathInstruction(dir, new DrawPathInstruction[] { new DrawPathInstruction(left, new DrawPathInstruction[] { }) }) }),
                    new DrawPathInstruction(right, new DrawPathInstruction[] { new DrawPathInstruction(dir, new DrawPathInstruction[] { new DrawPathInstruction(right, new DrawPathInstruction[] { }) }) }),
                });
            }
        }
    }
    private bool checkDir(GameManager.Direction dir)
    {
        Vector3    temp = genTemp(dir);
        RaycastHit hit;

        if (Physics.Raycast(transform.position, temp, out hit, CHECK_DIST))
        {
            if (hit.collider.tag == "Level")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
Beispiel #8
0
        //public int? this[Direction dir] {
        public int this[Direction dir] {
            get {
                switch (dir)
                {
                case Direction.North:
                    return(north);

                case Direction.South:
                    return(south);

                case Direction.West:
                    return(west);

                case Direction.East:
                    return(east);
                }
                return(east);
            }
            set {
                switch (dir)
                {
                case Direction.North:
                    north = value;
                    break;

                case Direction.South:
                    south = value;
                    break;

                case Direction.West:
                    west = value;
                    break;

                case Direction.East:
                    east = value;
                    break;
                }
            }
        }
Beispiel #9
0
    public static bool CheckForBomb(AIBaseEnt m_AI, Direction m_Direction)
    {
        m_AI.DebugMsg("Checking movement in " + m_Direction + " direction...");

        bool isBomb = false;
        Dictionary <Direction, TileInfo> moveData = SearchImmediate(m_AI);

        if (moveData.ContainsKey(m_Direction) && (moveData[m_Direction].GetTileData() & SensorData.Bomb) != 0)
        {
            isBomb = true;
        }
        else
        {
            isBomb = false;
        }

        if (isBomb)
        {
            m_AI.DebugMsg("MovementScript.CheckMovement() " + m_Direction + " is not safe; SensorData = " + moveData[m_Direction].GetTileData());
        }

        return(isBomb);
    }
Beispiel #10
0
    private Vector3 genTemp(GameManager.Direction dir)
    {
        Vector3 temp = transform.position;

        if (dir == GameManager.Direction.North)
        {
            temp.z = temp.z + LEVEL_SIZE;
        }
        else if (dir == GameManager.Direction.South)
        {
            temp.z = temp.z - LEVEL_SIZE;
        }
        else if (dir == GameManager.Direction.East)
        {
            temp.x = temp.x + LEVEL_SIZE;
        }
        else if (dir == GameManager.Direction.West)
        {
            temp.x = temp.x - LEVEL_SIZE;
        }

        return(temp);
    }
Beispiel #11
0
    public void Rotate(GameManager.Direction direction)
    {
        switch (direction)
        {
        case GameManager.Direction.North:
            this.gameObject.transform.eulerAngles = new Vector3(0, 0, 0);
            break;

        case GameManager.Direction.South:
            this.gameObject.transform.eulerAngles = new Vector3(0, 180, 0);
            break;

        case GameManager.Direction.East:
            this.gameObject.transform.eulerAngles = new Vector3(0, 90, 0);
            break;

        case GameManager.Direction.West:
            this.gameObject.transform.eulerAngles = new Vector3(0, 270, 0);
            break;

        default:
            break;
        }
    }
Beispiel #12
0
    public void Move(GameManager.Direction direction)
    {
        switch (direction)
        {
        case GameManager.Direction.North:
            this.gameObject.transform.position += new Vector3(unitDistance, 0, 0);
            break;

        case GameManager.Direction.South:
            this.gameObject.transform.position += new Vector3(-unitDistance, 0, 0);
            break;

        case GameManager.Direction.East:
            this.gameObject.transform.position += new Vector3(0, 0, -unitDistance);
            break;

        case GameManager.Direction.West:
            this.gameObject.transform.position += new Vector3(0, 0, unitDistance);
            break;

        default:
            break;
        }
    }
Beispiel #13
0
    //USE THIS TO GET A MOVE DIReCTION TO ADD TO aMOVES!!! IT UPDATES OUR CURRENT POSITION WHICH WE NEED FOR THE GRAPH
    GameManager.Direction Move(GameManager.Direction direction)
    {
        //Change the current position based on the direction we're moving
        switch (direction)
        {
        case GameManager.Direction.Up:
            currentPosition += Vector2.up;
            break;

        case GameManager.Direction.Left:
            currentPosition += Vector2.left;
            break;

        case GameManager.Direction.Down:
            currentPosition += Vector2.up;
            break;

        case GameManager.Direction.Right:
            currentPosition += Vector2.right;
            break;
        }

        return(direction);
    }
Beispiel #14
0
 private void checkDirectionPossible(ArrayList posDir, Vector3 leftOffset, Vector3 rightOffset, Vector3 temp, GameManager.Direction currentDir, GameManager.Direction oppositeDir)
 {
     Debug.DrawRay(leftOffset, temp * 1.0f, Color.white);
     if (genHit(leftOffset, temp, levelLayer) && (myDirection != currentDir && myDirection != oppositeDir))
     {
         Debug.DrawRay(rightOffset, temp * 1.0f, Color.white);
         if (genHit(rightOffset, temp, levelLayer) && (myDirection != currentDir && myDirection != oppositeDir))
         {
             posDir.Add(currentDir);
         }
     }
 }
Beispiel #15
0
    private void checkIntersection()
    {
        ArrayList posDir = new ArrayList();

        GameManager.Direction tempDir = myDirection;
        GameManager.Direction revTempDir;

        Vector3 temp;
        Vector3 leftOffset;
        Vector3 rightOffset;

        float OFFSET_VALUE = 0.95f;

        if (tempDir == GameManager.Direction.North)
        {
            revTempDir = GameManager.Direction.South;
        }
        else if (tempDir == GameManager.Direction.South)
        {
            revTempDir = GameManager.Direction.North;
        }
        else if (tempDir == GameManager.Direction.East)
        {
            revTempDir = GameManager.Direction.West;
        }
        else if (tempDir == GameManager.Direction.West)
        {
            revTempDir = GameManager.Direction.East;
        }
        else
        {
            revTempDir = GameManager.Direction.North;
        }

        for (int i = 0; i < 4; i++)
        {
            temp        = transform.position;
            leftOffset  = transform.position;
            rightOffset = transform.position;

            if (i == 0)
            {
                temp.z         = temp.z + LEVEL_SIZE;
                leftOffset.x  -= OFFSET_VALUE;
                rightOffset.x += OFFSET_VALUE;

                checkDirectionPossible(posDir, leftOffset, rightOffset, temp, GameManager.Direction.North, GameManager.Direction.South);
            }
            else if (i == 1)
            {
                temp.z         = temp.z - LEVEL_SIZE;
                leftOffset.x  += OFFSET_VALUE;
                rightOffset.x -= OFFSET_VALUE;

                checkDirectionPossible(posDir, leftOffset, rightOffset, temp, GameManager.Direction.South, GameManager.Direction.North);
            }
            else if (i == 2)
            {
                temp.x         = temp.x + LEVEL_SIZE;
                leftOffset.z  -= OFFSET_VALUE;
                rightOffset.z += OFFSET_VALUE;

                checkDirectionPossible(posDir, leftOffset, rightOffset, temp, GameManager.Direction.East, GameManager.Direction.West);
            }
            else if (i == 3)
            {
                temp.x         = temp.x - LEVEL_SIZE;
                leftOffset.z  += OFFSET_VALUE;
                rightOffset.z -= OFFSET_VALUE;

                checkDirectionPossible(posDir, leftOffset, rightOffset, temp, GameManager.Direction.West, GameManager.Direction.East);
            }
        }

        int newDirection = Random.Range(0, posDir.Count);

        if (posDir.Count > 0)
        {
            if (checkDir(tempDir))
            {
                setNewDir(posDir, newDirection);
            }
            else
            {
                int directionChangeChance = Random.Range(1, 11);

                if (directionChangeChance == 1)
                {
                    if (!(checkDir(revTempDir)))
                    {
                        myDirection = revTempDir;
                        intersected = true;
                    }
                }
                else if (directionChangeChance >= 2 && directionChangeChance <= 5)
                {
                    if (!(checkDir(tempDir)))
                    {
                        intersected = true;
                    }
                    else
                    {
                        setNewDir(posDir, newDirection);
                    }
                }
                else
                {
                    setNewDir(posDir, newDirection);
                }
            }
        }
        else
        {
            intersected = false;
        }
    }
Beispiel #16
0
    void FixedUpdate()
    {
        pacManListener(transform.position);

        if (superMode)
        {
            if (Input.GetButton("Fire1"))
            {
                Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
                Vector3   fwd      = transform.TransformDirection(Vector3.back);
                instance.AddForce(fwd * power);

                Destroy(instance.gameObject, DESTROY_BULLET_TIME);
            }

            if (followCam.InPosition)
            {
                float tiltAroundY = followCam.TiltAroundY;
                float moveForward = Input.GetAxis("Vertical");

                if (myDirection == GameManager.Direction.North)
                {
                    if (tiltAroundY < 280 && tiltAroundY > 260)
                    {
                        myDirection = GameManager.Direction.West;
                    }
                    else if (tiltAroundY > 80 && tiltAroundY < 170)
                    {
                        myDirection = GameManager.Direction.East;
                    }
                    moveNorth(moveForward);
                }
                else if (myDirection == GameManager.Direction.East)
                {
                    if (tiltAroundY > 170)
                    {
                        myDirection = GameManager.Direction.South;
                    }
                    else if (tiltAroundY < 10)
                    {
                        myDirection = GameManager.Direction.North;
                    }
                    moveEast(moveForward);
                }
                else if (myDirection == GameManager.Direction.South)
                {
                    if (tiltAroundY > 260)
                    {
                        myDirection = GameManager.Direction.West;
                    }
                    else if (tiltAroundY < 100)
                    {
                        myDirection = GameManager.Direction.East;
                    }
                    moveSouth(moveForward);
                }
                else if (myDirection == GameManager.Direction.West)
                {
                    if (tiltAroundY > 350)
                    {
                        myDirection = GameManager.Direction.North;
                    }
                    else if (tiltAroundY < 190)
                    {
                        myDirection = GameManager.Direction.South;
                    }
                    moveWest(moveForward);
                }
            }
        }
        else
        {
            if (Input.GetAxis("Right") > 0)
            {
                myDirection = GameManager.Direction.East;
                moveEast(Input.GetAxis("Right"));
            }
            else if (Input.GetAxis("Left") > 0)
            {
                myDirection = GameManager.Direction.West;
                moveWest(Input.GetAxis("Left"));
            }
            else if (Input.GetAxis("Up") > 0)
            {
                myDirection = GameManager.Direction.North;
                moveNorth(Input.GetAxis("Up"));
            }
            else if (Input.GetAxis("Down") > 0)
            {
                myDirection = GameManager.Direction.South;
                moveSouth(Input.GetAxis("Down"));
            }
        }

        if (curPos.x >= level.renderer.bounds.max.x)
        {
            curPos.x = level.renderer.bounds.min.x;
        }
        else if (curPos.x <= level.renderer.bounds.min.x)
        {
            curPos.x = level.renderer.bounds.max.x;
        }

        transform.position = curPos;
        setRotation();
    }
Beispiel #17
0
    public override void _Update()
    {
        //Player interaction objects
        //if (InputManager.instance.OnInputDown(InputManager.Action.action)) {
        if (Input.GetButtonDown("Action"))
        {
            //if (currentPosition.hasSign/* && curdir == 0*/) {
            if (currentPosition.type == Node.TileType.sign /* && curdir == 0*/)
            {
                //Player reads a sign
                ///////// make sign visible/not visible
                signText.text = currentPosition.signMessage;
                signImage.gameObject.SetActive(!signImage.gameObject.activeInHierarchy);
                //Debug.Log(currentPosition.signMessage);
            }
            else
            {
                if (hasBall)
                {
                    //Player drops the ball
                    hasBall = false;
                    //} else if ((currentPosition.data.hasEnter && !currentPosition.data.hasLeave) || stringLeft == map.stringleft && currentPosition.type == Node.TileType.source) {
                }
                else if (
                    (currentPosition.hasEnter && !currentPosition.hasLeave) ||
                    stringLeft >= map.stringleft && currentPosition.type == Node.TileType.source)
                {
                    //Player pick up the ball
                    hasBall = true;
                }
            }
        }

        //Shows pause menu
        //if (InputManager.instance.OnInputDown(InputManager.Action.back)) {
        if (Input.GetButtonDown("Back"))
        {
            GameManager.changeState(pauseMenu, this);
        }

        //Dont do anything past here if we are doing an animation
        if (animLockout)
        {
            return;
        }
        else if (winTrigger)
        {
            youWinScreenTimeout -= Time.deltaTime;
            if (youWinScreenTimeout < 0.0f)
            {
                winTrigger = false;
                // load the next level if it exists, else return to level selector
                if (GameManager.saveGame.levelNumber >= 0 && GameManager.saveGame.levelNumber < levelSelector.levelButtons.Length)
                {
                    LevelSelector.changeLevelHelper(GameManager.saveGame.levelNumber);
                }
                else
                {
                    GameManager.changeState(levelSelector, this);
                }
            }
            return;
        }
        //This for loop deals with inputs and moves the player around.

        //for (int i = 0; i < 4; i++) {
        //Direction lines up with input manager so we can directly convert to an action from a direction.
        //GameManager.Direction dir = (GameManager.Direction)i;
        bool directionInput = false;

        GameManager.Direction dir = GameManager.Direction.North;
        float ver = Input.GetAxisRaw("Vertical");
        float hor = Input.GetAxisRaw("Horizontal");

        if (!Mathf.Approximately(ver, 0.0f) && ver > 0)                 // if multiple axis are active, choose only one, with priority N > E > S > W
        {
            directionInput = true;
        }
        else if (!Mathf.Approximately(hor, 0.0f) && hor > 0)
        {
            dir            = GameManager.Direction.East;
            directionInput = true;
        }
        else if (!Mathf.Approximately(ver, 0.0f) && ver < 0)
        {
            dir            = GameManager.Direction.South;
            directionInput = true;
        }
        else if (!Mathf.Approximately(hor, 0.0f) && hor < 0)
        {
            dir            = GameManager.Direction.West;
            directionInput = true;
        }

        //if (InputManager.instance.OnInput((InputManager.Action)i)) {
        if (directionInput)             // only go into if a direction input occured
        {
            bool canMove   = false;
            Node otherNode = null;
            if (signImage.gameObject.activeInHierarchy)
            {
                signImage.gameObject.SetActive(false);
            }
            //curdir = i;
            //curdir = (int)dir;
            if (hasBall && (currentPosition.hasLeave || (currentPosition.type != Node.TileType.source && !currentPosition.hasLeave && !currentPosition.hasEnter)))
            {
                hasBall = false;
            }
            if (currentPosition[(int)dir] >= 0)
            {
                otherNode = map[currentPosition[(int)dir]];
                //See if the other node has a leave
                canMove = (
                    (
                        (!otherNode.hasLeave && !otherNode.hasEnter && stringLeft > 0) || ( // can't carry string onto tiles if it already has string on it
                            otherNode.hasLeave && otherNode.leave.inverse() == dir &&       // unless you are rolling up the string
                            currentPosition.hasEnter && currentPosition.enter == dir) ||
                        !hasBall) &&                                                        // this stuff about string doesn't matter if you are not carrying string
                    !map.disjoint(currentPosition, dir) &&                                  // can't walk through one-ways if it would sever the string
                    (otherNode.type != Node.TileType.unwalkable || pitWalk)                 // can't walk over pits, unless leveleditor "walk over pits" setting is set
                    );
            }
            if (cinimaticMode && Input.GetKey(KeyCode.Space))
            {
                canMove = false;
            }
            animLockout = true;
            StartCoroutine(CharacterAnimator.instance.AnimateMovement(
                               (bool flag) => { onArrive(canMove, otherNode, dir); },
                               dir, moveAnimSpeed, canMove
                               ));

            //break;
        }
        //}
    }
Beispiel #18
0
    public void onArrive(bool canMove, Node otherNode, GameManager.Direction dir)
    {
        if (!canMove)
        {
            animLockout = false;
            return;
        }
        //Handle fake connection stacking
        {
            //If the connection from this node to the other is one-way
            if (otherNode[(int)dir.inverse()] != currentPosition.index)
            {
                // temp override connection to that node
                otherNode[(int)dir.inverse()] = currentPosition.index;
            }
        }

        if (hasBall)
        {
            //Tag the current square with line exit dir
            if (!otherNode.hasLeave)
            {
                currentPosition.leave    = dir;
                currentPosition.hasLeave = true;
                otherNode.enter          = dir.inverse();
                otherNode.hasEnter       = true;
                stringLeft--;
            }
            else
            {
                //Do a backup
                currentPosition.hasEnter = false;
                otherNode.hasLeave       = false;
                stringLeft++;
            }
        }

        currentPosition = otherNode;

#if UNITY_EDITOR    // if this is in the editor, call getCurrentNode() every time movement happens,
        // and apply copied colors and sprites to the new tile is currently drawing.
        if (editLevel != null)
        {
            editLevel.getCurrentNode();
            editLevel.drawTiles();              // only changes stuff if currently drawing
            //Debug.Log("calling getCurrentNode()...")
        }
        else
        {
            Debug.Log("Cannot call getCurrentNode(), there is no reference to editLevel script/object");
        }
#endif
        nonEuclidRenderer.HandleRender(dir, currentPosition);
        animLockout = false;
        setUItext();            // apply changes to UI text: string left, checkpoints.

        if (map.winConditions())
        {
            winTrigger = true;
            wintext.SetActive(true);                                              // make win text visible
            winSound.SetActive(true);                                             // play sound
            // play win sound here
            levelSelector.unlockLevel();                                          // unlocks next level
            GameManager.saveGame.levelNumber++;                                   // advance last level visited, so will auto-load next level
            SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame); // save changes to levels accessible and last-level-visited
            //Debug.Log("You win!");
        }
        //if (currentPosition.hasSign && !signsVisited.Contains(currentPosition.index)) {
        if (currentPosition.type == Node.TileType.sign && !signsVisited.Contains(currentPosition.index))
        {
            signsVisited.Add(currentPosition.index);
            signText.text = currentPosition.signMessage;
            signImage.gameObject.SetActive(true);
        }
    }
Beispiel #19
0
 public void SetWallFromDir(Direction dir, bool b)
 {
     walls[(int)dir].gameObject.SetActive(b);
 }
Beispiel #20
0
    void QueueAction(ref List <GameManager.Direction> aMoves, ref int aBombTime)
    {
        // grab the last nodes we checked out
        List <Node>           nodes        = new List <Node>();
        LinkedListNode <Node> currentLNode = m_Map.nodes.Last;
        int count = m_NumOfSquaresScanned;

        while (count > 1)
        {
            nodes.Add(currentLNode.Value);
            currentLNode = currentLNode.Previous;
            count--;
        }

        // are any of these nodes the diamond?
        foreach (Node node in nodes)
        {
            if (node.transform.data.isDiamond)
            {
                aMoves.Add(node.transform.data.foundFrom);
                m_CurrentDirection = node.transform.data.foundFrom;
                m_IsMoving         = true;
                m_IsHoldingDiamond = true; // log that we grabbed the diamond
                return;
            }

            if (node.transform.data.isGoal && m_IsHoldingDiamond)
            {
                aMoves.Add(node.transform.data.foundFrom);
                m_CurrentDirection = node.transform.data.foundFrom;
                m_IsMoving         = true;
                m_IsGoingToGoal    = true; // log that we grabbed the diamond
                return;
            }
        }

        foreach (Node node in nodes)
        {
            // if there is an enemy or a bomb move away if it is safe to
            if (node.transform.data.isEnemy || node.transform.data.isBomb)
            {
                // tell the ai we are moving
                m_IsMoving = true;

                // dodge stuff
                switch (RandomMove())
                {
                case GameManager.Direction.Up:
                    if ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Clear) != 0 &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Enemy) == 0) &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Bomb) == 0))
                    {
                        aMoves.Add(GameManager.Direction.Down);
                        m_CurrentDirection = GameManager.Direction.Down;
                        return;
                    }
                    break;

                case GameManager.Direction.Down:
                    if ((UseSensor(GameManager.Direction.Up) & GameManager.SensorData.Clear) != 0 &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Enemy) == 0) &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Bomb) == 0))
                    {
                        aMoves.Add(GameManager.Direction.Up);
                        m_CurrentDirection = GameManager.Direction.Up;
                        return;
                    }
                    break;

                case GameManager.Direction.Left:
                    if ((UseSensor(GameManager.Direction.Right) & GameManager.SensorData.Clear) != 0 &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Enemy) == 0) &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Bomb) == 0))
                    {
                        aMoves.Add(GameManager.Direction.Right);
                        m_CurrentDirection = GameManager.Direction.Right;
                        return;
                    }
                    break;

                case GameManager.Direction.Right:
                    if ((UseSensor(GameManager.Direction.Left) & GameManager.SensorData.Clear) != 0 &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Enemy) == 0) &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Bomb) == 0))
                    {
                        aMoves.Add(GameManager.Direction.Left);
                        m_CurrentDirection = GameManager.Direction.Left;
                        return;
                    }
                    break;

                case GameManager.Direction.Current:
                    if ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Clear) != 0 &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Enemy) == 0) &&
                        ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Bomb) == 0))
                    {
                        aMoves.Add(GameManager.Direction.Down);
                        m_CurrentDirection = GameManager.Direction.Down;
                        return;
                    }
                    break;
                }
            }
        }

        // if there wasn't any enemy ai or bombs near us continue on our wonderfully straight path
        if ((UseSensor(m_LastDirection) & GameManager.SensorData.Clear) != 0)
        {
            aMoves.Add(m_LastDirection);
        }
        else
        {
            aMoves.Add(RandomMove());
        }

        // tell the ai to move this turn
        m_IsMoving = true;
    }
Beispiel #21
0
    public override CombatantAction GetAction(ref List <GameManager.Direction> aMoves, ref int aBombTime)
    {
        test++;
        m_NumOfSquaresScanned = 0;
        m_LastDirection       = m_CurrentDirection;
        RunCheck(GameManager.Direction.Current);
        RunCheck(GameManager.Direction.Down);
        RunCheck(GameManager.Direction.Left);
        RunCheck(GameManager.Direction.Right);
        RunCheck(GameManager.Direction.Up);

        // get the first node we found this turn
        LinkedListNode <Node> currentLNode = m_Map.nodes.Last;
        int count = m_NumOfSquaresScanned;

        while (count > 1)
        {
            // two way connections
            //if (currentLNode.Previous.Value != null)
            //    currentLNode.Value.transform.data.connectedNodes.Add(currentLNode.Previous.Value);

            currentLNode = currentLNode.Previous;

            //if (currentLNode.Next.Value != null)
            //    currentLNode.Value.transform.data.connectedNodes.Add(currentLNode.Next.Value);

            count--;
        }

        Node currentNode = currentLNode.Value;

        // add nodes to the list of connected nodes
        currentLNode = currentLNode.Next;
        while (currentLNode != null)
        {
            currentNode.transform.data.connectedNodes.Add(currentLNode.Value);
            currentLNode = currentLNode.Next;
        }

        QueueAction(ref aMoves, ref aBombTime);

        // if we have the diamond
        if (m_IsHoldingDiamond)
        {
            // go through our list of nodes and see if the goal is in there
            LinkedListNode <Node> node = m_Map.nodes.First;
            while (node != null)
            {
                // if it is
                if (node.Value.transform.data.isGoal)
                {
                    // go to it
                    //MoveToPriorPosition(ref aMoves);
                    m_IsMoving      = true;
                    m_IsGoingToGoal = true;
                    break;
                }
                node = node.Next;
            }
        }

        // do turn
        if (m_IsMoving)
        {
            Resets();

            //if (!m_IsGoingToGoal)
            //{
            //    m_PriorMoves.Add(m_LastDirection);
            //}
            //else
            //{
            //    m_IsGoingToGoal = false;
            //}

            //if (test > 14)
            //{
            //    m_IsGoingToGoal = true;
            //    aMoves = new List<GameManager.Direction>();
            //    MoveToPriorPosition(ref aMoves);
            //    QueueAction(ref aMoves, ref aBombTime);
            //    test = 0;
            //}
            //else
            //{
            //    if ((UseSensor(m_CurrentDirection) & GameManager.SensorData.Clear) != 0)
            //        m_PriorMoves.Add(m_CurrentDirection);
            //}


            return(CombatantAction.Move);
        }
        else if (m_IsBombing)
        {
            Resets();
            return(CombatantAction.DropBomb);
        }
        else
        {
            Resets();
            return(CombatantAction.Pass);
        }
    }
Beispiel #22
0
 public DoorEventArgs(GameManager.Direction dir)
 {
     direction = dir;
 }
Beispiel #23
0
        public override CombatantAction GetAction(ref List <Direction> aMoves, ref int aBombTime)
        {
            // Check all directions
            m_RightTile   = UseSensor(Direction.Right);
            m_LeftTile    = UseSensor(Direction.Left);
            m_UpTile      = UseSensor(Direction.Up);
            m_DownTile    = UseSensor(Direction.Down);
            m_CurrentTile = UseSensor(Direction.Current);

            // Update the surrounding tiles
            UpdateSurroundingTiles();

            aBombTime = Random.Range(m_BombTime.min, m_BombTime.max + 1);

            // Managing Movement

            // For each node, check to make sure that the node was not yet visited and is not dangerous, or
            // check if the diamond is there
            // If so, then try to move to that position
            if (m_CurrentNode.left.visited == false && m_CurrentNode.left.tile.Contains(m_DangerousAreas) == false ||
                m_CurrentNode.left.tile.Contains(SensorData.Diamond))
            {
                // If an enemy is there, drop a bomb
                if (m_CurrentNode.left.tile.Contains(SensorData.Enemy))
                {
                    return(CombatantAction.DropBomb);
                }
                aMoves.Add(Direction.Left);
            }
            // Same logic as the first part, but for different nodes
            else if (m_CurrentNode.right.visited == false && m_CurrentNode.right.tile.Contains(m_DangerousAreas) == false ||
                     m_CurrentNode.right.tile.Contains(SensorData.Diamond))
            {
                if (m_CurrentNode.right.tile.Contains(SensorData.Enemy))
                {
                    return(CombatantAction.DropBomb);
                }
                aMoves.Add(Direction.Right);
            }
            else if (m_CurrentNode.up.visited == false && m_CurrentNode.up.tile.Contains(m_DangerousAreas) == false ||
                     m_CurrentNode.up.tile.Contains(SensorData.Diamond))
            {
                if (m_CurrentNode.up.tile.Contains(SensorData.Enemy))
                {
                    return(CombatantAction.DropBomb);
                }
                aMoves.Add(Direction.Up);
            }
            else if (m_CurrentNode.down.visited == false && m_CurrentNode.down.tile.Contains(m_DangerousAreas) == false ||
                     m_CurrentNode.down.tile.Contains(SensorData.Diamond))
            {
                if (m_CurrentNode.down.tile.Contains(SensorData.Enemy))
                {
                    return(CombatantAction.DropBomb);
                }
                aMoves.Add(Direction.Down);
            }
            else
            {
                // Go into a random direction if all tiles are already visited
                // keep re-rolling until we get a proper direction, or until we've tried 10 more times
                Direction  dir        = (Direction)Random.Range(0, 4);
                SensorData targetTile = UseSensor(dir);
                for (int i = 0; i < 10; i++)
                {
                    if (targetTile.Contains(m_DangerousAreas))
                    {
                        dir        = (Direction)Random.Range(0, 4);
                        targetTile = UseSensor(dir);
                    }
                    else
                    {
                        break;
                    }
                }
                // just pass if for some reason, our AI wants to walk into a wall
                if (targetTile.Contains(SensorData.OffGrid, SensorData.Wall))
                {
                    return(CombatantAction.Pass);
                }
                else if (targetTile.Contains(SensorData.Enemy))
                {
                    return(CombatantAction.DropBomb);
                }

                // Just move to the position
                aMoves.Add(dir);
            }

            // This will update the coordinates and return a movement action
            CombatantAction action = MoveAndUpdateCoords(ref aMoves);

            Debug.LogFormat("[{0}][{1}]", m_Horizontal, m_Vertical);
            return(action);
        }
Beispiel #24
0
 /// <summary>
 /// �]�w�B�B���ݩ�
 /// </summary>
 /// <param name="speed">�B�B���ʳt��</param>
 /// <param name="direction">�B�B���ʪ���V</param>
 public void SetIceAttributes(float speed, GameManager.Direction direction)
 {
     this.iceSpeed = speed;
     this.iceMoveDirection = direction;
 }
Beispiel #25
0
 /// <summary>
 /// Updates information in the direction of an adjacent tile
 /// </summary>
 /// <param name="m_Direction">Direction of the tile to update (Up, Down, Left, Right)</param>
 /// <param name="m_AdjacentTileData">SensorData of the adjacent tile</param>
 public void UpdateAdjacentTileData(Direction m_Direction, SensorData m_AdjacentTileData)
 {
     adjacentTiles[m_Direction].SetTileData(m_AdjacentTileData);
 }
Beispiel #26
0
 public DrawPathInstruction(Direction dir, DrawPathInstruction[] nextInstructions)
 {
     this.dir = dir;
     //this.renderLayer = renderLayer;
     this.nextInstructions = nextInstructions;
 }
Beispiel #27
0
 public TileInfo GetAdjacentTileInfo(Direction m_TileDirection)
 {
     return(adjacentTiles[m_TileDirection]);
 }
Beispiel #28
0
    GameManager.Direction RandomMove()
    {
        m_CurrentDirection = (GameManager.Direction)UnityEngine.Random.Range(0, 4);
        if (m_CurrentDirection == m_LastDirection)
        {
            RandomMove();
        }
        // make sure it isn't a wall
        switch (m_CurrentDirection)
        {
        case GameManager.Direction.Up:
            if ((UseSensor(GameManager.Direction.Up) & GameManager.SensorData.Clear) != 0)
            {
                return(m_CurrentDirection);
            }
            else
            {
                RandomMove();
            }
            break;

        case GameManager.Direction.Down:
            if ((UseSensor(GameManager.Direction.Down) & GameManager.SensorData.Clear) != 0)
            {
                return(m_CurrentDirection);
            }
            else
            {
                RandomMove();
            }
            break;

        case GameManager.Direction.Left:
            if ((UseSensor(GameManager.Direction.Left) & GameManager.SensorData.Clear) != 0)
            {
                return(m_CurrentDirection);
            }
            else
            {
                RandomMove();
            }
            break;

        case GameManager.Direction.Right:
            if ((UseSensor(GameManager.Direction.Right) & GameManager.SensorData.Clear) != 0)
            {
                return(m_CurrentDirection);
            }
            else
            {
                RandomMove();
            }
            break;

        default:
            RandomMove();
            break;
        }

        // to be safe if recursion fails or switch gets broken out for some reason
        return(GameManager.Direction.Current);
    }
Beispiel #29
0
	void FixedUpdate () {
        pacManListener(transform.position);

		if (superMode) {
            if (Input.GetButton("Fire1")) {
                Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
                Vector3 fwd = transform.TransformDirection(Vector3.back);
                instance.AddForce(fwd * power);

                Destroy(instance.gameObject, DESTROY_BULLET_TIME);
            }

            if (followCam.InPosition) {
                float tiltAroundY = followCam.TiltAroundY;
                float moveForward = Input.GetAxis("Vertical");

                if (myDirection == GameManager.Direction.North) {
                    if (tiltAroundY < 280 && tiltAroundY > 260) {
                        myDirection = GameManager.Direction.West;           
                    } else if (tiltAroundY > 80 && tiltAroundY < 170) {
                        myDirection = GameManager.Direction.East;
                    }
                    moveNorth(moveForward);
                } else if (myDirection == GameManager.Direction.East) {
                    if (tiltAroundY > 170) {
                        myDirection = GameManager.Direction.South;
                    } else if (tiltAroundY < 10) {
                        myDirection = GameManager.Direction.North;
                    }
                    moveEast(moveForward);
                } else if (myDirection == GameManager.Direction.South) {
                    if (tiltAroundY > 260) {
                        myDirection = GameManager.Direction.West;
                    } else if (tiltAroundY < 100) {
                        myDirection = GameManager.Direction.East;
                    }
                    moveSouth(moveForward);
                } else if (myDirection == GameManager.Direction.West) {
                    if (tiltAroundY > 350) {
                        myDirection = GameManager.Direction.North;
                    } else if (tiltAroundY < 190) {
                        myDirection = GameManager.Direction.South;
                    }
                    moveWest(moveForward);
                }
            }
		} else {
			if (Input.GetAxis ("Right") > 0) {
                myDirection = GameManager.Direction.East;
                moveEast(Input.GetAxis("Right"));
			} else if (Input.GetAxis ("Left") > 0) {
                myDirection = GameManager.Direction.West;
                moveWest(Input.GetAxis("Left"));
			} else if (Input.GetAxis ("Up") > 0) {
                myDirection = GameManager.Direction.North;
                moveNorth(Input.GetAxis("Up"));
			} else if (Input.GetAxis ("Down") > 0) {
                myDirection = GameManager.Direction.South;
                moveSouth(Input.GetAxis("Down"));
			}
		}

        if (curPos.x >= level.renderer.bounds.max.x) {
            curPos.x = level.renderer.bounds.min.x;
        } else if (curPos.x <= level.renderer.bounds.min.x) {
            curPos.x = level.renderer.bounds.max.x;
        }

        transform.position = curPos;
        setRotation();
	}
    public IEnumerator <object> AnimateMovement(AnimationCallback callback, GameManager.Direction dir, float time, bool canMove)
    {
        float progress = 0.0f;
        //Vector3 startPos = this.gameObject.transform.position;
        // for some reason, changing the camera size messes this up if you use global position, so use local position instead.
        //Vector3 startPos = this.gameObject.transform.localPosition;
        Vector3 goalPos = startPos + (new Vector3(moveDir[(int)dir].x, moveDir[(int)dir].y, 0));


        //changes the direction of the player sprite
        spriteR = gameObject.GetComponent <SpriteRenderer>();
        if ((int)dir == 0)
        {
            spriteR.sprite = sprites[characterSelect[characterInput][10]];
        }
        else if ((int)dir == 1)
        {
            spriteR.sprite = sprites[characterSelect[characterInput][7]];
        }
        else if ((int)dir == 2)
        {
            spriteR.sprite = sprites[characterSelect[characterInput][1]];
        }
        else if ((int)dir == 3)
        {
            spriteR.sprite = sprites[characterSelect[characterInput][4]];
        }
        foot = !foot;

        if (canMove)
        {
            //Slide forward
            while (progress <= time)
            {
                if (GameManager.getCurrentState()._stateType != GameManager.IStateType.gameplay)
                {
                    yield return(null);

                    continue;
                }
                if ((int)dir == 0)
                {
                    if (foot)
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][9]];
                    }
                    else
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][11]];
                    }
                }
                else if ((int)dir == 1)
                {
                    if (foot)
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][6]];
                    }
                    else
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][8]];
                    }
                }
                else if ((int)dir == 2)
                {
                    if (foot)
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][0]];
                    }
                    else
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][2]];
                    }
                }
                else if ((int)dir == 3)
                {
                    if (foot)
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][3]];
                    }
                    else
                    {
                        spriteR.sprite = sprites[characterSelect[characterInput][5]];
                    }
                }
                progress += Time.deltaTime;
                //this.gameObject.transform.position = Vector3.Lerp(startPos, goalPos, progress / time);
                // for some reason, changing the camera size messes this up if you use global position, so use local position instead.
                this.gameObject.transform.localPosition = Vector3.Lerp(startPos, goalPos, progress / time);
                yield return(null);
            }
            //Snap back
            resetPos();
            //this.gameObject.transform.position = startPos;
            // for some reason, changing the camera size messes this up if you use global position, so use local position instead.

            if ((int)dir == 0)
            {
                spriteR.sprite = sprites[characterSelect[characterInput][10]];
            }
            else if ((int)dir == 1)
            {
                spriteR.sprite = sprites[characterSelect[characterInput][7]];
            }
            else if ((int)dir == 2)
            {
                spriteR.sprite = sprites[characterSelect[characterInput][1]];
            }
            else if ((int)dir == 3)
            {
                spriteR.sprite = sprites[characterSelect[characterInput][4]];
            }
        }

        callback(true);
    }
Beispiel #31
0
 public SensorData GetSensorData(Direction m_Direction)
 {
     // Used for MovementScript
     return(UseSensor(m_Direction));
 }
Beispiel #32
0
    public void DrawFullNode(Node node, GameManager.Direction?dir, Vector2Int?position, bool grayout = false)
    {
        if ((node == null) || (dir == null) || (position == null))              // set everything invisible if any of these are null
        {
            this.gameObject.SetActive(false);
        }
        else
        {
            // otherwise, draw the stuff as appropriate
            int i;
            for (i = 0; i < 4; i++)
            {
                SetLineFromDir((Direction)i, false);
            }

            if (node.hasEnter)  // set line/string visible as appropriate
            {
                SetLineFromDir(node.enter, true);
            }
            if (node.hasLeave)
            {
                SetLineFromDir(node.leave, true);
            }

            // set line/string center visible as appropriate

            /*if (node.hasEnter && node.hasLeave && node.enter.inverse() == node.leave)
             *      lineCenter.gameObject.SetActive(true);
             * else
             *      lineCenter.gameObject.SetActive(false);*/

            // should evaluate to an array of size 2 for tiles on the cardinal directions, 4 for the middle tile, or 1 otherwise
            // add the directions that need to be checked to the array
            // Directions to be check are based on tile location in relation to the center tile
            // North correspondes to upper-right, east to lower-right, south to lower-left, and west to upper-left.
            //    Center tile is checked in upper-right, lower-right, lower-left, upper-right directions,
            //    Tile on the cardinal directions are checked in the two directions pointeed away from the center tile,
            //    and all other tile are checked in the main direction that points away from the center tile
            Direction[] checkDirection = new Direction[((position.Value.x == 2) ? 2 : 1) * ((position.Value.y == 2) ? 2 : 1)];
            i = 0;
            if (position.Value.x <= 2)
            {
                if (position.Value.y <= 2)
                {
                    checkDirection[i] = Direction.South;
                    i++;
                }
                if (position.Value.y >= 2)
                {
                    checkDirection[i] = Direction.West;
                    i++;
                }
            }
            if (position.Value.x >= 2)
            {
                if (position.Value.y >= 2)
                {
                    checkDirection[i] = Direction.North;
                    i++;
                }
                if (position.Value.y <= 2)
                {
                    checkDirection[i] = Direction.East;
                }
            }
            // now in each of the given directions, it checks the nodes that can be reached clockwise and counter cockwise in each direction.
            // If nodes reached clockwise/counter-clockwise do not match or are null, the corner in that direction is set visible, otherwise that corner is set non-visible.
            foreach (Direction d in checkDirection)
            {
                if (node.drawCorner[(int)d])
                {
                    GameManager.gameplay.nonEuclidRenderer.cornerMaskMap[
                        position.Value.x + (((int)d < 2) ? 1 : 0),
                        position.Value.y + ((((int)d % 3) == 0) ? 1 : 0)
                    ].setCornerFromDir(true, dir.Value);
                }
            }

            //Update the floor sprite if this node has one.
            //load errorsprite if floor sprite is invalid.
            if (node.floorSprite != null)
            {
                //Sprite fSprite = Resources.Load<Sprite>("Floor_" + node.floorSprite);
                Sprite fSprite = GameManager.getSprite("Floor_" + node.floorSprite);
                if (fSprite != null)
                {
                    floor.sprite = fSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Floor_<" + node.floorSprite + ">\" not found");
                    //floor.sprite = Resources.Load<Sprite>("ErrorSprite");
                    floor.sprite = GameManager.errorSprite;
                }
            }
            //Update the wall sprites if this node has one.
            //load errorsprite if wall sprite is invalid.

            if (node.wallSprite != null)
            {
                //Sprite wSprite = Resources.Load<Sprite>("Wall_" + node.wallSprite + "_N");
                Sprite wSprite = GameManager.getSprite("Wall_" + node.wallSprite + "_N");
                if (wSprite != null)
                {
                    //northWall.sprite = wSprite;
                    walls[0].sprite = wSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Wall_<" + node.wallSprite + ">_N\" not found");
                    //walls[0].sprite = Resources.Load<Sprite>("ErrorSprite");
                    walls[0].sprite = GameManager.errorSprite;
                }
                //wSprite = Resources.Load<Sprite>("Wall_" + node.wallSprite + "_E");
                wSprite = GameManager.getSprite("Wall_" + node.wallSprite + "_E");
                if (wSprite != null)
                {
                    walls[1].sprite = wSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Wall_<" + node.wallSprite + ">_E\" not found");
                    //walls[1].sprite = Resources.Load<Sprite>("ErrorSprite");
                    walls[1].sprite = GameManager.errorSprite;
                }
                //wSprite = Resources.Load<Sprite>("Wall_" + node.wallSprite + "_S");
                wSprite = GameManager.getSprite("Wall_" + node.wallSprite + "_S");
                if (wSprite != null)
                {
                    walls[2].sprite = wSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Wall_<" + node.wallSprite + ">_S\" not found");
                    //walls[2].sprite = Resources.Load<Sprite>("ErrorSprite");
                    walls[2].sprite = GameManager.errorSprite;
                }
                //wSprite = Resources.Load<Sprite>("Wall_" + node.wallSprite + "_W");
                wSprite = GameManager.getSprite("Wall_" + node.wallSprite + "_W");
                if (wSprite != null)
                {
                    walls[3].sprite = wSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Wall_<" + node.wallSprite + ">_W\" not found");
                    //walls[3].sprite = Resources.Load<Sprite>("ErrorSprite");
                    walls[3].sprite = GameManager.errorSprite;
                }
                //wSprite = Resources.Load<Sprite>("Corner_" + node.wallSprite);
                wSprite = GameManager.getSprite("Corner_" + node.wallSprite);
                if (wSprite != null)
                {
                    corners.sprite = wSprite;
                }
                else
                {
                    Debug.Log("Error: sprite \"Corner_<" + node.wallSprite + ">\" not found");
                    //corners.sprite = Resources.Load<Sprite>("ErrorSprite");
                    corners.sprite = GameManager.errorSprite;
                }
            }

            if (grayout)                // if grayed-out, set all colors as grayed versions
            {
                floor.color = Color.Lerp(node.colorF, Color.gray, 0.9f);
                for (int j = 0; j < walls.Length; j++)
                {
                    walls[j].color = Color.Lerp(node.colorW, Color.gray, 0.9f);
                }
                corners.color = Color.Lerp(node.colorW, Color.gray, 0.9f);
                Color grayish = new Color(0.55f, 0.55f, 0.55f);
                for (int j = 0; j < debris.Length; j++)
                {
                    debris[j].color = grayish;
                }
                for (int j = 0; j < lines.Length; j++)
                {
                    lines[j].color = grayish;
                }
                //lineCenter.color = grayish;
            }
            else                        // if not grayed-out, set all colors as normal
            {
                floor.color = node.colorF;
                for (int j = 0; j < walls.Length; j++)
                {
                    walls[j].color = node.colorW;
                }
                corners.color = node.colorW;
                for (int j = 0; j < debris.Length; j++)
                {
                    debris[j].color = Color.white;
                }
                for (int j = 0; j < lines.Length; j++)
                {
                    lines[j].color = Color.white;
                }
                //lineCenter.color = Color.white;
            }

            //set debris visible is it exists
            SetDebrisFromNode(node);

            //set this tile visible
            this.gameObject.SetActive(true);

            //set walls visible as appropriate
            SetWallsFromNode(node, dir, position);
        }
    }