Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        FoodSpawnTime   -= Time.deltaTime;
        MenaceSpawnTime -= Time.deltaTime;

        if (FoodSpawnTime <= 0.0f)
        {
            GameObject g    = Instantiate(FoodPrefab);
            float      xPos = Random.Range(BoxBounds.min.x, BoxBounds.max.x);
            float      zPos = Random.Range(BoxBounds.min.z, BoxBounds.max.z);
            float      yPos = BoxBounds.max.y;
            g.transform.position = new Vector3(xPos, yPos, zPos);
            BOIDManager.Get().FoodList.Add(g);
            FoodSpawnTime = FoodSpawnTimeHandler;
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            GameObject g    = Instantiate(MenacePrefab);
            float      xPos = Random.Range(BoxBounds.min.x, BoxBounds.max.x);
            float      zPos = Random.Range(BoxBounds.min.z, BoxBounds.max.z);
            float      yPos = Random.Range(BoxBounds.min.y, BoxBounds.max.y);
            g.transform.position = new Vector3(xPos, yPos, zPos);
            BOIDManager.Get().MenaceList.Add(g);
        }
    }
Ejemplo n.º 2
0
    private void TransformIntoMenace()
    {
        GameObject g = Instantiate(MenacePF);

        g.transform.position = transform.position;
        BOIDManager.Get().MenaceList.Add(g);
        BOIDManager.Get().BoidList.Remove(this);
        Destroy(this.gameObject);
    }
Ejemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.transform.tag == "Food")
     {
         BOIDManager.Get().FoodList.Remove(other.gameObject);
         Destroy(other.gameObject);
         eatenFoodCount++;
         if (eatenFoodCount >= 5)
         {
             TransformIntoMenace();
         }
     }
 }