コード例 #1
0
    IEnumerator GenerateObjects()
    {
        while (true)
        {
            var id = Random.Range(1, 3);
            foreach (SpawnObject objParam in stage.getList().Where(x => x.groupID == id))
            {
                Vector3 spawnPosition = new Vector3(
                    objParam.x,
                    0,
                    objParam.z);
                Quaternion spawnRotation = Quaternion.identity;
                var        len           = objects.Count(x => x.gameObject.tag == objParam.objectTag);
                var        fieldObj      = objects.Where(x => x.gameObject.tag == objParam.objectTag).ElementAt(Random.Range(0, len));
                Instantiate(fieldObj, spawnPosition, spawnRotation);
                switch (objParam.objectTag)
                {
                case "Island":
                    //fieldObj.GetComponent<IslandController>();
                    break;

                //case "Crowd":
                //fieldObj.GetComponent<CrowdController>().setDirection(objParam.direction);
                //fieldObj.GetComponent<CrowdController>().setBaseVelocity(new Vector3(objParam.objSpeed, 0f, ))
                default:
                    break;
                }

                int coursedFrame = 0;
                while (coursedFrame < objParam.nextSpawFrame)
                {
                    coursedFrame += (int)ObjectManager.Instance.baseSpeedOfZ / (-10);;
                    yield return(new WaitForEndOfFrame());
                }
                //yield return StartCoroutine(WaitForFrameWithAccel(objParam.nextSpawFrame));
                //yield return new WaitForSeconds(objParam.nextSpawnSpan);
                //yield return StartCoroutine(WaitForSecondsWithAccel(objParam.nextSpawnSpan));
            }
        }
    }