void Start()
    {
        boxCollider2D = GetComponent <BoxCollider2D>();

        //furnace needs this as a reference
        theFurnace = GameObject.Find("Furnace").GetComponent <FurnaceScript>();
        //also spawning
        theSpawning = GameObject.Find("SpawningPoint").GetComponent <SpawningScript>();

        //the ingredients should fly towards this, if correct
        target = null;

        theChangeScene = GameObject.Find("Canvas").GetComponent <ChangeSceneScript>();

        theMoney = GameObject.Find("Money").GetComponent <MoneyScript>();

        theSPF = GameObject.Find("SpawningFoodLayer").GetComponent <SpawningFoodLayerScript>();
        theSPF.spawnfoodlayer();//

        foodlayerclone = GameObject.Find("FoodLayer(Clone)");

        theNextRecipe = GameObject.Find("NextRecipeButton").GetComponent <NextRecipeScript>();

        theGameMaster = GameObject.Find("GameMaster").GetComponent <GameMasterScript>();
    }
    // Start is called before the first frame update
    void Start()
    {
        theGameMaster  = GameObject.Find("GameMaster").GetComponent <GameMasterScript>();
        theChangeScene = GameObject.Find("Canvas").GetComponent <ChangeSceneScript>();

        //assign a sprite to the objects that will appear
        GameObject.Find("Object1").GetComponent <SpriteRenderer>().sprite = spritetobebought[0];
        GameObject.Find("Object2").GetComponent <SpriteRenderer>().sprite = spritetobebought[1];
        if (spritetobebought.Length >= 3)
        {
            GameObject.Find("Object3").GetComponent <SpriteRenderer>().sprite = spritetobebought[2];
        }

        GameObject.Find("ChooseButton").GetComponentInChildren <Text>().text = theGameMaster.languagehandler["Choose"];

        //initialise laguage and character elements
        GameObject.Find("ContinueButton").GetComponentInChildren <Text>().text = theGameMaster.languagehandler["Continue"];
        GameObject.Find("Congratulations").GetComponent <Text>().text          = theGameMaster.languagehandler["Congratulations"];
        //Debug.Log("option character" + theGameMaster.option_character);
        GameObject.Find("CharacterImage").GetComponent <Image>().sprite = theGameMaster.spriteslayers[theGameMaster.option_character];

        //hide all of these until we press coninue
        foreach (GameObject sgameObject in screenGameObjects)
        {
            sgameObject.SetActive(false);
        }
    }
Exemple #3
0
    // Set prefered FPS
    //void Awake() {
    //	Application.targetFrameRate = 25;
    //}

    // Use this for initialization
    void Start()
    {
        gameState  = GameState.Loaded;
        globalData = ChangeSceneScript.Instance;

        // Ads sound
        AudioListener.pause = false;

        // Count total diamonds for this level
        availableDiamonds = GameObject.FindGameObjectsWithTag("Diamond").Length;

        // Get and show current level
        currentLevelText.text = string.Format("Level: {0}", globalData.currentLevel);

        // Check is audio is mute
        audioSource.mute = !globalData.musicOn;

        // Configure individual levels:
        switch (globalData.currentLevel)
        {
        case 1:
            break;

        case 2:
            break;

        case 3:
            //arrows = new [] {Vector3.left, Vector3.back, Vector3.right, Vector3.forward};
            arrows = new[] { Vector3.left, Vector3.back, Vector3.right, Vector3.forward };
            break;

        case 4:
            speedDeltas = new int[] { 0, 0, 4, 0 };
            break;

        case 5:
            arrows = new[] { Vector3.forward, Vector3.back, Vector3.left, Vector3.right };
            break;

        case 6:
            speedDeltas = new int[] { 4, 0, 4, 0 };
            break;

        case 7:
            arrows = new[] { Vector3.forward, Vector3.back, Vector3.forward, Vector3.right };
            break;

        default:
            break;
        }

        arrowsLength = arrows.Length;
    }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        string            nextSceneName = "materScene";
        string            prevSceneName = "materScene";
        ChangeSceneScript helper        = FindObjectOfType <ChangeSceneScript>();

        if (helper != null)
        {
            nextSceneName = helper.NextSceneName;
            prevSceneName = helper.PrevSceneName;
        }

        StartCoroutine(LoadNextScene(nextSceneName, prevSceneName));
    }
    // Access text field
    void Start()
    {
        globalData  = ChangeSceneScript.Instance;
        updateField = true;

        // Get music configuration
        musicToggle.isOn = globalData.musicOn;


        // Add listener to change of toggle
        musicToggle.GetComponent <Toggle> ().onValueChanged.AddListener(
            delegate {
            globalData.setMusic(musicToggle.GetComponent <Toggle>().isOn);
        });

        // Add listener to Play button
        playButton.onClick.AddListener(() => {
            globalData.ChangeScene();
        });
    }
Exemple #6
0
    void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (GlobalData != null && GlobalData != this)
        {
            Destroy(this.gameObject);
        }

        GlobalData = this;
        DontDestroyOnLoad(this.gameObject);

        /// LOAD DATA ///
        adsCounter = 1;

        // Get if music is on
        musicOn = PlayerPrefs.GetInt("GameMusic", 1) == 1;

        // Set chosen level
        limitLevel = PlayerPrefs.GetInt("LimitLevel", defaultLimitLevel);

        // Get last available Level
        currentLevel = PlayerPrefs.GetInt("CurrentGameLevel", 1);
    }
    //Handles input from player
    void Update()
    {
        //select J
        if (Input.GetKeyDown(KeyCode.J))
        {
            SmallItemSlot.ShowDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            choice = (int)Choices.Small;
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.ShowDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            choice = (int)Choices.Medium;
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.ShowDescriptionPanel();
            choice = (int)Choices.Large;
        }

        if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
        {
            HoldADTime += Time.deltaTime;
            HoldADFill.transform.localScale = new Vector3(HoldADTime, 1, 1);
            print("been holding for " + (int)HoldADTime);
            if (HoldADTime > 1f)
            {
                ChangeSceneScript.ChangeScene(nextScene);
            }
        }

        if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D))
        {
            HoldADTime = 0;
            HoldADFill.transform.localScale = new Vector3(HoldADTime, 1, 1);
            print("been holding for " + (int)HoldADTime);
        }
        if (Input.GetKey(KeyCode.Space))
        {
            HoldSpaceTime += Time.deltaTime;
            //don't stretch infinitely
            if (HoldSpaceTime < 1.01)
            {
                HoldSpaceFill.transform.localScale = new Vector3(HoldSpaceTime, 1, 1);
            }
            print("been holding for " + (int)HoldSpaceTime);
            if (HoldSpaceTime > 1f)
            {
                switch (choice)
                {
                case (int)Choices.None:
                    error.Play();
                    print("no selection");
                    break;

                case (int)Choices.Small:
                    SmallItemSlot.Buy();
                    break;

                case (int)Choices.Medium:
                    MediumItemSlot.Buy();
                    break;

                case (int)Choices.Large:
                    LargeItemSlot.Buy();
                    break;
                }
                HoldSpaceTime = 0f;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            HoldSpaceTime = 0;
            HoldSpaceFill.transform.localScale = new Vector3(HoldSpaceTime, 1, 1);
            print("been holding for " + (int)HoldSpaceTime);
        }

        if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.D))
        {
            SmallItemSlot.HideDescriptionPanel();
            MediumItemSlot.HideDescriptionPanel();
            LargeItemSlot.HideDescriptionPanel();
            //reset choice nothing
            choice = (int)Choices.None;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        renderer = GetComponent <SpriteRenderer>();

        theSPF = GameObject.Find("SpawningFoodLayer").GetComponent <SpawningFoodLayerScript>();

        target     = GameObject.Find("Furnace");
        movetoward = GameObject.Find("SpeechBubble");

        //load a base graphic
        //renderers[3].sprite = SpriteLayerBase(target.GetComponent<FurnaceScript>().recipe.name);

        theNextRecipe = GameObject.Find("NextRecipeButton").GetComponent <NextRecipeScript>();

        gameObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);

        theChangeScene = GameObject.Find("Canvas").GetComponent <ChangeSceneScript>();
        theFurnace     = GameObject.Find("Furnace").GetComponent <FurnaceScript>();

        theGameMaster = GameObject.Find("GameMaster").GetComponent <GameMasterScript>();

        theMoney = GameObject.Find("Money").GetComponent <MoneyScript>();

        gameObject.name = "FoodLayer(Clone)";

        /*make changes to the food layer for the following specific recipes*/

        //change ice cream's position to within the board's surface
        if (theFurnace.recipe.name.StartsWith("Salad"))
        {
            gameObject.transform.position = new Vector3(-0.3f, 0.2f, 0);
        }
        else if (theFurnace.recipe.name.StartsWith("IceCream"))
        {
            gameObject.transform.position = new Vector3(-0.3f, 0.8f, 0);
        }
        else if (theFurnace.recipe.name.StartsWith("Club"))//initialise club sandwich, if needed
        {
            int clchldrn;
            clchldrn = gameObject.transform.childCount;

            for (int i = 1; i < clchldrn; i++)
            {
                //Debug.Log("forloop");

                if (theFurnace.recipe.neededIngr.Count < i)
                {
                    gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, -0.175f * i + 0.05f * (i) + 0.1f, 0);
                    break;
                }
                // Debug.Log("i "+i+" neededingr "+theFurnace.recipe.neededIngr.Count);
                //Debug.Log(theFurnace.recipe.neededIngr[i-1]);

                //gameObject.transform.GetChild(i - 1).GetComponent<Transform>().localPosition = new Vector3(0f, 0.05f * (i-1), 0);
                gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, -0.175f * i + 0.05f * (i), 0);
                //Debug.Log("0.05*i-1=" + 0.05 * (i-1));

                if (theFurnace.recipe.neededIngr[i - 1] == "Potato")
                {
                    potatoeson = true;

                    //assign the base's position on potatoes
                    gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition = gameObject.transform.GetChild(clchldrn - 2).GetComponent <Transform>().localPosition;

                    gameObject.transform.GetChild(i - 1).GetComponent <SpriteRenderer>().sortingOrder = 4;
                }
            }
            for (int i = 1; i < clchldrn; i++)
            {
                gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, 0.175f, 0);
                if (potatoeson)
                {
                    gameObject.transform.GetChild(i - 1).GetComponent <SpriteRenderer>().sortingOrder++;
                    if (i == clchldrn - 1)
                    {
                        //gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition += new Vector3(0f, -0.700f, 0);
                        gameObject.transform.GetChild(i).GetComponent <Transform>().localPosition = new Vector3(0f, theFurnace.recipe.neededIngr.Count * 0.05f, 0);
                    }
                }

                /*if ((i != (clchldrn - 2)))
                 * {
                 *  gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0.05f * (i), 0);
                 *  if (theFurnace.recipe.neededIngr.Count>=i )
                 *  {
                 *      if (theFurnace.recipe.neededIngr[i] == "Potato")
                 *      {
                 *          Debug.Log("1");
                 *          if (i < clchldrn - 2)
                 *          {
                 *              Debug.Log("2");
                 *              gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0f, 0);
                 *          }
                 *      }
                 *  }
                 * }*/
                /*else
                 * {
                 *  gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0, 0);
                 * }*/

                //gameObject.transform.GetChild(i - 1).GetComponent<Transform>().localPosition += new Vector3(0f, 0.175f, 0);
            }

            gameObject.GetComponent <SpriteRenderer>().sprite       = theGameMaster.spriteslayers["Plate"];
            gameObject.GetComponent <SpriteRenderer>().sortingOrder = 4;
        }

        set_ingredient_distance();

        //Debug.Log("k");
    }
 void Awake()
 {
     Instance = this;
 }
Exemple #10
0
 public void Change()
 {
     ChangeSceneScript.ChangeScene(nextScene);
 }
    public void Start()
    {
        globalData = ChangeSceneScript.Instance;

        nextLevelButton.interactable = enableNextLevelButton();
    }