コード例 #1
0
    public void AddObject(PoolObjectParams parameters)
    {
        int        ran      = Random.Range(0, objectList.Count);
        PoolObject enemy    = objectList[ran];
        GameObject enemyObj = enemy.gameObject;

        if (!enemyObj.activeInHierarchy)
        {
            objectList[ran].gameObject.SetActive(true);
            enemy.InitializePoolObject(parameters);
        }
    }
コード例 #2
0
    IEnumerator TimerToSpawn(PoolObjectParams par)
    {
        yield return(new WaitForSeconds(3));

        AddObject(par);
        int           ran   = Random.Range(0, objectPrefab.Length - 1);
        EnemyMovement enemy = Instantiate(objectPrefab[ran]).GetComponent <EnemyMovement>();

        enemy.InitializePoolObject(par);
        if (player.transform.position.x > 0)
        {
            par.startingPosition = new Vector3(-10, -1, 0);
        }
        else
        {
            par.startingPosition = new Vector3(10, -1, 0);
            enemy.speed          = Mathf.Abs(enemy.speed);
        }
        StartCoroutine(TimerToSpawn(par));
    }
コード例 #3
0
 public abstract void InitializePoolObject(PoolObjectParams parameters);
コード例 #4
0
 public override void InitializePoolObject(PoolObjectParams parameters)
 {
     transform.position = parameters.startingPosition;
 }