Exemple #1
0
    void SpawnActor(Vector3 position)
    {
        int randVal = (int)(Random.value * 100);
        int index   = randVal % EnemyList.Length;

        GameObject newActor = Instantiate(EnemyList[index]) as GameObject;

        //position.y += newActor.transform.localScale.y;
        newActor.transform.position = position;

        SimpleMovement moveScript = newActor.GetComponent("SimpleMovement") as SimpleMovement;

        if (moveScript == null)
        {
            throw new MissingComponentException("TODO: Refactor MoveScripts.");
        }
        moveScript.SetTarget(new Vector3(0, 0, 0));

        if (WantGoofyRandomness)
        {
            // Just doing some goofy randomization.
            float rand = Random.Range(0, 2);
            Debug.Log("RAND:" + rand);
            if (rand > 0)
            {
                GoofyRandomization(3, newActor);
            }
        }
    }