示例#1
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;
                }
            }
        }
示例#2
0
        public void PunchUpdate()
        {
            KeyboardState keyState  = Keyboard.GetState();
            bool          keyIsDown = keyState.IsKeyDown(activationKey);

            if (!keyIsDown)
            {
                offset = VectorHelpers.MoveTowards(offset, Vector2.Zero, Time.deltaTime * restitutionSpeed);
                blob.transform.LocalPosition = currentAnchor + offset;
            }

            if (keyState.IsKeyDown(KeyBindings.LimbChangeModifier) || keyState.IsKeyDown(KeyBindings.LimbChangeAlternate))
            {
                ThrowCharge(keyIsDown);
            }
            else
            {
                if (keyWasDown && keyIsDown)
                {
                    ContinuePunch();
                }
                else if (!keyWasDown && keyIsDown)
                {
                    StartCharge();
                    StartPunch();
                }
                else if (keyWasDown && !keyIsDown)
                {
                    ReleaseCharge();
                    EndPunch();
                    chargePower = 0;
                    GameManager.Instance.SetSecondLabel(chargePower.ToString("0.00"));
                }
            }
            keyWasDown = keyState.IsKeyDown(activationKey);
        }