void SpawningGobball()
 {
     for (int i = 0; i < numOfGobball; ++i)
     {
         // Return a random spawn point inside a circle
         //Vector3 spawnPosition = SpawningCircleRange(transform.position, 3.0f);
         Vector2 tempSpawnpoint = new Vector2(Random.Range(0, 8), Random.Range(0, 8));
         Vector3 spawnPosition  = spawnPointList.GetWaypoint((int)tempSpawnpoint.x, (int)tempSpawnpoint.y);
         // Instantiate a new gobball
         GameObject newGobball = Instantiate(gobball, spawnPosition, Quaternion.identity) as GameObject;
         // Random the type and set the sprite
         int type = Random.Range(0, sizeof(GobballSpawnerScript.GOBBALL_TYPE) - 1);
         newGobball.GetComponent <SpriteRenderer>().sprite        = gobballSprite[type];
         newGobball.GetComponent <GobballScript>().animController = animController[type];
         newGobball.GetComponent <GobballScript>().SetGobballType(type);
         // Set the coordinate of the default waypoint to the current spawn point
         newGobball.GetComponent <GobballMovementScript>().waypoint_coord = tempSpawnpoint;
         // Make it a child to a parent which governs all the gobball
         newGobball.transform.SetParent(this.gameObject.transform);
     }
 }
コード例 #2
0
        void RandomNextWaypoint()
        {
            int horizontal = Random.Range(0, 2);

            if (horizontal == 0)
            {
                waypoint_coord = new Vector2(waypoint_coord.x, Random.Range(0, 8));
            }
            else
            {
                waypoint_coord = new Vector2(Random.Range(0, 8), waypoint_coord.y);
            }
            Vector2 newWaypoint = waypointsList.GetWaypoint((int)waypoint_coord.x, (int)waypoint_coord.y);

            nextWaypoint = new Vector3(newWaypoint.x, newWaypoint.y, newWaypoint.y);
        }