Beispiel #1
0
    public void DivideRedBalls(int changeNum)
    {
        EffectManager.BreakPower();

        StopCoroutine(coroutine);
        player.transform.localScale = new Vector3(1, 1, 1);

        List <Friend>     reds = Friend.redBalls;
        RaycastHit        hit;
        int               redsCount   = reds.Count;
        List <GameObject> changeBalls = new List <GameObject>();

        for (int i = 0; i < redsCount; i++)
        {
            if (!reds[i].gameObject.activeSelf)
            {
                // UnityEngine.Debug.LogFormat("i={0},是隐藏的,循环总数{1}", i,redsCount);
                //Vector3 pos = new Vector3(Random.Range(rangeMin, rangeMax), 0.5f, Random.Range(rangeMin, rangeMax));
                Vector3 dir = new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f));
                if (Physics.Raycast(player.transform.position, dir, out hit, 10, 1 << 10))
                {
                    reds[i].transform.position = hit.point - dir.normalized * 0.5f;
                }
                else
                {
                    reds[i].transform.position = player.transform.position + dir * 8;
                }

                if (changeNum > 0)
                {
                    changeBalls.Add(reds[i].gameObject);
                    changeNum--;
                    UnityEngine.Debug.Log("changeNum--;");
                }
                else
                {
                    EffectManager.GenerateTrail(player.transform, reds[i].transform, 5, 1);
                    StartCoroutine(waitRedAppear(reds[i].gameObject, 1));
                }
            }
        }

        for (int i = 0; i < changeBalls.Count; i++)
        {
            changeBalls[i].GetComponent <Friend>().ChangeSelf();

            EffectManager.GenerateTrailBlack(player.transform, changeBalls[i].transform, 5, 1);

            StartCoroutine(waitGeneraterEnmey(changeBalls[i].transform.position, 1));
        }



        //UnityEngine.Debug.Log("解除合体,主角" + player.transform.localScale);
        player.GetComponent <Player>().union = false;
    }