Example #1
0
    public override void Init(MapHandlerExp mapHandler, Vector2 initSpace)
    {
        this.mapHandler = mapHandler;
        GetComponent <SpriteRenderer>().sprite = entryArrow;

        curSpace = initSpace;

        //Top player spawn
        if (curSpace.y == (mapHandler.tileGrid.GetLength(1) - 1))
        {
            heroDir = HeroDirections.Down;
            transform.localEulerAngles = new Vector3(0, 0, 180);
            curSpace  = new Vector2(curSpace.x, curSpace.y + 3);
            nextSpace = new Vector2(curSpace.x, curSpace.y - 1);
        }

        //Bottom player spawn
        else if (curSpace.y == 0)
        {
            heroDir = HeroDirections.Up;
            transform.localEulerAngles = new Vector3(0, 0, 0);
            curSpace  = new Vector2(curSpace.x, curSpace.y - 3);
            nextSpace = new Vector2(curSpace.x, curSpace.y + 1);
        }

        //Left player spawn
        else if (curSpace.x == 0)
        {
            heroDir = HeroDirections.Right;
            transform.localEulerAngles = new Vector3(0, 0, 270);
            curSpace  = new Vector2(curSpace.x - 3, curSpace.y);
            nextSpace = new Vector2(curSpace.x + 1, curSpace.y);
        }

        //Right player spawn
        else if (curSpace.x == (mapHandler.tileGrid.GetLength(0) - 1))
        {
            heroDir = HeroDirections.Left;
            transform.localEulerAngles = new Vector3(0, 0, 90);
            curSpace  = new Vector2(curSpace.x + 3, curSpace.y);
            nextSpace = new Vector2(curSpace.x - 1, curSpace.y);
        }

        //Else illegal spawn
        else
        {
            print("Tried to spawn the hero at x=" + curSpace.x + ", y=" + curSpace.y + " which is ILLEGAL (so we're just gonna default to some arbitrary values, please fix)");
            heroDir   = HeroDirections.Up;
            nextSpace = new Vector2(curSpace.x, curSpace.y + 1);
        }
    }
Example #2
0
 void ChangeHeroDirection(HeroDirections newDir)
 {
     heroDir = newDir;
     UpdateHeroGraphic();
 }