Example #1
0
    public void BeginGameplay(Vector3 playerStartPosition)
    {
        Debug.Log("Beginning gameplay");
        currentTileMap = tilemapControllers[0];
        currentTileMap.PlayLevelIntro(OnNewLevelIntroAnimationComplete);

        Instance.playerController = Instantiate <PlayerController>(Instance.playerPrefab, null);
        Instance.playerController.transform.position = playerStartPosition + .44f * Vector3.up;
        CharacterController2D.Instance = Instance.playerController.GetComponent <CharacterController2D>();
        CharacterController2D.Enable();
    }
    void Awake()
    {
        me = this;
        //Have to set the floor to recive shadows here because it won't let us in the inspector
        floor.gameObject.GetComponent <TilemapRenderer> ().receiveShadows = true;
        calculateLighting();
        TilemapRenderer t = lighting.gameObject.GetComponent <TilemapRenderer> ();

        //lighting.transform.position = new Vector3 (lighting.transform.position.x - 0.2f, lighting.transform.position.y - 0.2f, lighting.transform.position.z);
        t.sortingOrder = 99;
    }
Example #3
0
    void makeNodesUnwalkable(GameObject g, bool corner)
    {
        LevelTilemapController tilemapCont = FindObjectOfType <LevelTilemapController> ();

        if (corner == true)
        {
            Vector3Int v = new Vector3Int((int)g.transform.position.x, (int)g.transform.position.y - 1, 0);
            tilemapCont.nonWalkable.SetTile(v, null);
        }
        else
        {
            if (g.transform.rotation.eulerAngles.z <= 1 || g.transform.rotation.eulerAngles.z >= 179 && g.transform.rotation.eulerAngles.z <= 181)
            {
                Vector3Int v = new Vector3Int((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
                tilemapCont.nonWalkable.SetTile(v, null);                  //TODO doesnt seem to work, work out why
                //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall



                if (corner == false)
                {
                    v = new Vector3Int((int)g.transform.position.x, (int)g.transform.position.y - 1, 0);
                    tilemapCont.nonWalkable.SetTile(v, null);

                    //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y, 0);
                    //tilemapCont.nonWalkable.SetTile (v,block);

                    //v = new Vector3Int ((int)g.transform.position.x-1, (int)g.transform.position.y, 0);
                    //tilemapCont.nonWalkable.SetTile (v,block);
                }
            }
            else if (g.transform.rotation.eulerAngles.z >= 89 && g.transform.rotation.eulerAngles.z <= 91 || g.transform.rotation.eulerAngles.z >= 269 && g.transform.rotation.eulerAngles.z <= 271)
            {
                Vector3Int v = new Vector3Int((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
                tilemapCont.nonWalkable.SetTile(v, null);                  //TODO doesnt seem to work, work out why
                //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall



                if (corner == false)
                {
                    v = new Vector3Int((int)g.transform.position.x - 1, (int)g.transform.position.y, 0);
                    tilemapCont.nonWalkable.SetTile(v, null);

                    //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y, 0);
                    //tilemapCont.nonWalkable.SetTile (v,block);

                    //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y-1, 0);
                    //tilemapCont.nonWalkable.SetTile (v,block);
                }
            }
        }
    }
Example #4
0
 public void GoToNextLevel()
 {
     //successful completion of level
     Debug.Log("Level completed successfully!");
     //freeze gameplay / disallow input
     // InputController.Enabled = false;
     if (currentTileMap.isFinalLevel)
     {
         currentTileMap.RemoveAllRemovables();
         OnLastLevelOutroAnimationComplete();
     }
     else
     {
         CharacterController2D.Disable();
         lastGongPosition = currentTileMap.goalLocation.position;
         currentLevelIdx += 1;
         currentTileMap   = tilemapControllers[currentLevelIdx];
         currentTileMap.PlayLevelOutro(OnOldLevelOutroAnimationComplete);
     }
 }
Example #5
0
    void makeNodesWalkable(GameObject g, bool corner, bool tSection)
    {
        LevelTilemapController tilemapCont = FindObjectOfType <LevelTilemapController> ();
        Vector3Int             v           = new Vector3Int(Mathf.RoundToInt(g.transform.position.x), Mathf.RoundToInt(g.transform.position.y), 0);

        tilemapCont.nonWalkable.SetTile(v, block);
        v = new Vector3Int(Mathf.RoundToInt(g.transform.position.x - 1), Mathf.RoundToInt(g.transform.position.y), 0);
        tilemapCont.nonWalkable.SetTile(v, block);
        v = new Vector3Int(Mathf.RoundToInt(g.transform.position.x - 1), Mathf.RoundToInt(g.transform.position.y - 1), 0);
        tilemapCont.nonWalkable.SetTile(v, block);
        v = new Vector3Int(Mathf.RoundToInt(g.transform.position.x), Mathf.RoundToInt(g.transform.position.y - 1), 0);
        tilemapCont.nonWalkable.SetTile(v, block);

        /*if (tSection == true) {
         *      if (g.transform.rotation.eulerAngles.z <= 1) {
         *
         *              Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *              //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y , 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *              v = new Vector3Int ((int)g.transform.position.x-2, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *
         *              //v = new Vector3Int ((int)g.transform.position.x+2, (int)g.transform.position.y - 1, 0);
         *              //tilemapCont.nonWalkable.SetTile (v, block);
         *
         *
         *
         *      }
         *      else if(g.transform.rotation.eulerAngles.z >= 179 && g.transform.rotation.eulerAngles.z <= 181)
         *      {
         *              Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *              //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y , 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *              v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *
         *              v = new Vector3Int ((int)g.transform.position.x+1, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *      }
         *      else if (g.transform.rotation.eulerAngles.z >= 89 && g.transform.rotation.eulerAngles.z <= 91 ) {
         *
         *
         *              Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *              //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *              v = new Vector3Int ((int)g.transform.position.x , (int)g.transform.position.y-1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y+1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *      }
         *      else if(g.transform.rotation.eulerAngles.z >= 269 && g.transform.rotation.eulerAngles.z <= 271)
         *      {
         *              Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *              //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *              v = new Vector3Int ((int)g.transform.position.x , (int)g.transform.position.y-1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y-1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y-2, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *      }
         * } else {
         *
         *      if (corner == true) {
         *              Vector3Int v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y - 1, 0);
         *              tilemapCont.nonWalkable.SetTile (v, block);
         *      } else {
         *              if (g.transform.rotation.eulerAngles.z <= 1 || g.transform.rotation.eulerAngles.z >= 179 && g.transform.rotation.eulerAngles.z <= 181) {
         *                      Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *                      tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *                      //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *
         *                      if (corner == false) {
         *                              v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y - 1, 0);
         *                              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *                              //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y, 0);
         *                              //tilemapCont.nonWalkable.SetTile (v,block);
         *
         *                              //v = new Vector3Int ((int)g.transform.position.x-1, (int)g.transform.position.y, 0);
         *                              //tilemapCont.nonWalkable.SetTile (v,block);
         *                      }
         *              } else if (g.transform.rotation.eulerAngles.z >= 89 && g.transform.rotation.eulerAngles.z <= 91 || g.transform.rotation.eulerAngles.z >= 269 && g.transform.rotation.eulerAngles.z <= 271) {
         *                      Vector3Int v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y - 1, 0);
         *                      tilemapCont.nonWalkable.SetTile (v, block); //TODO doesnt seem to work, work out why
         *                      //TODO redo the two tone wall so its center is in the right place and it matches up with the other wall
         *
         *
         *
         *                      if (corner == false) {
         *
         *                              v = new Vector3Int ((int)g.transform.position.x - 1, (int)g.transform.position.y, 0);
         *                              tilemapCont.nonWalkable.SetTile (v, block);
         *
         *                              //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y, 0);
         *                              //tilemapCont.nonWalkable.SetTile (v,block);
         *
         *                              //v = new Vector3Int ((int)g.transform.position.x, (int)g.transform.position.y-1, 0);
         *                              //tilemapCont.nonWalkable.SetTile (v,block);
         *                      }
         *              }
         *
         *      }
         * }*/
    }