Save() public static method

public static Save ( int num ) : void
num int
return void
Example #1
0
    public bool ValidateMove(Vector3 targetLocation, bool isPlayer, List <TileType> tileTypes)
    {
        // can be null as it loads
        if (grid == null)
        {
            return(false);
        }

        Vector3Int tilePos = grid.WorldToCell(targetLocation);

        //Debug.Log("***************************************************");
        //Debug.Log("targetLoc: " + targetLocation + " targetCell: " + tilePos + " count: " + grid.transform.childCount);
        for (int i = 0; i < grid.transform.childCount; i++)
        {
            GameObject child   = grid.transform.GetChild(i).gameObject;
            Tilemap    tilemap = child.GetComponent <Tilemap>();
            //Debug.Log("tilemap: " + tilemap.name + ", rule: " + rule);
            SuperTile tile = tilemap.GetTile <SuperTile>(tilePos);
            if (tile != null)
            {
                GridTile gridTile = getTileProperties(tile);
                //Debug.Log("Tile matched");
                if (gridTile.cost >= 0)
                {
                    if (isPlayer)
                    {
                        if (gridTile.tileType == TileType.LOCATION)
                        {
                            foreach (GameObject location in locations)
                            {
                                if (Vector3.Distance(location.transform.position, targetLocation) <= 0.05f)
                                {
                                    //Debug.Log("Enter location: " + location.name);
                                    saveLoadHandler.Save();
                                    StartCoroutine(LoadLocationScene(location.name));
                                    return(true);
                                }
                            }
                            return(false);
                        }
                        else
                        {
                            questHandler.IncrementTime(gridTile.cost);
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    // only allow the first rule to be processed
                    return(false);
                }
            }
        }
        return(false);
    }
Example #2
0
    AsyncOperation op; // Holds the async operation. Used to 'allowSceneActivation'.

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other == switch_point.GetComponent <Collider2D>())
        {
            if (setGravity != null)
            {
                GravityWarp.gravity = setGravity;
            }
            Info.gameTime              += Camera.main.GetComponent <GravityWarp>().leveltmr;
            Info.checkpoint             = new Vector3(0, 0, 0);
            SaveLoadHandler.playerScene = nextLevel;
            SaveLoadHandler.Save();
            op.allowSceneActivation = true;
        }
        else if (other == exit_point.GetComponent <Collider2D>())
        {
            if (asyncLoad && !loadOnce)
            {
                loadOnce = true;
                Debug.Log("Loading " + nextLevel);
                op = SceneManager.LoadSceneAsync(nextLevel);
                op.allowSceneActivation = false;
                if (exitDoor != null)
                {
                    exitDoor.GetComponent <Door>().ActivateLink(1);
                }
            }
        }
    }
Example #3
0
 // Update is called once per frame
 void Update()
 {
     if (playerController != null && map != null &&
         (playerController.transform.position.x <= 0 ||
          playerController.transform.position.x >= map.m_Width - 1 ||
          playerController.transform.position.y >= 0 ||
          playerController.transform.position.y <= -map.m_Height + 1))
     {
         saveLoadHandler.Save();
         StartCoroutine(ExitLocation());
     }
 }