Exemple #1
0
    public void TickUpdate()
    {
        if (!Updating)
        {
            return;
        }
        if (!_started && !GameOver)
        {
            if (!NextLevelStart)
            {
                StartAction();
            }
            else
            {
                NextLevelStart = false;
            }
            _levelSpawner.StartAction();
            _started = true;
        }
        Ticks++;
        TickActionPerm();
        TickAction();
        Pattern.Instance.TickUpdate();
        UnitedTint.TickUpdate();
        if (Spawning)
        {
            _levelSpawner.TickUpdate();
        }
        var units  = _grid.GetAllUnits();
        var ticked = false;

        var c = 0;

        for (var i = 0; i < units.Count; i++)
        {
            var unit = units[i];
            unit.TickAnimations();
            if (unit.Position.IntX() == Player.Instance.Position.IntX() + 1 ||
                unit.Position.IntX() == Player.Instance.Position.IntX() - 1)
            {
                units[i] = units[c];
                units[c] = unit;
                c++;
            }
        }
        var limit = 500;

        while (limit > 0)
        {
            limit--;
            ticked = false;
            for (var i = 0; i < units.Count; i++)
            {
                var unit   = units[i];
                var result = unit.TickUpdate();
                if (!result)
                {
                    continue;
                }
                ticked = true;
                units.RemoveAt(i);
                i--;
            }
            if (!ticked || units.Count == 0)
            {
                break;
            }
        }
        if (limit == 0)
        {
            Debug.LogWarning("Tick update cycle limit reached");
        }
    }
Exemple #2
0
 private void Awake()
 {
     Instance   = this;
     _frontTint = FrontLine.GetComponent <UnitedTint>();
     _backTint  = BackLine.GetComponent <UnitedTint>();
 }
Exemple #3
0
 private void Awake()
 {
     _sr = GetComponent <SpriteRenderer>();
     _ut = GetComponent <UnitedTint>();
 }