示例#1
0
    public void RemoveFish(int amount)
    {
        SchoolChild dObj = _roamers[_roamers.Count - 1];

        _roamers.RemoveAt(_roamers.Count - 1);
        Destroy(dObj.gameObject);
    }
示例#2
0
 public void RayCastToPushAwayFromObstaclesCheckForCollision()
 {
     RaycastHit hit = new RaycastHit();
     float d = 0.0f;
     Vector3 cacheForward = _scanner.forward;
     if (Physics.Raycast(_cacheTransform.position, cacheForward, out hit, _spawner._pushDistance, _spawner._avoidanceMask))
     {
         SchoolChild s = null;
         s = hit.transform.GetComponent<SchoolChild>();
         d = (_spawner._pushDistance - hit.distance) / _spawner._pushDistance;   // Equals zero to one. One is close, zero is far	
         if (s != null)
         {
             _cacheTransform.position -= cacheForward * _spawner._newDelta * d * _spawner._pushForce;
         }
         else
         {
             _speed -= .01f * _spawner._newDelta;
             if (_speed < .01f)
                 _speed = .01f;
             _cacheTransform.position -= cacheForward * _spawner._newDelta * d * _spawner._pushForce * 2;
             //Tell scanner to rotate slowly
             _scan = false;
         }
     }
     else
     {
         //Tell scanner to rotate randomly
         _scan = true;
     }
 }
示例#3
0
    public GameObject AddFish(SchoolChild objtemp)
    {
        if (_groupChildToNewTransform)
        {
            InstantiateGroup();
        }
        SchoolChild obj = (SchoolChild)Instantiate(objtemp);

        obj._spawner = this;
        _roamers.Add(obj);
        AddChildToParent(obj.transform);
        return(obj.gameObject);
    }
示例#4
0
 public void AddFish(int amount)
 {
     if (_groupChildToNewTransform)
     {
         InstantiateGroup();
     }
     for (int i = 0; i < amount; i++)
     {
         int         child = Random.Range(0, _childPrefab.Length);
         SchoolChild obj   = (SchoolChild)Instantiate(_childPrefab[child]);
         obj._spawner = this;
         _roamers.Add(obj);
         AddChildToParent(obj.transform);
     }
 }
示例#5
0
    public void AddFish(int amount)
    {
        _childAmount = amount;
        if (_groupChildToNewTransform) InstantiateGroup();
        for (int i = 0; i < amount; i++)
        {
            int child = Random.Range(0, _childPrefab.Length);
            SchoolChild obj = (SchoolChild)Instantiate(_childPrefab[child]);

            if (_isObjective)
                obj.gameObject.AddComponent<ObjectDetection>();

            obj._spawner = this;
            obj.gameObject.name = _childPrefab[child].name;
            _roamers.Add(obj);
            AddChildToParent(obj.transform);
        }
    }
示例#6
0
 public void RemoveFish(SchoolChild obj)
 {
     _roamers.Remove(obj);
     Destroy(obj.gameObject);
 }