예제 #1
0
    void Spawn()
    {
        GameObject foodSpawned = FoodObjectPooling.Spawn(objectPrefab);

        xSpawn  = Random.Range(-21, 21); //randomly generate x position between 2 numbers
        ySpawn  = Random.Range(-21, 21); //randomly generate y position between 2 numbers
        inArena = false;                 //obj coord is not in arena

        if ((borderTop.transform.position.y > ySpawn && borderBottom.transform.position.y < ySpawn) && (borderLeft.transform.position.x < xSpawn && borderRight.transform.position.x > xSpawn))
        {
            //check if the generated coord is inside the arena
            inArena = true; //obj coord is not in area

            foodSpawned.transform.position = new Vector3(xSpawn, ySpawn);
        }
    }
예제 #2
0
    IEnumerator InitializePool()
    {
        if (!isObjectPooled)
        {
            UIGameController.Instance.ShowNotificationMessage(LanguageManager.Instance.GetMessage("LOA0012"));
            yield return(new WaitForSeconds(0.1f));

            foodPool = FoodObjectPooling.Instance;

            fishPool = FishObjectPooling.Instance;

            predatorPool = PredatorObjectPooling.Instance;

            isObjectPooled = true;
        }
        yield return(null);

        GameController.Instance.StartListeningForSocketUpdates();
    }