Beispiel #1
0
    public void Update(float dt, TransmitionEmitterPool emittersPool, SpreadNewsPerson[] spammedPersons)
    {
        Decrease(GameBalanceConst.GlobalCensorAbsorption * dt);

        List <Transmition> transmitions_to_delete = new List <Transmition>();

        foreach (var transmition in _transmitions)
        {
            if (transmition.increase_timer >= 0.0f)
            {
                transmition.increase_timer -= dt;
                if (transmition.increase_timer <= 0.0f)
                {
                    Radiation += transmition.increase_value;

                    if (Radiation > GameBalanceConst.MaxIntensityToDropDown)
                    {
                        Radiation = 0;
                        SpreadNewsPerson person = GameObject.Instantiate(spammedPersons[Random.Range(0, spammedPersons.Length)]);
                        person.ShowSpreadingNews(GetPosition());
                        GameObject.Destroy(person, 2.0f);
                    }
                    else
                    {
                        if (transmition.increase_value > 0 && emittersPool.transform.childCount < GameBalanceConst.MaximumTransitions)
                        {
                            int curWidth = GameBalanceConst.SpreadSize;
                            foreach (var nearPoint in Neighbours)
                            {
                                float      timeToflight = GameBalanceConst.Asynchronous ? Random.Range(0.8f * GameBalanceConst.TransmissionsTime, 1.75f * GameBalanceConst.TransmissionsTime) : GameBalanceConst.TransmissionsTime;
                                GameObject emitter      = emittersPool.InstantiateEmitter();
                                emitter.transform.position = GetPosition();
                                LeanTween.move(emitter, nearPoint.GetPosition(), timeToflight);
                                GameObject.Destroy(emitter, timeToflight + 0.01f);
                                nearPoint.Increase(1, transmition.increase_value - GameBalanceConst.RadiationAbsorption, timeToflight);
                                curWidth -= 1;
                                if (curWidth == 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    transmitions_to_delete.Add(transmition);
                }
            }
        }

        foreach (var deleteTransmition in transmitions_to_delete)
        {
            _transmitions.Remove(deleteTransmition);
        }
    }
Beispiel #2
0
    public float Update(float dt, TransmitionEmitterPool emittersPool, SpreadNewsPerson[] spammedPersons)
    {
        float percentComplete = 0.0f;
        float radiatedPoints  = 0;

        foreach (var point in Points)
        {
            if (point.Radiation > 0.0f)
            {
                radiatedPoints += 1.0f;
            }
            point.Update(dt, emittersPool, spammedPersons);
        }

        percentComplete = (radiatedPoints / (float)Points.Count);

        return(percentComplete);
    }