Пример #1
0
    public IEnumerator GetFlockChild(float minDelay, float maxDelay)
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(minDelay, maxDelay)));

        if (_controller._flock.gameObject.activeInHierarchy && (landingChild == null))
        {
            RandomRotate();

            FlockChild fChild = null;

            for (int i = 0; i < _controller._flock._roamers.Count; i++)
            {
                FlockChild child = _controller._flock._roamers[i];
                if (!child._landing && !child._dived)
                {
                    if (!_controller._onlyBirdsAbove)
                    {
                        if ((fChild == null) && _controller._maxBirdDistance > Vector3.Distance(child._thisT.position, _thisT.position) && _controller._minBirdDistance < Vector3.Distance(child._thisT.position, _thisT.position))
                        {
                            fChild = child;
                            if (!_controller._takeClosest)
                            {
                                break;
                            }
                        }
                        else if ((fChild != null) && Vector3.Distance(fChild._thisT.position, _thisT.position) > Vector3.Distance(child._thisT.position, _thisT.position))
                        {
                            fChild = child;
                        }
                    }
                    else
                    {
                        if ((fChild == null) && child._thisT.position.y > _thisT.position.y && _controller._maxBirdDistance > Vector3.Distance(child._thisT.position, _thisT.position) && _controller._minBirdDistance < Vector3.Distance(child._thisT.position, _thisT.position))
                        {
                            fChild = child;
                            if (!_controller._takeClosest)
                            {
                                break;
                            }
                        }
                        else if ((fChild != null) && child._thisT.position.y > _thisT.position.y && Vector3.Distance(fChild._thisT.position, _thisT.position) > Vector3.Distance(child._thisT.position, _thisT.position))
                        {
                            fChild = child;
                        }
                    }
                }
            }
            if (fChild != null)
            {
                landingChild          = fChild;
                landing               = true;
                landingChild._landing = true;
                StartCoroutine(ReleaseFlockChild(_controller._autoDismountDelay.x, _controller._autoDismountDelay.y));
            }
            else if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y));
            }
        }
    }
Пример #2
0
    public IEnumerator GetFlockChild(float minDelay, float maxDelay)
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(minDelay, maxDelay)));

        if (this._controller._flock.gameObject.activeInHierarchy && this.landingChild == null)
        {
            FlockChild flockChild = null;
            for (int i = 0; i < this._controller._flock._roamers.Count; i++)
            {
                FlockChild flockChild2 = this._controller._flock._roamers[i];
                if (!flockChild2._landing && !flockChild2._dived)
                {
                    if (!this._controller._onlyBirdsAbove)
                    {
                        if (flockChild == null && this._controller._maxBirdDistance > Vector3.Distance(flockChild2._thisT.position, this._thisT.position) && this._controller._minBirdDistance < Vector3.Distance(flockChild2._thisT.position, this._thisT.position))
                        {
                            flockChild = flockChild2;
                            if (!this._controller._takeClosest)
                            {
                                break;
                            }
                        }
                        else if (flockChild != null && Vector3.Distance(flockChild._thisT.position, this._thisT.position) > Vector3.Distance(flockChild2._thisT.position, this._thisT.position))
                        {
                            flockChild = flockChild2;
                        }
                    }
                    else if (flockChild == null && flockChild2._thisT.position.y > this._thisT.position.y && this._controller._maxBirdDistance > Vector3.Distance(flockChild2._thisT.position, this._thisT.position) && this._controller._minBirdDistance < Vector3.Distance(flockChild2._thisT.position, this._thisT.position))
                    {
                        flockChild = flockChild2;
                        if (!this._controller._takeClosest)
                        {
                            break;
                        }
                    }
                    else if (flockChild != null && flockChild2._thisT.position.y > this._thisT.position.y && Vector3.Distance(flockChild._thisT.position, this._thisT.position) > Vector3.Distance(flockChild2._thisT.position, this._thisT.position))
                    {
                        flockChild = flockChild2;
                    }
                }
            }
            if (flockChild != null)
            {
                this.landingChild          = flockChild;
                this.landing               = true;
                this.landingChild._landing = true;
                if (this._controller._autoDismountDelay.x > 0f)
                {
                    base.Invoke("ReleaseFlockChild", UnityEngine.Random.Range(this._controller._autoDismountDelay.x, this._controller._autoDismountDelay.y));
                }
                this._controller._activeLandingSpots++;
            }
            else if (this._controller._autoCatchDelay.x > 0f && !this._controller.m_LandOnlyOnStart)
            {
                base.StartCoroutine(this.GetFlockChild(this._controller._autoCatchDelay.x, this._controller._autoCatchDelay.y));
            }
        }
        yield break;
        yield break;
    }
Пример #3
0
    public void InstantLand()
    {
        if (_controller._flock.gameObject.activeInHierarchy && (landingChild == null))
        {
            FlockChild fChild = null;

            for (int i = 0; i < _controller._flock._roamers.Count; i++)
            {
                FlockChild child = _controller._flock._roamers[i];
                if (!child._landing && !child._dived)
                {
                    fChild = child;
                }
            }
            if (fChild != null)
            {
                landingChild = fChild;
                landing      = true;

                landingChild._landing        = true;
                landingChild._thisT.position = _thisT.position;
                landingChild._model.GetComponent <Animation>().Play(landingChild._spawner._idleAnimation);
                StartCoroutine(ReleaseFlockChild(_controller._autoDismountDelay.x, _controller._autoDismountDelay.y));
            }
            else if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y));
            }
        }
    }
Пример #4
0
    public IEnumerator ReleaseFlockChild(float minDelay, float maxDelay)
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(minDelay, maxDelay)));

        if (_controller._flock.gameObject.activeInHierarchy && (landingChild != null))
        {
            lerpCounter = 0;
            if (_controller._featherPS != null)
            {
                _controller._featherPS.position = landingChild._thisT.position;
                _controller._featherPS.GetComponent <ParticleSystem>().Emit(UnityEngine.Random.Range(0, 3));
            }
            landing             = false;
            _idle               = false;
            landingChild._avoid = true;
            //Reset flock child to flight mode
            landingChild._damping = landingChild._spawner._maxDamping;
            landingChild._model.GetComponent <Animation>().CrossFade(landingChild._spawner._flapAnimation, .2f);
            landingChild._dived   = true;
            landingChild._speed   = 0.0f;
            landingChild._move    = true;
            landingChild._landing = false;
            landingChild.Flap();
            landingChild._wayPoint = new Vector3(landingChild._wayPoint.x, _thisT.position.y + 10, landingChild._wayPoint.z);
            yield return(new WaitForSeconds(.1f));

            if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y));
            }
            landingChild = null;
        }
    }
Пример #5
0
    public void InstantLand()
    {
        if (_controller._flock.gameObject.activeInHierarchy && (landingChild == null))
        {
            FlockChild fChild = null;

            for (int i = 0; i < _controller._flock._roamers.Count; i++)
            {
                FlockChild child = _controller._flock._roamers[i];
                if (!child._landing && !child._dived)
                {
                    fChild = child;
                }
            }
            if (fChild != null)
            {
                landingChild = fChild;
                landing      = true;
                _controller._activeLandingSpots++;
                landingChild._landing        = true;
                landingChild._thisT.position = _thisT.position + landingChild._landingPosOffset;
                landingChild._model.GetComponent <Animation>().Play(landingChild._spawner._idleAnimation);
                landingChild._thisT.Rotate(Vector3.up, Random.Range(0f, 360f));
                if (_controller._autoDismountDelay.x > 0)
                {
                    Invoke("ReleaseFlockChild", Random.Range(_controller._autoDismountDelay.x, _controller._autoDismountDelay.y));
                }
            }
            else if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y));
            }
        }
    }
Пример #6
0
 private void UpdateTimeOfDay()
 {
     if (MainLevel.Instance.IsNight())
     {
         int i = 0;
         while (i < this._roamers.Count)
         {
             FlockChild flockChild = this._roamers[i];
             if (flockChild.m_InvisibleDuration > 1f)
             {
                 this._roamers.Remove(flockChild);
                 UnityEngine.Object.Destroy(flockChild.gameObject);
                 this._childAmount--;
             }
             else
             {
                 i++;
             }
         }
     }
     else if (this._childAmount != this.m_StoredChildAmount)
     {
         this._childAmount = this.m_StoredChildAmount;
     }
 }
Пример #7
0
 public void InstantLand()
 {
     if (this._controller._flock.gameObject.activeInHierarchy && this.landingChild == null)
     {
         FlockChild x = null;
         for (int i = 0; i < this._controller._flock._roamers.Count; i++)
         {
             FlockChild flockChild = this._controller._flock._roamers[i];
             if (!flockChild._landing && !flockChild._dived)
             {
                 x = flockChild;
             }
         }
         if (x != null)
         {
             this.landingChild = x;
             this.landing      = true;
             this._controller._activeLandingSpots++;
             this.landingChild._landing        = true;
             this.landingChild._thisT.position = this._thisT.position;
             this.landingChild._model.GetComponent <Animation>().Play(this.landingChild._spawner._idleAnimation);
             this.landingChild._thisT.Rotate(Vector3.up, UnityEngine.Random.Range(0f, 360f));
             if (this._controller._autoDismountDelay.x > 0f)
             {
                 base.Invoke("ReleaseFlockChild", UnityEngine.Random.Range(this._controller._autoDismountDelay.x, this._controller._autoDismountDelay.y));
             }
         }
         else if (this._controller._autoCatchDelay.x > 0f)
         {
             base.StartCoroutine(this.GetFlockChild(this._controller._autoCatchDelay.x, this._controller._autoCatchDelay.y));
         }
     }
 }
Пример #8
0
    public void ReleaseFlockChild()
    {
        if (_controller._flock.gameObject.activeInHierarchy && (landingChild != null))
        {
            _gotcha     = false;
            lerpCounter = 0;
            if (_controller._featherPS != null)
            {
                _controller._featherPS.position = landingChild._thisT.position;
                _controller._featherPS.GetComponent <ParticleSystem>().Emit(Random.Range(0, 3));
            }
            landing             = false;
            _idle               = false;
            landingChild._avoid = true;
            //Reset flock child to flight mode
            landingChild._damping = landingChild._spawner._maxDamping;
            landingChild._model.GetComponent <Animation>().CrossFade(landingChild._spawner._flapAnimation, .2f);
            landingChild._dived   = true;
            landingChild._speed   = 0.0f;
            landingChild._move    = true;
            landingChild._landing = false;
            landingChild.Flap();
            landingChild._wayPoint = new Vector3(landingChild._wayPoint.x, _thisT.position.y + 10, landingChild._wayPoint.z);

            if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x + 0.1f, _controller._autoCatchDelay.y + 0.1f));
            }

            landingChild = null;
            _controller._activeLandingSpots--;
        }
    }
Пример #9
0
 public void RemoveChild(int amount)
 {
     for (int index = 0; index < amount; ++index)
     {
         FlockChild roamer = this._roamers[this._roamers.Count - 1];
         this._roamers.RemoveAt(this._roamers.Count - 1);
         Object.Destroy((Object)((Component)roamer).get_gameObject());
     }
 }
Пример #10
0
 public void RemoveChild(FlockChild child)
 {
     this._roamers.Remove(child);
     if (child != null)
     {
         UnityEngine.Object.Destroy(child.gameObject);
     }
     this._childAmount--;
 }
Пример #11
0
 public void RemoveChild(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         FlockChild dObj = _roamers[_roamers.Count - 1];
         _roamers.RemoveAt(_roamers.Count - 1);
         Destroy(dObj.gameObject);
     }
 }
Пример #12
0
    public void Start()
    {
        if (Object.op_Equality((Object)this._flockChild, (Object)null))
        {
            this._flockChild = (FlockChild)((Component)((Component)this).get_transform().get_parent()).GetComponent <FlockChild>();
        }
        float num = Random.Range(this._timer, this._timer * 3f);

        this.InvokeRepeating("Trigger", num, num);
    }
Пример #13
0
    public void Start()
    {
        if (_flockChild == null)
        {
            _flockChild = transform.parent.GetComponent <FlockChild>();
        }
        float timer = Random.Range(_timer, _timer * 3);

        InvokeRepeating("Trigger", timer, timer);
    }
 public void Start()
 {
     _flockChild = GetComponent <FlockChild>();
     _audio      = GetComponent <AudioSource>();
     InvokeRepeating("PlayRandomSound", Random.value + 1, 1.0f);
     if (_scareSounds.Length > 0)
     {
         InvokeRepeating("ScareSound", 1.0f, .01f);
     }
 }
Пример #15
0
 public void Start()
 {
     this._flockChild = (FlockChild)((Component)this).GetComponent <FlockChild>();
     this._audio      = (AudioSource)((Component)this).GetComponent <AudioSource>();
     this.InvokeRepeating("PlayRandomSound", Random.get_value() + 1f, 1f);
     if (this._scareSounds.Length <= 0)
     {
         return;
     }
     this.InvokeRepeating("ScareSound", 1f, 0.01f);
 }
Пример #16
0
 public void RemoveChild(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         if (this._roamers.Count > 0)
         {
             FlockChild flockChild = this._roamers[this._roamers.Count - 1];
             this._roamers.RemoveAt(this._roamers.Count - 1);
             UnityEngine.Object.Destroy(flockChild.gameObject);
         }
     }
 }
Пример #17
0
    public IEnumerator GetFlockChild(FlockChild _bird, float Delay)
    {
        yield return(new WaitForSeconds(Delay));

        if (_controller._flock.gameObject.activeInHierarchy && (landingChild == null))
        {
            if (_bird != null)
            {
                landingChild          = _bird;
                landing               = true;
                landingChild._landing = true;
            }
        }
    }
Пример #18
0
 public void AddChild(int amount)
 {
     if (_groupChildToNewTransform)
     {
         InstantiateGroup();
     }
     for (int i = 0; i < amount; i++)
     {
         FlockChild obj = (FlockChild)Instantiate(_childPrefab);
         obj._spawner = this;
         _roamers.Add(obj);
         AddChildToParent(obj.transform);
     }
 }
Пример #19
0
 public void AddChild(int amount)
 {
     if (this._groupChildToNewTransform)
     {
         this.InstantiateGroup();
     }
     for (int index = 0; index < amount; ++index)
     {
         FlockChild flockChild = (FlockChild)Object.Instantiate <FlockChild>((M0)this._childPrefab);
         flockChild._spawner = this;
         this._roamers.Add(flockChild);
         this.AddChildToParent(((Component)flockChild).get_transform());
     }
 }
Пример #20
0
 public void AddChild(int amount)
 {
     if (this._groupChildToNewTransform)
     {
         this.InstantiateGroup();
     }
     for (int i = 0; i < amount; i++)
     {
         FlockChild flockChild = UnityEngine.Object.Instantiate <FlockChild>(this._childPrefab);
         flockChild.name     = this._childPrefab.name;
         flockChild._spawner = this;
         this._roamers.Add(flockChild);
         this.AddChildToParent(flockChild.transform);
     }
 }
Пример #21
0
    public IEnumerator ReleaseFlockChild(float minDelay, float maxDelay)
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(minDelay, maxDelay)));

        if (_controller._flock.gameObject.activeInHierarchy && (landingChild != null))
        {
            lerpCounter = 0;
            if (_controller._featherPS != null)
            {
                _controller._featherPS.position = landingChild._thisT.position;
                _controller._featherPS.GetComponent <ParticleSystem>().Emit(UnityEngine.Random.Range(0, 3));
            }
            landing = false;
            idle    = false;
            landingChild.TakeOff();
            yield return(waitForSecsBuf);

            if (_controller._autoCatchDelay.x > 0)
            {
                StartCoroutine(GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y));
            }
            landingChild = null;
        }
    }
Пример #22
0
    private void UpdateTimeOfDay()
    {
        bool flag = false;

        if (MainLevel.Instance.IsNight() && this._childPrefab.m_TimeOfDay == FlockChild.TimeOfDay.Day)
        {
            flag = true;
        }
        if (!MainLevel.Instance.IsNight() && this._childPrefab.m_TimeOfDay == FlockChild.TimeOfDay.Night)
        {
            flag = true;
        }
        if (flag)
        {
            int i = 0;
            while (i < this._roamers.Count)
            {
                FlockChild flockChild = this._roamers[i];
                if (flockChild.m_InvisibleDuration > 1f)
                {
                    this._roamers.Remove(flockChild);
                    UnityEngine.Object.Destroy(flockChild.gameObject);
                    this._childAmount--;
                }
                else
                {
                    i++;
                }
            }
            return;
        }
        if (this._childAmount != this.m_StoredChildAmount)
        {
            this._childAmount = this.m_StoredChildAmount;
        }
    }