Ejemplo n.º 1
0
    public void SpawnEnemies(int numSpawn, float x, float y, float z, float range = -1)
    {
        npcs       = null;
        numToSpawn = numSpawn;
        npcs       = new NPCUnit[numToSpawn];
        for (int i = 0; i < numToSpawn; i++)
        {
            GameObject go = (GameObject)Instantiate(enemyPrefab);

            go.transform.position = new Vector3(x, y, z);

            NPCMovementController   npc  = go.GetComponent <NPCMovementController>();
            NPCAppearanceController npcA = go.GetComponent <NPCAppearanceController>();

            if (npcA != null)
            {
                npcA.Init();
            }

            if (npc != null)
            {
                //Naming for ease
                npc.gameObject.name = i.ToString("0000");                 //assuming we have less than 10,000
                npcs[i]             = npc.GetComponent <NPCUnit>();

                //Movement update
                if (range > 0)
                {
                    npc.maxDistance            = range;
                    npc.randomPositionGenerate = true;
                }
            }
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     if (player == null)
     {
         player = GameObject.FindGameObjectWithTag("Player");
     }
     appearancreController = gameObject.GetComponent <NPCAppearanceController> ();
     appearancreController.Init();
 }
Ejemplo n.º 3
0
    void Start()
    {
        //Place this snowman somewhere toward the ends of the world
        float x = Random.Range(edgeOfWorld * 0.75f, edgeOfWorld);
        float z = Random.Range(edgeOfWorld * 0.75f, edgeOfWorld);

        x *= (Random.Range(0, 2) == 0) ? -1: 1;
        z *= (Random.Range(0, 2) == 0) ? -1: 1;

        transform.position = new Vector3(x, 2, z);

        npcMovementController.Init();
        npcAppearanceController.Init();
        SetGoal(LessonOneGenerator.goal);
    }