Ejemplo n.º 1
0
    private bool destIsValidTile(int nextI, int nextJ)
    {
        if (!onGrid(nextI, nextJ))
        {
            return(false);
        }
        tileStuff tileScript = tiles [nextI, nextJ].GetComponent <tileStuff> ();

        if (!usingElevator)
        {
            if (tileScript.getIsPlatform())
            {
                return(false);
            }
            if (tileScript.getHasElevCat())
            {
                return(true);
            }
            int checkIsPlatJ = nextJ - 1;
            if (onGrid(nextI, checkIsPlatJ))
            {
                tileScript = tiles [nextI, checkIsPlatJ].GetComponent <tileStuff> ();
                if (!tileScript.getIsPlatform())
                {
                    dest = new Vector3(nextI, nextJ, 0f);
//					setFallingDest (nextI, checkIsPlatJ);
                    floating = true;
                    return(true);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
        else
        {
            if (nextJ > elevCatMaxJ || nextJ < elevCatMinJ)
            {
                return(false);
            }
            //fixme use an elev cat counter?
            if (tileScript.getIsPlatform())
            {
                return(false);
            }
            return(true);
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        int newI = gridCont.convertToTileCoord(transform.position.x);
        int newJ = gridCont.convertToTileCoord(transform.position.y);

        if (newI != currI || newJ != currJ)
        {
            tileStuff tileScript = tiles [newI, newJ].GetComponent <tileStuff> ();
            tileScript.setHasElevCat(true);
            tileScript = tiles [currI, currJ].GetComponent <tileStuff> ();
            tileScript.setHasElevCat(false);
            currI = newI;
            currJ = newJ;
        }
        if (transform.parent == null)
        {
            Vector2 tileSpot = new Vector2(newI, newJ - gridCont.tileSize / 3);
            transform.position = Vector2.MoveTowards(transform.position, tileSpot, 0.2f);
        }
    }
Ejemplo n.º 3
0
    private void checkSpawningCats()
    {
        int nextI = boyTileI;        // - 1;
        int nextJ = boyTileJ;

//		if (facingRight) {
//			nextI = boyTileI + 1;
//		}
        //a platform cat?
        if (Input.GetKeyUp("1") || Input.GetMouseButtonUp(1))
        {
//			nextJ--;
            if (onGrid(nextI, nextJ - 1))
            {
                tileStuff tileScript = tiles [nextI, nextJ].GetComponent <tileStuff> ();
                tileStuff belowTile  = tiles [nextI, nextJ - 1].GetComponent <tileStuff> ();
                if (reachedDestination() && !belowTile.getHasElevCat() && !tileScript.getIsPlatform() && !tileScript.getHasElevCat())
                {
                    tileScript.placeCat(elevCat, elevCatPrefab, gridCont.tileSize);
                }
            }
        }
    }