Пример #1
0
    public override void _Process(float delta)
    {
        if (!IsCPU)
        {
            Camera.GlobalPosition = KinematicBody.GlobalPosition;
            Vector2 vector = Vector2.Zero;

            if (Input.IsActionPressed("ui_up"))
            {
                vector.y -= 1;
            }
            if (Input.IsActionPressed("ui_down"))
            {
                vector.y += 1;
            }
            if (Input.IsActionPressed("ui_left"))
            {
                vector.x -= 1;
            }
            if (Input.IsActionPressed("ui_right"))
            {
                vector.x += 1;
            }

            vector = vector.Normalized();
            if (vector.Length() > 0)
            {
                DirectionFacing  = new Vector2(vector);
                IsAutoNavigating = false;
                AnimatedSprite.Play();
            }
            else if (!IsAutoNavigating)
            {
                AnimatedSprite.Stop();
            }
            KinematicBody.MoveAndSlide(vector * MovementSpeed);
        }

        if (IsAutoNavigating)
        {
            Vector2 vector = DestinationPosition - KinematicBody.GlobalPosition;
            if (vector.Length() > 50)
            {
                vector = vector.Normalized();
                KinematicBody.MoveAndSlide(vector * MovementSpeed);
                AnimatedSprite.Play();
            }
            else
            {
                IsAutoNavigating = false;
                AnimatedSprite.Stop();
            }
        }

        if (CurrentState != State.Borrow)
        {
            foreach (Unit unit in Units.ToArray())
            {
                unit.SetLeaderPosition(KinematicBody.GlobalPosition);
                unit.SetFollowing();
            }
        }

        switch (CurrentState)
        {
        case State.Idle:
            Highlight.Hide();
            DebugLabel.Hide();
            break;

        case State.Hover:
            Highlight.Show();
            DebugLabel.Hide();
            break;

        case State.Defeated:
            DebugLabel.Show();
            break;
        }

        Duration += delta;
        if (Name == "EnemyLeader1")
        {
            if (TutorialStep == 0 && Duration > 0.5)
            {
                DialogLabel.Text = "Prince, is that really you?";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && CurrentState == State.Borrow && Duration > 0.2)
            {
                DialogLabel.Text = "Borrow at ease!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 2 && CurrentState == State.Borrow && Duration > 3)
            {
                DialogLabel.Text = "Pick my units, then press done.";
            }
            else if (TutorialStep == 2 && CurrentState == State.Idle && Duration > 0.2 && GetUnits().Count == 0)
            {
                DialogLabel.Text = "Excellent!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 2 && CurrentState == State.Idle && Duration > 0.2 && GetUnits().Count > 0)
            {
                DialogLabel.Text = "Borrow my units, you'll need them.";
                Duration         = 0;
            }
            else if (TutorialStep == 3 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 4 && Duration > 0.5)
            {
                DialogLabel.Text = "Be wise borrowing units...";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 5 && Duration > 3)
            {
                DialogLabel.Text = "... or you'll be deep in debt!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 6 && Duration > 3)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 7 && Duration > 0.5)
            {
                DialogLabel.Text = "Interest rates are high around here...";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 8 && Duration > 4)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }
        else if (Name == "EnemyLeader2")
        {
            if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300)
            {
                DialogLabel.Text = "Hey, look it's the prince!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (CurrentState == State.Hover && Debt > 0)
            {
                DialogLabel.Text = "Repay my debt, to fight with honor!";
                TutorialStep     = 20;
                Duration         = 0;
            }
            else if (TutorialStep == 20 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }
        else if (Name == "EnemyLeader3")
        {
            if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300)
            {
                DialogLabel.Text = "If you borrow my men...";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && Duration > 2)
            {
                DialogLabel.Text = "... then you better pay me back";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 2 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (CurrentState == State.Borrow && TutorialStep < 10)
            {
                DialogLabel.Text = "Take what you need.";
                TutorialStep     = 10;
                Duration         = 0;
            }
            else if (TutorialStep == 10 && Duration > 3)
            {
                DialogLabel.Text = "I expect them back later.";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 11 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (CurrentState == State.Hover && Debt > 0)
            {
                DialogLabel.Text = "Repay my debt, to fight with honor!";
                TutorialStep     = 20;
                Duration         = 0;
            }
            else if (TutorialStep == 20 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }
        else if (Name == "EnemyLeader4")
        {
            if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300)
            {
                DialogLabel.Text = "This isn't amateur hour!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }
        else if (Name == "EnemyLeader5")
        {
            if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300 && PlayerLeader.GetUnits().Count <= 4)
            {
                DialogLabel.Text = "That's all you got?";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300 && PlayerLeader.GetUnits().Count > 4)
            {
                DialogLabel.Text = "You seem like a worthy opponent!";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }

        else if (Name == "EnemyLeader6")
        {
            if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300 && PlayerLeader.GetUnits().Count <= 4)
            {
                DialogLabel.Text = "I'll lend you some.";
                TutorialStep    += 1;
                Duration         = 0;
            }
            else if (TutorialStep == 0 && PlayerLeader.GetKinematicGlobalPosition().DistanceTo(GetKinematicGlobalPosition()) < 300 && PlayerLeader.GetUnits().Count > 4)
            {
                DialogLabel.Text = "I've been waiting to fight you!";
                TutorialStep     = 1;
                Duration         = 0;
            }
            else if (TutorialStep == 1 && Duration > 2)
            {
                DialogLabel.Text = "";
                TutorialStep    += 1;
                Duration         = 0;
            }
        }
    }
Пример #2
0
 public Vector2 GetPlayerGlobalPosition()
 {
     return(PlayerLeader.GetKinematicGlobalPosition());
 }