Beispiel #1
0
 private void Awake()
 {
     _tailGenerator = GetComponent <TailGenerator>();
     _input         = GetComponent <SnakeInput>();
     _tail          = _tailGenerator.Generate(_tailSize);
     SizeUpdated?.Invoke(_tail.Count);
 }
Beispiel #2
0
    private void OnBlockCollided()
    {
        Segment deleteSegment = _tail[_tail.Count - 1];

        _tail.Remove(deleteSegment);
        Destroy(deleteSegment.gameObject);
        SizeUpdated?.Invoke(_tail.Count);
    }
Beispiel #3
0
    private void OnBlockColided()
    {
        Segment deltaSegment = tail[tail.Count - 1];

        tail.Remove(deltaSegment);
        Destroy(deltaSegment.gameObject);

        SizeUpdated?.Invoke(tail.Count);
    }
Beispiel #4
0
    private void Start()
    {
        _towerBuilder = GetComponent <TowerBuilder>();
        _blocks       = _towerBuilder.Build();

        foreach (var block in _blocks)
        {
            block.BulletHit += OnBulletHit;
        }

        SizeUpdated?.Invoke(_blocks.Count);
    }
Beispiel #5
0
    private void OnBulletHit(Block hitedBlock)
    {
        hitedBlock.BulletHit -= OnBulletHit;

        _blocks.Remove(hitedBlock);

        foreach (var block in _blocks)
        {
            block.transform.position = new Vector3(block.transform.position.x, block.transform.position.y - block.transform.localScale.y, block.transform.position.z);
        }

        SizeUpdated?.Invoke(_blocks.Count);
    }
Beispiel #6
0
 private void OnBonusCollected(int bonusSize)
 {
     _tail.AddRange(_tailGenerator.Generate(bonusSize));
     SizeUpdated?.Invoke(_tail.Count);
 }
Beispiel #7
0
 private void Start()
 {
     SizeUpdated?.Invoke(tail.Count);
 }