Esempio n. 1
0
        private Vector3 GetNextPosition(GameObject gameObject, BossClass bossClass, IReadOnlyList <Transform> wayPoints)
        {
            if (gameObject.transform.position.Equals(wayPoints[wayPointIndex].position))
            {
                wayPointIndex++;
                if (wayPointIndex == wayPoints.Count)
                {
                    wayPointIndex = bossClass.StartLoopPath;
                }
            }

            return(bossClass.BossWayPoints[wayPointIndex].position);
        }
Esempio n. 2
0
        public void StartBossPathing(BossClass bossClass, GameObject gameObject)
        {
            wayPointIndex = 0;

            gameObject.transform.position = bossClass.BossWayPoints[0].position;

            gameObject.UpdateAsObservable()
            .Select(_ => GetNextPosition(gameObject, bossClass, bossClass.BossWayPoints))
            .Subscribe(nextPosition => GoToNextPosition(gameObject, bossClass.MoveSpeed, nextPosition))
            .AddTo(_disposables);

            gameObject.OnDisableAsObservable()
            .Subscribe(_ => _disposables.Clear());
        }
Esempio n. 3
0
        public void StartBoss(BossClass bossClass)
        {
            _bossClass             = bossClass;
            _transform.localScale  = bossClass.Size;
            _spriteRenderer.sprite = bossClass.Sprite;

            MaxHealth   = bossClass.MaxHealth;
            _halfHealth = MaxHealth / 2;

            _bossPathing.StartBossPathing(bossClass, gameObject);
            _enemyHealth.StartEnemyHealth(gameObject, MaxHealth, Death);

            Shield.StartShield(bossClass.MaxHealthShield);

            this.UpdateAsObservable()
            .Where(_ => _enemyHealth.CurrentHealth.Value < _halfHealth)
            .Subscribe(_ =>
            {
                Shield.StartShield(bossClass.MaxHealthShield);
                _disposables.Clear();
            })
            .AddTo(_disposables);
        }