Beispiel #1
0
    public void CreateCow()
    {
        if (_selectedCow == null)
        {
            return;
        }
        MotherActivity activity = _selectedCow.GetComponent <MotherActivity>();

        if (!activity)
        {
            Debug.LogError("Not cow activitie");
            return;
        }

        activity.SpawnCow();
    }
Beispiel #2
0
    public bool DropCow(bool goodCow)
    {
        Cow newCow = (Cow)Instantiate(cow, dropPoint.position, Quaternion.identity).GetComponent(typeof(Cow));

        cows--;

        newCow.goodCow = goodCow;
        newCow.lastCow = cows <= 0;

        var rigidBody = newCow.GetComponent <Rigidbody2D>();

        rigidBody.gravityScale = 1f;

        updateText();

        return(cows <= 0);
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        PlayerManager.m_instance.addNoise(noiseByUpdate);
        ParticleSystem[] ps = GetComponentsInChildren <ParticleSystem> ();
        for (int i = 0; i < ps.Length; i++)
        {
            if (ps[i].name == "ground-light")
            {
                int        layerMask = 1 << 10;
                GameObject ground    = GameObject.Find("Ground");
                //Debug.Log (ground.name);
                Quaternion quat  = Quaternion.identity;
                Vector3    quatv = quat.eulerAngles;
                quatv.x                  = 5.0f;
                quat.eulerAngles         = quatv;
                ps[i].transform.rotation = quat;
                ps[i].transform.position = new Vector3(transform.position.x,
                                                       -4.5f,
                                                       -1.0f);

                /*	Debug.Log ("PUTE");
                 * }*/
            }
        }
        if (m_active && m_catched_array != null && m_catched_array.Count > 0 && cowsAreLiftable())
        {
            Cow cow = null;
            //cow = (Cow)m_catched_array[0];
            for (int i = 0; i < m_catched_array.Count; i++)
            {
                if (!cow && !((Cow)m_catched_array[i]).m_pointAlreadyGive)
                {
                    cow = (Cow)m_catched_array[i];
                }

                if (cow && !((Cow)m_catched_array[i]).m_pointAlreadyGive && cow.transform.position.y <= ((Cow)m_catched_array[i]).transform.position.y)
                {
                    cow = (Cow)m_catched_array[i];
                }
            }
            if (cow != null)
            {
                if (cow.transform.position.y < cow.YGroundPLus)
                {
                    cow.setOverGround();
                }

                Bounds  cowBounds = cow.GetComponent <BoxCollider2D>().bounds;
                Vector3 v3t       = cowBounds.center;
                v3t.z            = 0.0f;
                cowBounds.center = v3t;
                Bounds bounds = GetComponent <BoxCollider2D>().bounds;
                v3t           = bounds.center;
                v3t.z         = 0.0f;
                bounds.center = v3t;
                if (cow.getCowState() == CowState.Flying && cowBounds.Intersects(bounds))
                {
                    cow.setCowState(CowState.BeingLiftToShip);
                    activateBorders();
                }

                Rigidbody2D rb2D = cow.GetComponent <Rigidbody2D> ();


                if (cow.getCowState() == CowState.BeingLiftToShip)
                {
                    float r = Random.Range(0.0f, 1000.0f);
                    if (r > m_cow_dir_no_switch_percentage * 10)
                    {
                        m_beamed_last_directions = -m_beamed_last_directions;
                    }
                    if (rb2D)
                    {
                        rb2D.AddForce(new Vector2(m_cow_dir.x * m_beamed_last_directions, m_cow_dir.y));
                    }
                }
            }
        }
        else if (m_catched_array != null && m_catched_array.Count > 0)
        {
            Cow cow = null;
            for (int i = 0; i < m_catched_array.Count; i++)
            {
                Cow lCow = (Cow)m_catched_array [i];
                if (cow == null || cow.transform.localPosition.y > lCow.transform.localPosition.y)
                {
                    cow = lCow;
                }
            }
            cow.setCowState(CowState.Flying);
        }
    }