public float particleAttractionSpeed;  // Used for particle movement smoothing
	// Use this for initialization
	void Start () {
        flower = GameObject.FindWithTag("Flower").transform;
        saturationPoints = maxSaturationPoints;
        foreach (Transform child in transform) {
            if (child.tag == "ParticleSystem") {
                particleSystem = child.GetComponent<ParticleSystem>();
                break;
            }
        }
        particleSystem.simulationSpace = ParticleSystemSimulationSpace.World;  // Make the particles play in world space.
        flowerScript = flower.GetComponent<FlowerScript>();
        renderer = GetComponent<Renderer>();
	}
Exemple #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "TiltedEarth" && seedCount > 0)
        {
            TiltedGroundScript script = collision.GetComponent <TiltedGroundScript> ();

            // only plant in unplanted tilted earth
            if (script.GetIsPlanted() == false)
            {
                collision.GetComponent <TiltedGroundScript> ().PlantSeed();
                ScoreTrack.scoreNum += 20;
                seedCount--;
                ScoreTrack.seedNum = seedCount;

                // play particle effect
                ParticleSystem clone    = particle;
                Vector3        location = collision.transform.position;
                location.z = -4f;

                Instantiate(clone, location, collision.transform.rotation);

                avatarAnimator.SetFloat("planted", 3.0f);
                avatarAnimator.SetTrigger("avatar_happy");
            }
        }
        else if (collision.gameObject.tag == "Flower")
        {
            FlowerScript script = collision.GetComponent <FlowerScript> ();

            // flower can only hurt the player once
            if (script.getHurtPlayer() == false)
            {
                script.toggleHurtPlayer();

                Color semiTransparent = collision.GetComponent <SpriteRenderer> ().color;
                semiTransparent.a = 0.5f;
                collision.GetComponent <SpriteRenderer> ().color = semiTransparent;

                health--;

                avatarAnimator.SetFloat("stunned", 3.0f);

                // if player runs out of health reset seen
                if (health <= 0)
                {
                    RespawnPlayer();
                }
            }
        }
    }
    void Start()
    {
        FS = GameObject.FindObjectOfType <FlowerScript>();

        this.player = GameObject.FindWithTag("Player").transform;

        if (player)
        {
            Cursor.lockState = CursorLockMode.Locked;
        }
        else
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }
Exemple #4
0
    private bool isInvulnerable = false;  // Player is invulnerable for a period after hit



	void Start () {
        // Get the player's rigidbody2D component for movement uses.
        rigidbody2D = GetComponent<Rigidbody2D>();
        foreach (Transform child in transform) {
            if (child.tag == "GroundCollider") {
                groundCheckRadius = child.GetComponent<CircleCollider2D>().radius;
                break;
            }
        }
        foreach (Transform child in transform) {
            if (child.tag == "Flower") {
                flower = child.transform;
                flowerScript = flower.GetComponent<FlowerScript>();
                break;
            }
        }
        //print(groundCheckerRadius);
	}
	// Use this for initialization
	protected void Start () {
        rigidbody2D = GetComponent<Rigidbody2D>();
        player = GameObject.FindWithTag("Player").transform;
        flowerScript = GameObject.FindWithTag("Flower").GetComponent<FlowerScript>();
	}
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     flowerScript = GameObject.FindGameObjectWithTag("Flower").GetComponent<FlowerScript>();
     failureText = failureText.Replace("\\n", "\n");
 }
    public void AddShakeListener(GameObject flower)
    {
        FlowerScript flower_script = flower.GetComponent <FlowerScript>();

        shakeEvent.AddListener(flower_script.FillUpPollen);
    }
    public void SpawnFlowerField()
    {
        //Delete all remaining flowers
        foreach (GameObject flower in GameObject.FindGameObjectsWithTag("Flower"))
        {
            GameObject.Destroy(flower);
        }
        foreach (GameObject vine in GameObject.FindGameObjectsWithTag("Vine"))
        {
            GameObject.Destroy(vine);
        }
        flowerNumberList.Clear();
        flowerList.Clear();

        //Add hive and lake to collider list
        Collider hive = GameObject.FindGameObjectWithTag("Hive").GetComponent <Collider>();
        Collider lake = GameObject.FindGameObjectWithTag("Lake").GetComponent <Collider>();

        flowerList.Add(hive);
        flowerList.Add(lake);

        //Initialize
        int flower_int = 0;

        flowerNumberList.Add(flowerNumberVine);
        flowerNumberList.Add(flowerNumberWhite);
        flowerNumberList.Add(flowerNumberBlue);
        flowerNumberList.Add(flowerNumberPink);

        foreach (int flowerNumber in flowerNumberList)
        {
            int temp_flowerNumber = flowerNumber;

            for (int i = 0; i < temp_flowerNumber; i++)
            {
                if (temp_flowerNumber > flowerNumber * 5)
                {
                    break;
                }
                ;
                float   r     = planet.transform.localScale.x / 2;
                Vector3 point = ((Random.onUnitSphere * r) + planet.transform.position); // put the ray randomly around the transform

                if (flower_int == 0)
                {
                    // Instantiation mesh
                    instantiated_flower = Instantiate(vine_prefab, point, Quaternion.identity);

                    //Orient mesh
                    instantiated_flower.transform.LookAt(planet.transform);
                    instantiated_flower.transform.Rotate(-90, 0, 0);
                }
                else
                {
                    // Instantiation mesh
                    instantiated_flower = Instantiate(prefab, point, Quaternion.identity);

                    //Orient mesh
                    instantiated_flower.transform.LookAt(planet.transform);
                    instantiated_flower.transform.Rotate(-90, 0, 0);

                    //Set flower type
                    FlowerScript flower_script = instantiated_flower.GetComponent <FlowerScript>();
                    flower_script.flowerType = (FlowerScript.Flower)flower_int - 1;
                    flower_script.UpdateFlower();
                }

                //if intersecting with another flower, replace
                bool     isIntersecting = false;
                Collider flowerCollider = instantiated_flower.GetComponent <Collider>();

                foreach (Collider col in flowerList)
                {
                    if (flowerCollider.bounds.Intersects(col.bounds))
                    {
                        GameObject.Destroy(instantiated_flower);
                        temp_flowerNumber += 1;
                        isIntersecting     = true;
                        break;
                    }
                }
                // Add to list
                if (!isIntersecting)
                {
                    flowerList.Add(flowerCollider);
                }
            }
            flower_int += 1;
        }
    }