Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Notes") && !FindObjectOfType <CharacterMovement>().movingToNextDay&& FindObjectOfType <GameManager>().canStartGame)
        {
            game.canStick      = canTakeNotes;
            canTakeNotes       = !canTakeNotes;
            noteCanvas.enabled = canTakeNotes;

            if (menu.tutorialNum == 13)
            {
                menu.tutorialNum = 14;
            }
        }

        if (Input.GetButtonDown("SeedInfo") && player.objectHolding != null)
        {
            canSeedInfo        = !canSeedInfo;
            seedCanvas.enabled = canSeedInfo;
            SeedScript seed     = player.objectHolding.GetComponent <SeedScript>();
            string     seedText = "Seed Shape:  " + shapes[seed.seedShape];
            seedText += "\nSeed Size:  " + sizes[seed.size];
            seedText += "\nSeed Color:  " + color[seed.seedColorNum];
            seedText += "\nSeed Texture:  " + (seed.smooth ? "Smooth" : "Rough");
            seedText += "\nSeed Amount:  " + seed.numSeeds;
            seedCanvas.GetComponentInChildren <TextMeshProUGUI>().text = seedText;
            if (menu.tutorialNum == 14)
            {
                menu.tutorialNum = 15;
            }
        }
    }
Exemple #2
0
    public void FeedMe(GameObject plant)
    {
        SeedScript seed = plant.GetComponent <SeedScript>();

        if (seed.isBad)
        {
            Destroy(gameObject);
        }
    }
Exemple #3
0
    public void CreateNewItem(SeedScript plant)
    {
        GameObject nc = Instantiate(newContent, content.transform);

        nc.GetComponent <NewContent>().plant = plant;

        //GameObject ns = Instantiate(seed, nc.GetComponentsInChildren<Image>()[0].transform);
        GameObject ns = Instantiate(seed, nc.transform);
    }
Exemple #4
0
 // need to think about this function
 public void HeroInteract(GameObject equippedSeed, GameObject activePlayer)
 {
     if (readyToPlant)
     {
         seed = equippedSeed.GetComponent <SeedScript>();
         // currentPlayer = activePlayer.GetComponent<PlayerBehavior>();
         //plant a tree
         GameObject newTree = seed.Plant;;  // get from seedBehavior attached to object - seed.treeObject;
         if (!plantingCoroutineIsRunning)
         {
             StartCoroutine(StartPlantingTimer(newTree, 1, activePlayer));
             plantingCoroutineIsRunning = true;
         }
     }
 }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        game = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
        seed = GetComponentInParent <NewContent>().plant;

        seedShape = seed.seedShape;

        numSeeds = seed.numSeeds;

        seedColorNum = seed.seedColorNum;
        seedColor    = seed.seedColor;

        size = seed.size;

        gameObject.transform.localScale = Vector3.one;

        smooth = seed.smooth;

        GetComponent <Image>().sprite = smooth ? game.smoothSeeds[seedShape] : game.roughSeeds[seedShape];

        GetComponent <Image>().color = seedColor;
    }
Exemple #6
0
    //check for collision with seeds
    void OnTriggerEnter2D(Collider2D other)
    {
        //check if other object is a seed and if this planting spot is unoccupied
        if (other.tag == "Seed" && !occupied)
        {
            //Debug.Log("seed collision");
            //other object is indeed a seed, so get the seed script
            SeedScript seedScript = other.GetComponent <SeedScript>();

            // check the type of seed, make sure it corrisponds to this.type,
            // if so instansiate the corrisponding plant type.
            if (seedScript.type == type &&
                golden == seedScript.golden)
            {
                if (plantSound)
                {
                    AudioSource.PlayClipAtPoint(plantSound, this.transform.position, volume);
                }
                GrowPlant();
                GameObject.Destroy(other.gameObject);
            }
        }
    }
    public void FeedMe(GameObject plant)
    {
        SeedScript currentSeed = plant.GetComponent <SeedScript>();

        if (currentSeed.isBad)
        {
            FindObjectOfType <AudioManager>().Play("LongCrunch");
            isSad  = true;
            hunger = hunger - currentSeed.feedAmount > 0 ? hunger - currentSeed.feedAmount : 0;
            health = health - 1 > 0 ? health - 1 : 0;
            UpdateHearts();

            GetComponent <Animator>().SetBool("sad", true);
        }
        else
        {
            FindObjectOfType <AudioManager>().Play("ThreeCrunch");
            hunger = (currentSeed.feedAmount + hunger > maxHunger ? maxHunger : currentSeed.feedAmount + hunger);
        }

        hungerBar.size = hunger / maxHunger;

        CheckLiving();
    }