Пример #1
0
    private IEnumerator MoveSpider(float duration)
    {
        yield return(new WaitForSeconds(duration));

        _canMove = true;
        if (!_spider.activeSelf || _pathListToPlayer.Count <= 0)
        {
            yield break;
        }

        _spiderPosition = _pathListToPlayer[Mathf.Clamp(_currentPathIndex, 0, _pathListToPlayer.Count - 1)];

        IntVector2 oldPosition = new IntVector2((int)_spider.transform.position.x, (int)_spider.transform.position.y);

        _spider.transform.position = new Vector2(_spiderPosition.x, _spiderPosition.y);

        _levelManager.ClearCell(oldPosition);
        _levelManager.SetSpiderCell(_spiderPosition);

        _currentPathIndex++;
        //_canMove = true;

        if (_currentPathIndex >= _pathListToPlayer.Count)
        {
            _isSpiderReachedDestination = true;
        }
    }
Пример #2
0
    public void DestroyCentipedeBodyPart(IntVector2 position)
    {
        if (_centipedeHead != null)
        {
            GameObject headGameObject = _centipedeHead.GetHeadGameObject();
            IntVector2 headPosition   = new IntVector2((int)headGameObject.transform.position.x, (int)headGameObject.transform.position.y);
            if (headPosition == position)
            {
                Object.Destroy(headGameObject);
                _levelManager.ClearCell(position);

                AssignNewHead();
            }
        }

        //Debug.LogWarning("list count = " + _centipedeTailsList.Count);
        for (int i = _centipedeTailsList.Count - 1; i >= 0; i--)
        {
            //Debug.Log("index = " + i);
            CentipedeTail tail           = _centipedeTailsList[i];
            GameObject    tailGameObject = tail.GetTailObject();
            IntVector2    tailPosition   = new IntVector2((int)tailGameObject.transform.position.x, (int)tailGameObject.transform.position.y);
            if (tailPosition == position)
            {
                _levelManager.ClearCell(position);
                if (i == _centipedeTailsList.Count - 1)
                {
                    Object.Destroy(tailGameObject);
                    _centipedeTailsList.Remove(tail);
                }
                else
                {
                    Object.Destroy(tailGameObject);
                    DivideCentipedeFrom(tail, tailPosition);
                }
                break;
            }
        }
    }
    public void DamageMushroomAtPosition(IntVector2 position, int damage)
    {
        Mushroom mushroom = _mushroomsList.Find(mushRoom => mushRoom.GetCellPosition() == position);

        if (mushroom == null)
        {
            Debug.LogError("Mushroom not found === ");
            return;
        }

        bool isDead = mushroom.Damage(damage);

        if (isDead)
        {
            _mushroomsList.Remove(mushroom);
            _levelManager.ClearCell(position);
            _scoreManager.Score += 10;
        }
    }
Пример #4
0
 public void ResetSpiderPosition(IntVector2 position)
 {
     _levelManager.ClearCell(position);
     SpawnSpider();
 }