public void DestroyArm()
        {
            Node2D  targetParent    = (Node2D)GetParent().GetParent().GetParent();
            Vector2 initialPosition = GetGlobalPosition();

            GetParent().RemoveChild(this);
            targetParent.AddChild(this);

            SetGlobalPosition(initialPosition);

            Color currentColor = GetSelfModulate();

            _currentAlpha = currentColor.a;

            _armDestructionActive = true;

            SetMode(ModeEnum.Rigid);

            Vector2 randomVector = VectorHelpers.Random2D();

            AddForce(Vector2.Zero, randomVector * armDetachForce);
        }
Esempio n. 2
0
        private void UpdateBossMovement(float delta)
        {
            if (_bossReachedDestination)
            {
                _currentMovementTimer -= delta;
                if (_currentMovementTimer <= 0)
                {
                    _targetMovementPosition = VectorHelpers.Random2D() * movementRadius;
                    _bossReachedDestination = false;
                    _currentMovementTimer   = movementTimer;
                }
            }
            else
            {
                Vector2 finalPosition = VectorHelpers.MoveTowards(GetGlobalPosition(), _targetMovementPosition, movementSpeed * delta);
                SetGlobalPosition(finalPosition);

                if (_targetMovementPosition.DistanceSquaredTo(finalPosition) <= movementReachedDistance)
                {
                    _bossReachedDestination = true;
                }
            }
        }
Esempio n. 3
0
 protected Vector2 GetNewPositionForIdling() => VectorHelpers.Random2D() *explorationRadius;