Example #1
0
    void Start()
    {
        defender = Instantiate(defender);
        Utility.InitializeFish(defender, targetPos, Utility.Z);

        for (int i = 0; i < attackers.Length; ++i)
        {
            attackers [i] = new AttackerWithTarget(Instantiate(attacks [i]), targetPos);

            GameObject attacker = attackers [i].attacker;

            float x = Random.Range(-48, 50);
            float y = Mathf.Sqrt(50 * 50 - x * x);

            if (x > 0)
            {
                // if y is a value that if it was negative would not make the object more
                // than 30 degrees below the horizontal, then randomly flip the sign
                if (y < 50 * Mathf.Sin(0.523599f))
                {
                    y = (Random.value > 0.75) ? y : -y;
                }
                else if (x == 0)
                {
                    y = 50;
                }
            }

            x += targetPos.x;
            y += targetPos.y;

            Utility.InitializeFish(attacker, new Vector3(x, y, Utility.Z), Random.Range(2, 10));
            attacker.GetComponent <ActionObject> ().MakeUndestroyable();
        }
    }
    void Start()
    {
        defender = Instantiate (defender);
        Utility.InitializeFish (defender, targetPos, Utility.Z);

        for (int i = 0; i < attackers.Length; ++i) {
            attackers [i] = new AttackerWithTarget (Instantiate (attacks [i]), targetPos);

            GameObject attacker = attackers [i].attacker;

            float x = Random.Range(-48, 50);
            float y = Mathf.Sqrt(50 * 50 - x * x);

            if (x > 0)
                // if y is a value that if it was negative would not make the object more
                // than 30 degrees below the horizontal, then randomly flip the sign
                if (y < 50 * Mathf.Sin(0.523599f))
                    y = (Random.value > 0.75) ? y : -y;
            else if (x == 0)
                y = 50;

            x += targetPos.x;
            y += targetPos.y;

            Utility.InitializeFish (attacker, new Vector3 (x, y, Utility.Z), Random.Range (2, 10));
            attacker.GetComponent<ActionObject> ().MakeUndestroyable ();
        }
    }