Exemple #1
0
 // Start is called before the first frame update
 void Start()
 {
     text            = GameObject.FindGameObjectWithTag("Canvas").transform.Find("Dialogue Panel").Find("DialogueText").GetComponent <Text>();
     currentDialogue = GameObject.FindGameObjectWithTag("Canvas").transform.Find("Dialogue Panel").GetComponent <CurrentDialogue>();
     interaction     = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <Interaction>();
     currentQuests   = GameObject.FindGameObjectWithTag("GameData").GetComponent <CurrentQuests>();
 }
    }     //End setNPCPortrait

    //Get rid of things from the previous part of the conversation
    private void destroyOldDialogueObjects()
    {
        //Destroy old dialogue object
        if (gameObject.GetComponent <CurrentDialogue>())
        {
            currentDialogue = null;
            DestroyImmediate(gameObject.GetComponent <CurrentDialogue>());
        }//End if
        //Destroy old player choice objects
        if (GameObject.FindGameObjectWithTag("Dialogue Choice"))
        {
            foreach (GameObject oldOption in GameObject.FindGameObjectsWithTag("Dialogue Choice"))
            {
                DestroyImmediate(oldOption);
            } //End foreach
        }     //End if
        //Clear old audio clip
        if (audioSource != null)
        {
            if (audioSource.clip != null)
            {
                audioSource.clip = null;
            } //End if
        }     //End if
    }         //End destroyOldDialogueObjects
Exemple #3
0
        public string Speak(string responseText = null)
        {
            if (string.IsNullOrWhiteSpace(responseText))
            {
                return("Do you need something?");
            }

            if (CurrentDialogue == null)
            {
                var startDialogue = StartingDialogue.FirstOrDefault(x => x.TriggerText.Equals(responseText, StringComparison.CurrentCultureIgnoreCase));

                CurrentDialogue = startDialogue;
                return(startDialogue.Text);
            }

            var nextDialogue = CurrentDialogue.GetResponse(responseText);

            if (nextDialogue != null)
            {
                CurrentDialogue = nextDialogue;
                return(nextDialogue.Text);
            }

            return($"I don't understand try again.{Environment.NewLine}{CurrentDialogue.Text}");
        }
Exemple #4
0
 /// <inheritdoc />
 private void Start()
 {
     InteractControl          = Resources.Load <Control>("Managers/InputManager/Interact");
     CurrentDialogueReference = Resources.Load <CurrentDialogue>("DialogueSystem/CurrentDialogue");
     paramsInstance           = new QuestNpcParams()
     {
         NpcTransform       = transform,
         Npc                = this,
         NavAgent           = GetComponent <NavMeshAgent>(),
         Animator           = GetComponent <Animator>(),
         OriginPosistion    = transform.position,
         MovementType       = Options.MovementType,
         WanderDistance     = Options.WanderDistance,
         IdleTime           = Options.IdleTime,
         TimeLeftIdle       = Options.IdleTime,
         PatrolPoints       = Options.PatrolPoints,
         CurrentPatrolPoint = Options.StartingPatrolPoint,
         Player             = FindObjectOfType <PlayerController>(),
         Dialogue           = Options.Dialogue
     };
     stateMachine = new UStateMachine <QuestNpcParams>(paramsInstance, new Conversing(), new Idle(), new Move());
     stateMachine.SetState(typeof(Idle), paramsInstance);
     _manipulationType             = Manipulations.Normal;
     paramsInstance.NavAgent.speed = paramsInstance.MovementSpeed * TimeInfo.Data.SingleOrDefault(x => x.Type == _manipulationType).Stats.MovementModifier;
     paramsInstance.Animator.speed = TimeInfo.Data.SingleOrDefault(x => x.Type == _manipulationType).Stats.AnimationModifier;
 }
    // Start is called before the first frame update
    void Start()
    {
        PlayerMove = transform.GetComponentInParent <PlayerMove>();
        direction  = transform.right;
        foreach (Transform transform in GameObject.FindGameObjectWithTag("Canvas").GetComponentsInChildren <Transform>())
        {
            if (transform.name == "InteractText")
            {
                InteractText = transform.GetComponent <Text>();
            }

            else if (transform.tag == "DialoguePanel")
            {
                DialoguePanel   = transform.gameObject;
                currentDialogue = transform.GetComponent <CurrentDialogue>();
            }
        }
        foreach (Transform transform in GameObject.FindGameObjectWithTag("DontDestroyCanvas").GetComponentsInChildren <Transform>())
        {
            if (transform.tag == "InventoryPanel")
            {
                inventory = transform.GetComponent <Inventory>();
            }
        }

        currentQuests = GameObject.FindGameObjectWithTag("GameData").GetComponent <CurrentQuests>();

        InteractText.gameObject.SetActive(false);
        DialoguePanel.SetActive(false);
    }
Exemple #6
0
 public override void update(GameTime time, GameLocation location, long id, bool move)
 {
     LastColliding = Colliding;
     Colliding     = false;
     if (!isGlowing)
     {
         if (Name == "MoongateWax")
         {
             CurrentDialogue.Clear();
             startGlowing(Color.FromNonPremultiplied(0, 236, 222, 255), false, 0.01f);
         }
         else if (Name == "MoongateWane")
         {
             CurrentDialogue.Clear();
             startGlowing(Color.FromNonPremultiplied(236, 0, 183, 255), false, 0.01f);
         }
         else if (Name == "MoongateEbb")
         {
             CurrentDialogue.Clear();
             startGlowing(Color.FromNonPremultiplied(187, 255, 57, 255), false, 0.01f);
         }
         else if (Name == "MoongateFlow")
         {
             CurrentDialogue.Clear();
             startGlowing(Color.FromNonPremultiplied(179, 129, 255, 255), false, 0.01f);
         }
     }
     //base.update(time, location, id, move);
     updateGlow();
     Sprite.Animate(time, 0, 4, 200f);
 }
Exemple #7
0
        public void EndAct()
        {
            if (--PatienceScale <= 0)
            {
                IsGameOver = true;
                ChangeStage(GameStage.Finished);
            }
            if (IsDialogueActivated)
            {
                PatienceScale -= 2;
                var index = (int)CurrentLevel.KeyPressed - 49;
                if (index < 0 || index >= CurrentDialogue.CountAnswers)
                {
                    return;
                }
                if (CurrentDialogue.IsCorrectAnswer(index))
                {
                    ChangeStage(GameStage.Play);
                    SetKeyPressed(Keys.None);
                    CurrentDialogue = null;
                }
                else
                {
                    PatienceScale -= 20;
                    SetKeyPressed(Keys.None);
                }
                return;
            }
            var creaturesPerLocation = GetCandidatesPerLocation();

            for (var x = 0; x < CurrentLevel.Width; x++)
            {
                for (var y = 0; y < CurrentLevel.Height; y++)
                {
                    CurrentLevel.SetCreatures(x, y, SelectWinnerCandidatePerLocation(creaturesPerLocation, x, y));
                }
            }

            if (changeLevel)
            {
                changeLevel = false;
                if (IndexCurrentLevel + 1 < Levels.Length)
                {
                    IndexCurrentLevel += 1;
                    CurrentLevel       = Levels[IndexCurrentLevel];
                    PatienceScale      = CurrentLevel.Height * CurrentLevel.Width;
                }
                else
                {
                    IsGameOver = true;
                    ChangeStage(GameStage.Finished);
                }
            }

            if (PatienceScale < 0)
            {
                PatienceScale = 0;
            }
        }
Exemple #8
0
    }//End Player Speaking Display Getter

    #endregion

    private void Start()
    {
        //Create blank currentDialogue
        currentDialogue = null;
        //Get the player speaker data
        playerData = JSONHolder.getSpeaker("Player");
        //Get the portrait, name, and line objects from the UI
        for (int i = 0; i < convoHUDObject.transform.childCount; i++)
        {
            var child = convoHUDObject.transform.GetChild(i);
            switch (child.name)
            {
            case "NPC Dialogue Box":
                npcSpeakingDisplay = child.gameObject;
                for (int j = 0; j < npcSpeakingDisplay.transform.childCount; j++)
                {
                    var npcChild = npcSpeakingDisplay.transform.GetChild(j);
                    switch (npcChild.name)
                    {
                    case "Portrait": portraitNPCDisplay = npcChild.gameObject.GetComponent <Image>(); break;

                    case "Name": speakerNameNPCDisplay = npcChild.gameObject.GetComponent <TextMeshProUGUI>(); break;

                    case "Line": lineInBoxNPCDisplay = npcChild.gameObject.GetComponent <TextMeshProUGUI>(); break;
                    } //End switch
                }     //End for
                break;

            case "Player Choices":
                playerSpeakingDisplay = child.gameObject;
                var playerDialogueBox = playerSpeakingDisplay.transform.GetChild(0);
                for (int j = 0; j < playerDialogueBox.transform.childCount; j++)
                {
                    var playerChild = playerDialogueBox.transform.GetChild(j);
                    switch (playerChild.name)
                    {
                    case "Portrait":
                        portraitPlayerDisplay = playerChild.gameObject.GetComponent <Image>();
                        setPlayerPortrait(playerData.portrait);
                        break;

                    case "Name":
                        speakerNamePlayerDisplay = playerChild.gameObject.GetComponent <TextMeshProUGUI>();
                        setPlayerName(playerData.speakerName);
                        break;

                    case "Line":
                        lineInBoxPlayerDisplay = playerChild.gameObject.GetComponent <TextMeshProUGUI>();
                        setPlayerLineInBox("");
                        break;
                    } //End switch
                }     //End for
                break;
            }//End switch
        }//End for
        playerSpeakingDisplay.SetActive(false);
        npcSpeakingDisplay.SetActive(false);
    }//End Start
 protected void DialogueOptionSelected(DialogueRuntime runtime, CurrentDialogue dialogue, OptionSelection selection)
 {
     for (int i = 0; i < selectionsContainer.childCount; i++)
     {
         if (selectionsContainer.GetChild(i).name == "row_selection")
         {
             Destroy(selectionsContainer.GetChild(i).gameObject);
         }
     }
 }
    }//End startDialogue

    public void runDialogue(SetLine setLineFromDialogueChoice)
    {
        //Reset script run status
        storedLineSeenResult = false;
        finishedLine         = false;
        doneBeforeLine       = false;
        doneAfterLine        = false;
        destroyOldDialogueObjects();
        currentDialogue = gameObject.AddComponent <CurrentDialogue>();
        //Try to get the next set in the conversation
        if (setLineFromDialogueChoice == null)
        {
            set = getNextSet(conversation, set);
        }//End if
        else
        {
            set = JSONHolder.getSetFromConversation(setLineFromDialogueChoice.nextSet, conversation);
        }//End else
        //If there is no next set in the conversation, the conversation is over
        if (!conversationIsOver && set != null)
        {
            lines = getNextLines(set);
            if (set.speaker.Equals("PLAYER"))
            {
                List <SetLine> dialogueOptions = setUpDialogueOptions();
                currentDialogue.speakerIsPlayer(playerData);
                currentDialogue.setDialogueOptions(dialogueOptions);
                currentDialogue.displayDialogueOptions();
            }//End if
             //Display individual NPC line
            else if (set.speaker.Equals("NPC"))
            {
                if (lines[0].doBeforeLine != null)
                {
                    //Run a script before the line itself has run
                    runDialogueLineScript(lines[0]);
                }//End if
                //Set NPC dialogue data up
                setNPCDialogueData();
                currentDialogue.speakLine();
                StartCoroutine(WaitForLineToFinish());
            }//End else if
            else
            {
                Debug.LogError("ERROR IN SET JSON: PLAYER or NPC speaker marker in " + set.setID + " mistyped as " + set.speaker + ".");
            } //End else
        }     //End if
        else
        {
            currentDialogue.setBlipSource(null);
            PlayerInteraction playerInteraction = GameObject.FindGameObjectWithTag("Player").gameObject.GetComponentInChildren <PlayerInteraction>();
            playerInteraction.setIsInteracting(false);
        } //End else
    }     //End runDialogue
    }//End Start

    public void thisOptionWasChosen()
    {
        if (finishedTyping)
        {
            CurrentDialogue currentDialogue = GameObject.FindGameObjectWithTag("Game Manager").GetComponent <CurrentDialogue>();
            if (!currentDialogue.getOptionChosen())
            {
                StartCoroutine(TypeLineIntoBox());
            } //End if
            currentDialogue.setOptionChosen(true);
        }     //End if
    }         //End thisOptionWasChosen
Exemple #12
0
 public void OnOptionSelected(int index)
 {
     if (CurrentDialogue.CurrentNode is DialogueOptionNode)
     {
         canvas.HideOptionsBox();
         CurrentDialogue.ExecuteNextNode(index);
     }
     else
     {
         Debug.LogWarning("An option selection was received, but the current node is incompatible.");
     }
 }
Exemple #13
0
        /// <summary>
        /// Draws the contents of the stage to the screen.
        /// </summary>
        /// <param name="spriteBatch"></param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            switch (StageNumber)
            {
            case 0:
                DrawSplash(spriteBatch, "Game Start!");
                break;

            case 5:
                spriteBatch.Draw(evilQueenFace, evilQueenFacePos, null, Color.White, 0f, new Vector2(evilQueenFace.Width / 2f, evilQueenFace.Height / 2f), Sprite.SCALE, SpriteEffects.None, 0f);
                break;
            }

            CurrentDialogue?.Draw(spriteBatch);
        }
    protected void DialogueUIUpdate(DialogueRuntime runtime, CurrentDialogue dialogue)
    {
        text.text = dialogue.Text;

        selectionsContainer.gameObject.SetActive(false);

        continueButton.gameObject.SetActive(!dialogue.HasSelections);

        actorContainer.gameObject.SetActive(dialogue.Actor != null ? true : false);

        if (continueButton.gameObject.activeSelf)
        {
            continueButton.transform.Find("text").GetComponent <Text>().text = dialogue.IsEnding ? "Finish" : "Next";
        }

        if (actorContainer.gameObject.activeSelf)
        {
            actorContainer.Find("text").GetComponent <Text>().text = dialogue.Actor;
        }

        if (dialogue.HasSelections)
        {
            selectionsContainer.gameObject.SetActive(true);

            dialogue.Selections.ForEach(selection => {
                var option = GameObject.Instantiate(sampleOption);

                option.name = "row_selection";

                option.gameObject.SetActive(true);

                option.Find("text").GetComponent <Text>().text = selection.Text;

                option.GetComponent <Button>().onClick.AddListener(() => runtime.Continue(selection));

                option.SetParent(selectionsContainer);
            });
        }
    }
    }                 //End Update

    //Start a new conversation with an NPC
    public void startDialogue(GameObject npcGameObject)
    {
        currentIndex = 0;
        //Set the conversation being over variable to false
        conversationIsOver = false;
        //Get NPC speaker data
        NPCData = JSONHolder.getSpeaker(npcGameObject.GetComponent <Interactive>().getID());
        //Attach an audio source to the NPC if they don't have one already
        if (!npcGameObject.GetComponent <AudioSource>())
        {
            npcGameObject.AddComponent <AudioSource>();
        }//End if
        //Horrendous workaround
        currentDialogue = gameObject.AddComponent <CurrentDialogue>();
        currentDialogue.setBlipSource(npcGameObject.GetComponent <AudioSource>());
        DestroyImmediate(currentDialogue);
        //Find the relevant conversation
        conversation = JSONHolder.findConversation(NPCData);
        set          = null;
        lines        = new List <Line>();
        runDialogue(null);
    }//End startDialogue
Exemple #16
0
    // This is the main function called every time the story changes. It does a few things:
    // Destroys all the old content and choices.
    // Continues over all the lines of text, then displays all the choices. If there are no choices, the story is finished!
    void RefreshView()
    {
        // Remove all the UI on screen
        ClearText();
        buttonEnableCounter = 0;
        addedtoMain         = false;
        addedToSecondary    = false;

        bool first = true;

        while (CurrentDialogue.canContinue)
        {
            string text = CurrentDialogue.Continue();
            CreateContentView(text, CurrentDialogue);
        }


        if (CurrentDialogue.currentChoices.Count <= 0) // END. HANDLE THIS IN STORY
        {
            HandleSwitch(CurrentDialogue.currentText.Trim(new char[] { '@', '\n' }));
        }
    }
Exemple #17
0
 void OnClickChoiceButton(Choice choice)
 {
     CurrentDialogue.ChooseChoiceIndex(choice.index);
     RefreshView();
 }
Exemple #18
0
        /// <summary>
        /// Updates the stage.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            StageTimer       += dt;
            spawnTimer       += dt;
            vortexSpawnTimer += dt;
            CurrentDialogue?.Update(gameTime);

            if (!isOver)
            {
                base.Update(gameTime);
            }
            else
            {
                for (int i = 0; i < Players.Length; i++)
                {
                    if (Players[i] != null)
                    {
                        Players[i].Position += new Vector2(0, -5);
                    }
                }
            }

            switch (StageNumber)
            {
            case 1:
                if (StageTimer >= 5000f)
                {
                    SetStage(StageNumber + 1);
                    MediaPlayer.Play(cosmoFunk);
                }
                break;

            case 0:
                CurrentDialogue = Dialogues[0];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 2:
                CurrentDialogue = Dialogues[1];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 3:
                // spawn robots with invis
                if (spawnTimer > 700f)
                {
                    spawnTimer = 0;
                    if (rand.NextDouble() > .50 || StageTimer < 7000f)
                    {
                        SpawnInvisSinEnemy(new Vector2(-100, rand.Next(100, 500)), true);
                    }
                    else if (StageTimer > 7000f)
                    {
                        SpawnInvisSinEnemy(new Vector2(ScreenManager.GetInstance().Width + 100, rand.Next(100, 500)), false);
                    }

                    if (vortexSpawnTimer > 9000 && StageTimer > 18000f)
                    {
                        vortexSpawnTimer = 0;
                        SpawnVortexEnemy(new Vector2(-100, -100), new Vector2(200, 200), 7000f);
                        SpawnVortexEnemy(new Vector2(ScreenManager.GetInstance().Width + 100, -100), new Vector2(-200, 200), 7000f);
                    }

                    if (StageTimer > 36000f)
                    {
                        SetStage(StageNumber + 1);
                    }
                }

                break;

            case 4:
                CurrentDialogue = Dialogues[2];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 5:
                if (StageTimer >= 5000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 6:
                // summon asteroid hell upon the players
                if (spawnTimer > 70 && StageTimer < 30000)
                {
                    spawnTimer = 0;
                    Vector2   pos    = new Vector2(rand.Next(-100, ScreenManager.GetInstance().Width + 100), -90);
                    float     scale  = (float)(rand.NextDouble() * (Sprite.SCALE - 3) + 3f);
                    float     speed  = 1000 / (float)Math.Sqrt(scale);
                    Texture2D aster  = asteroidTextures[rand.Next(0, 5)];
                    float     xSpeed = (float)((rand.NextDouble() - 0.5f) * 100f);
                    Asteroid  a      = new Asteroid(Bullet.EntitySide.ENEMY, 7000f, new Vector2(xSpeed, speed))
                    {
                        Texture      = aster,
                        Position     = pos,
                        Size         = new Point((int)(aster.Width * scale), (int)(aster.Height * scale)),
                        Health       = (int)(Math.Ceiling(scale / 2)),
                        Color        = Color.White,
                        InitVelocity = new Vector2(xSpeed, speed),
                    };
                    Bullets.Add(a);
                }

                if (StageTimer > 33000)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 7:
                CurrentDialogue = Dialogues[3];

                if (CurrentDialogue.FinishedPlaying)
                {
                    Texture2D asteroidBoss = Content.Load <Texture2D>("AsteroidBoss");
                    aBoss = new AsteroidBoss(Players, 70 + GetPlayerCount() * 30)
                    {
                        Texture       = asteroidBoss,
                        Position      = new Vector2(ScreenManager.GetInstance().Width / 2, -300),
                        Size          = new Point(asteroidBoss.Width * Sprite.SCALE, asteroidBoss.Height * Sprite.SCALE),
                        BulletTexture = asteroidTextures[3],
                    };

                    AddEnemy(aBoss);
                    SetStage(StageNumber + 1);
                }
                break;

            case 8:
                if (StageTimer >= 5000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 9:
                if (aBoss != null && !aBoss.IsActive)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 10:
                CurrentDialogue = Dialogues[4];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 11:
                CurrentDialogue = Dialogues[5];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                CurrentDialogue = Dialogues[5];
                break;

            case 12:
                CurrentDialogue = Dialogues[6];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 13:
                if (StageTimer >= 5000f)
                {
                    SetStage(StageNumber + 1);
                }

                break;

            case 14:
                sBoss = new SpinnerBoss(Players, 100 + GetPlayerCount() * 50)
                {
                    Position = new Vector2(100, 100),
                };
                AddEnemy(sBoss);
                SetStage(StageNumber + 1);
                break;

            case 15:
                // SPAWN SPINNER BOSS
                if (Enemies.Count == 0)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 16:
                CurrentDialogue = Dialogues[7];
                if (CurrentDialogue.FinishedPlaying)
                {
                    isOver = true;
                    bool isReallyOver = false;
                    for (int i = 0; i < Players.Length; i++)
                    {
                        if (Players[i] != null && Players[i].Position.Y > 0)
                        {
                            isReallyOver = false;
                            break;
                        }
                        else
                        {
                            isReallyOver = true;
                        }
                    }

                    // now end level
                    if (isReallyOver)
                    {
                        ScreenManager.GetInstance().ChangeScreen(ScreenState.AFTER);
                        AfterScreen s = (AfterScreen)ScreenManager.GetInstance().CurrentScreen;
                        s.Players = Players;
                        s.Stage   = 1;
                        MediaPlayer.Stop();
                    }
                }
                break;
            }
        }
Exemple #19
0
        public override void Update(GameTime gameTime)
        {
            if (!isOver)
            {
                base.Update(gameTime);
            }
            else
            {
                for (int i = 0; i < Players.Length; i++)
                {
                    if (Players[i] != null)
                    {
                        Players[i].Position += new Vector2(0, -5);
                    }
                }
            }

            float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            StageTimer += dt;

            switch (StageNumber)
            {
            case 0:
                if (StageTimer > 5000f)
                {
                    SetStage(StageNumber + 1);
                    MediaPlayer.Play(charmPoint);
                }
                break;

            case 1:
                CurrentDialogue = Dialogues[0];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 2:
                CurrentDialogue = Dialogues[1];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 3:
                CurrentDialogue = Dialogues[2];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 4:
                CurrentDialogue = Dialogues[3];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 5:
                // evil queen entrance
                evilQueenFacePos += new Vector2(0, -1100) * (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (evilQueenFacePos.Y < -400)
                {
                    SetStage(StageNumber + 1);
                    boss = new LichBoss(Players, 200);
                    Enemies.Add(boss);
                }
                break;

            case 6:
                // first stage of evil queen
                break;

            case 7:
                // king launches a nuke
                break;

            case 8:
                // 2nd stage
                break;

            case 9:
                // 3rd stage
                break;

            case 10:
                // end game
                break;
            }

            CurrentDialogue?.Update(gameTime);
        }
Exemple #20
0
 public string GetOptionsText(IList <LanguageEnum> KnownLanguages)
 {
     return(CurrentDialogue.GetTriggerText(KnownLanguages));
 }
Exemple #21
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            float textHeight = tFont.MeasureString("H").Y;
            float opacity    = 1f;

            switch (StageNumber)
            {
            case 0:
                DrawSplash(spriteBatch, "Tutorial");
                //if (StageTimer < 600f)
                //{
                //    opacity = StageTimer / 600f;
                //}
                //else if (StageTimer > 4400f)
                //{
                //    opacity = (5000f - StageTimer) / 600f;
                //}

                //spriteBatch.Draw(blank, new Rectangle(ScreenManager.GetInstance().Width / 2, ScreenManager.GetInstance().Height / 2, ScreenManager.GetInstance().Width, 400)
                //    , null, Color.Green * opacity * 0.8f, 0f, new Vector2(0.5f, 0.5f), SpriteEffects.None, 0f);
                //if (opacity == 1)
                //{
                //    spriteBatch.DrawString(tFont, "Tutorial", new Vector2(300 + 700 * StageTimer / 5000f,
                //        ScreenManager.GetInstance().Height / 2 - textHeight / 2), Color.White, 0f, new Vector2(0, 0),
                //        1f, SpriteEffects.None, 0f);
                //}
                break;

            case 1:
                break;

            case 2:
                DrawSplash(spriteBatch, "Game Start!");
                //if (StageTimer < 600f)
                //{
                //    opacity = StageTimer / 600f;
                //}
                //else if (StageTimer > 4400f)
                //{
                //    opacity = (5000f - StageTimer) / 600f;
                //}

                //spriteBatch.Draw(blank, new Rectangle(ScreenManager.GetInstance().Width / 2, ScreenManager.GetInstance().Height / 2, ScreenManager.GetInstance().Width, 400)
                //    , null, Color.Green * opacity * 0.8f, 0f, new Vector2(0.5f, 0.5f), SpriteEffects.None, 0f);
                //if (opacity == 1)
                //{
                //    spriteBatch.DrawString(tFont, "Game Start!", new Vector2(300 + 700 * StageTimer / 5000f,
                //        ScreenManager.GetInstance().Height / 2 - textHeight / 2), Color.White, 0f, new Vector2(0, 0),
                //        1f, SpriteEffects.None, 0f);
                //}
                break;

            case 11:
                DrawSplash(spriteBatch, "Boss Fight: The Corrupted Sun");
                //if (StageTimer < 600f)
                //{
                //    opacity = StageTimer / 600f;
                //}
                //else if (StageTimer > 4400f)
                //{
                //    opacity = (5000f - StageTimer) / 600f;
                //}

                //spriteBatch.Draw(blank, new Rectangle(ScreenManager.GetInstance().Width / 2, ScreenManager.GetInstance().Height / 2, ScreenManager.GetInstance().Width, 400)
                //    , null, Color.Green * opacity * 0.8f, 0f, new Vector2(0.5f, 0.5f), SpriteEffects.None, 0f);
                //if (opacity == 1)
                //{
                //    spriteBatch.DrawString(tFont, "Boss Fight: The Corrupted Sun", new Vector2(300 + 700 * StageTimer / 5000f,
                //        ScreenManager.GetInstance().Height / 2 - textHeight / 2), Color.White, 0f, new Vector2(0, 0),
                //        1f, SpriteEffects.None, 0f);
                //}
                break;
            }

            CurrentDialogue?.Draw(spriteBatch);
        }
Exemple #22
0
        /// <summary>
        /// Updates the logic of the stage 0.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            if (!isOver)
            {
                base.Update(gameTime);
            }
            else
            {
                for (int i = 0; i < Players.Length; i++)
                {
                    if (Players[i] != null)
                    {
                        Players[i].Position += new Vector2(0, -5);
                    }
                }
            }
            float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            spawnTimer       += dt;
            spawnTimer2      += dt;
            StageTimer       += dt;
            vortexSpawnTimer += dt;

            switch (StageNumber)
            {
            case 0:
                if (StageTimer > 5000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 1:
                CurrentDialogue = Dialogues[0];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                    MediaPlayer.Play(snailChan);
                }

                break;

            case 2:
                if (StageTimer > 5000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 3:
                CurrentDialogue = Dialogues[1];

                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }

                break;

            case 4:     // 18 seconds
                if (StageTimer < 14000f)
                {
                    if (spawnTimer > 1500f)
                    {
                        spawnTimer = 0;
                        SpawnSinEnemy(new Vector2(-100, 70), true);
                    }

                    if (spawnTimer2 > 1500f)
                    {
                        spawnTimer2 = 0;
                        SpawnSinEnemy(new Vector2(-100, 500), true);
                    }
                }

                if (StageTimer > 18000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 5:
                CurrentDialogue = Dialogues[2];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }

                break;

            case 6:
                if (spawnTimer > 1500f)
                {
                    spawnTimer = 0;
                    SpawnSinEnemy(new Vector2(-100, 70), true);
                    if (rand.NextDouble() > 0.8f)
                    {
                        SpawnSinEnemy(new Vector2(ScreenManager.GetInstance().Width + 100, 100), false);
                    }
                }

                if (spawnTimer2 > 1500f)
                {
                    spawnTimer2 = 0;
                    SpawnSinEnemy(new Vector2(-100, 500), true);
                }

                if (StageTimer > 18000f)
                {
                    CurrentDialogue = Dialogues[3];
                    if (CurrentDialogue.FinishedPlaying)
                    {
                        SetStage(StageNumber + 1);
                    }
                }
                break;

            case 7:
                if (StageTimer < 25000f)
                {
                    if (spawnTimer > 1500f)
                    {
                        spawnTimer = 0;
                        SpawnSinEnemy(new Vector2(-100, 70), true);
                        if (rand.NextDouble() > 0.8f)
                        {
                            SpawnSinEnemy(new Vector2(ScreenManager.GetInstance().Width + 100, 100), false);
                        }
                    }

                    if (spawnTimer2 > 1500f)
                    {
                        spawnTimer2 = 0;
                        SpawnSinEnemy(new Vector2(-100, 500), true);
                    }

                    if (vortexSpawnTimer > 3000f)
                    {
                        SpawnVortexEnemy(new Vector2(-100, ScreenManager.GetInstance().Height / 2), new Vector2(300, 0), 8000f);
                        vortexSpawnTimer = 0;
                    }
                }

                if (StageTimer > 30000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 8:
                CurrentDialogue = Dialogues[4];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 9:
                if (StageTimer > 7000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 10:
                CurrentDialogue = Dialogues[5];
                if (CurrentDialogue.FinishedPlaying)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 11:
                if (StageTimer > 5000f)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 12:
                // Boss fight
                if (!spawnedBoss)
                {
                    Texture2D bossTexture = Content.Load <Texture2D>("TestBoss");
                    boss = new CorruptedSunBoss(Players, 100 + GetPlayerCount() * 50)
                    {
                        Texture            = bossTexture,
                        Size               = new Point(bossTexture.Width * 5, bossTexture.Height * 5),
                        BulletTexture      = blank,
                        Color              = Color.White,
                        vortexEnemyTexture = Content.Load <Texture2D>("Vortex"),
                        Blank              = blank,
                        sunBullet          = Content.Load <Texture2D>("SunBullet"),
                    };
                    AddEnemy(boss);
                    spawnedBoss = true;
                }
                else
                {
                    if ((float)boss.Health / boss.MAX_HEALTH < 0.5f)
                    {
                        CurrentDialogue = Dialogues[6];
                    }
                }

                if (Enemies.Count == 0)
                {
                    SetStage(StageNumber + 1);
                }
                break;

            case 13:
                CurrentDialogue = Dialogues[7];

                if (CurrentDialogue.FinishedPlaying)
                {
                    // end level
                    isOver = true;
                    bool isReallyOver = false;
                    for (int i = 0; i < Players.Length; i++)
                    {
                        if (Players[i] != null && Players[i].Position.Y > 0)
                        {
                            isReallyOver = false;
                            break;
                        }
                        else
                        {
                            isReallyOver = true;
                        }
                    }

                    // now end level
                    if (isReallyOver)
                    {
                        ScreenManager.GetInstance().ChangeScreen(ScreenState.AFTER);
                        AfterScreen s = (AfterScreen)ScreenManager.GetInstance().CurrentScreen;
                        s.Players = Players;
                        s.Stage   = 0;
                        MediaPlayer.Stop();
                    }
                }
                break;
            }

            if (CurrentDialogue != null)
            {
                CurrentDialogue.Update(gameTime);
            }
        }
Exemple #23
0
    }//End Current Dialogue Getter

    //Current Dialogue Setter
    public void setCurrentDialogue(CurrentDialogue currentDialogue)
    {
        this.currentDialogue = currentDialogue;
    }//End Current Dialogue Setter