Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        flashCanvas.SetActive(true);
        string sceneName = SceneLoaderScript.getLastSceneName();

        sceneName = sceneName != null ? sceneName : "";

        LevelDatabase.LevelData level = LevelDatabase.GetLevelData(sceneName);
        string levelName  = level != null ? level.name : "Unknown level";
        string levelImage = level != null ? level.polaroidPath : "";

        DateTime time = DateTime.UtcNow.Date;

        dateField.text = time.ToShortDateString();

        SetLevelDuration();

        levelNameField.text = levelName;
        selfie.GeneratePose();
        tagsField.text = GetRandomTagsText();

        backgroundImage.sprite = Resources.Load <Sprite>(levelImage);

        if (level != null)
        {
            string levelNameForPath = levelName.Replace(' ', '_');
            screenShot.TakeScreenShot(levelNameForPath, path =>
            {
                GalleryEntry entry = new GalleryEntry(levelName, path);
                GalleryManager.Instance.SaveEntry(entry);
            });
        }
    }
Ejemplo n.º 2
0
    private void Start()
    {
        var blocks = FindObjectsOfType <Block>();

        blocksCount = Array.FindAll(blocks, b => b.tag == "Breakable").Length;
        sceneLoader = FindObjectOfType <SceneLoaderScript>();
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     m_elephantMovement          = GameObject.FindObjectOfType <ElephantMovement>();
     m_sceneLoader               = GameObject.FindObjectOfType <SceneLoaderScript>();
     m_wantedLevel               = GameObject.FindObjectOfType <WantedLevel>();
     StatePatternEnemy.OnCaught += OnCaught;
     Collectable.OnCollect      += OnCollect;
 }
Ejemplo n.º 4
0
    void SetLevelDuration()
    {
        float duration = SceneLoaderScript.getDurationOfLastScene();
        int   minutes  = (int)(duration / 60.0f);
        int   seconds  = (int)(duration % 60.0f);

        levelDurationField.text = $"{minutes.ToString("D2")}:{seconds.ToString("D2")} Minutes";
    }
    void ShowResults()
    {
        SceneLoaderScript sceneLoaderScript = GameObject.Find("RoundManager").GetComponent <SceneLoaderScript>();
        string            currRound         = sceneLoaderScript.GetActiveSceneName();
        // Get score
        GameObject playerNest = GameObject.Find("PlayerNest");
        int        score      = playerNest.GetComponent <NestControl>().GetScore();
        string     message    = "";

        if (currRound == "PracticeRound")
        {
            message = "You collected " + score + " seeds in this practice mode! Now you'll move to an island with mostly large seeds. Meet the target number of seeds in order to survive!";
            sceneLoaderScript.SetFirstIsland("large");
        }
        // Create UI message with score
        else if (score >= quota)
        {
            if (currRound == "RoundOne")
            {
                message = "You collected enough seeds, you are thriving on this island! Next, you will try to meet your target again while another finch feeds at the same time.";
            }
            else
            {
                message = "You collected enough seeds and managed to survive!";
            }
            sceneLoaderScript.SetIsland(_largeNPCPrefab);
        }
        else
        {
            if (currRound == "RoundOne")
            {
                message = "You didn't collect enough seeds, so you must migrate to another island! There might be better seeds there, but other finches as well!";
            }
            else if (currRound == "RoundTwo")
            {
                message = "You didn't collect enough seeds, so you failed to survive!";
            }
            string playerFinch = sceneLoaderScript.GetActiveFinchName();
            if (playerFinch == "Large_Beak_Finch" || playerFinch == "Medium_Beak_Finch")
            {
                sceneLoaderScript.SetIsland(_mediumNPCPrefab, 2f, 17f, 1f);
            }
            else
            {
                sceneLoaderScript.SetIsland(_smallNPCPrefab, 1f, 2f, 17f);
            }
        }
        GameObject roundCanvas = GameObject.Find("Canvas");
        // Fix this hacky positioning later
        GameObject nextStep = Instantiate(nextStepPrefab, new Vector3(0, 100, 0), Quaternion.identity) as GameObject;

        nextStep.GetComponentInChildren <Text>().text = message;
        nextStep.transform.SetParent(roundCanvas.transform, false);
        // Give option to continue
        Button continueButton = nextStep.GetComponentInChildren <Button>();

        continueButton.onClick.AddListener(delegate { sceneLoaderScript.LoadNext(); });
    }
Ejemplo n.º 6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag.Contains("Player"))
        {
            SceneLoaderScript scene_loader = GetComponent <SceneLoaderScript>();

            scene_loader.loadScene(level_name);
        }

        //if (collision.tag == "Finish") {
        //    Debug.Log("Collision with FinalFlag!");
        //    scene_loader.loadScene("LevelComplete");
        //}
    }
Ejemplo n.º 7
0
    //Awake is always called before any Start functions
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 8
0
 private void Start()
 {
     sceneLoader = FindObjectOfType <SceneLoaderScript>();
 }
Ejemplo n.º 9
0
 public void Awake()
 {
     Instance = this;
     DontDestroyOnLoad(gameObject);
 }
 public GameManagerScript(SceneLoaderScript sceneLoader, InjectorHelper injectorHelper, SignalBus signalBus)
 {
     this.sceneLoader    = sceneLoader;
     this.injectorHelper = injectorHelper;
     this.signalBus      = signalBus;
 }