Exemplo n.º 1
0
    /// <summary>
    /// Enables the Player to light up torches (or possibly other objects).
    /// </summary>
    /// <param name="arg">Object to light up.</param>
    public void Light(string arg)
    {
        //Set MovementHappening to true to make sure that the Player disabled darkness before losing health
        MovementHappening = true;
        GameObject hit = GetRaycastObject("Torch");

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing here to light");
            MovementHappening = false;
            return;
        }
        if (arg.ToUpper() == "TORCH")
        {
            if (hit.transform.tag == "Torch")
            {
                StartCoroutine(RotateAndInteract(hit));
                return;
            }
            else
            {
                DialogueScript.ErrorText("That's not a torch.");
            }
        }
        else
        {
            DialogueScript.ErrorText("You can't light that.");
        }
        MovementHappening = false;
    }
Exemplo n.º 2
0
 public void Cleave()
 {
     if (OnCooldown("cleave"))
     {
         return;
     }
     lastMove = "Cleave";
     //Do a vertical cleave for x damage
     if (PlayerPrefs.GetInt("Level") < 4)
     {
         DialogueScript.ErrorText("You're not quite sure how to do that yet.");
         DialogueScript.ErrorText("Maybe after a couple more battles");
         DialogueScript.CombatTextEnemy("You space out a bit, and the enemy strikes!");
         ChangeTurn(null, null);
         return;
     }
     if (chargeAmount <= 0)
     {
         DialogueScript.GameInformationText("You fill up with rage.");
         DialogueScript.GameInformationText("Next turn you can do the attack!");
         EndOfTurn("Cleave", 1, 0);
         chargeAmount = 3;
     }
     else
     {
         chargeAmount = 0;
         DialogueScript.GameInformationText("You strike the enemy with a heavy hit!");
         EndOfTurn("Cleave", 3, Random.Range(PlayerPrefs.GetInt("Strength") + chargeAmount, PlayerPrefs.GetInt("Strenght") + PlayerPrefs.GetInt("Level") + chargeAmount));
     }
 }
Exemplo n.º 3
0
 public void CounterAttack()
 {
     if (OnCooldown("counterattack"))
     {
         return;
     }
     if (PlayerPrefs.GetInt("Level") < 6)
     {
         DialogueScript.ErrorText("Oh, that is something you havn't learnt to do yet.");
         DialogueScript.CombatTextEnemy("The enemy sees an opening, and stikes!");
         ChangeTurn(null, null);
         return;
     }
     if (lastMove != "ShieldBlock")
     {
         DialogueScript.ErrorText("You need to block first!");
     }
     else
     {
         int cm = PlayerPrefs.GetInt("Level");
         if (cm > 3)
         {
             cm = 3;
         }                                 //cant do more than three times stored damage
         DialogueScript.GameInformationText("You see an opening, and strike!");
         EndOfTurn("CounterAttack", 1, Random.Range(storedDamage, storedDamage * cm));
     }
     //Do a quick attack for x damage after blocking an attack
     lastMove     = "CounterAttack";
     storedDamage = 0;
 }
Exemplo n.º 4
0
    public void StrainSlash()
    {
        if (OnCooldown("strainslash"))
        {
            return;
        }
        lastMove = "StrainSlash";
        if (PlayerPrefs.GetInt("Level") < 8)
        {
            DialogueScript.ErrorText("While you grasp the consept, you still don't know how to do it");
            DialogueScript.CombatTextEnemy("The enemy sees your uncertainty, and strikes!");
            ChangeTurn(null, null);
            return;
        }

        if (PlayerPrefs.GetInt("Strength") > 5)
        {
            DialogueScript.GameInformationText("You strain yourself in the attack!");
            DialogueScript.GameInformationText("You feel weaker.");
            PlayerPrefs.SetInt("Strenght", PlayerPrefs.GetInt("Strenght") - 1);             //-1 permanent strenght
            EndOfTurn("StrainSlash", 3, Random.Range((PlayerPrefs.GetInt("Strength") + 1) * 2,
                                                     (PlayerPrefs.GetInt("Strenght") + 1 + PlayerPrefs.GetInt("Level")) * 2));
        }
        else
        {
            DialogueScript.GameInformationText("You are not strong enough for this anymore.");
            DialogueScript.GameInformationText("Try a different attack");
        }
    }
Exemplo n.º 5
0
    private void Kick(string arg, string arg2)
    {
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            if (arg == null)
            {
                DialogueScript.GameInformationText("You kick out wildly into the air. Not sure that is helping anyone.");
                return;
            }
            DialogueScript.ErrorText("Somehow, you fail to kick anything.");
            return;
        }
        if (arg2 == null)
        {
            if (string.Equals(hit.transform.gameObject.tag, arg, StringComparison.CurrentCultureIgnoreCase))
            {
                DialogueScript.GameInformationText("You kick the " + arg + ". Did it help you?");
                return;
            }
        }
        if (arg.ToUpper() == "THE")
        {
            if (string.Equals(hit.transform.gameObject.tag, arg, StringComparison.CurrentCultureIgnoreCase))
            {
                DialogueScript.GameInformationText("You kick " + arg + " " + arg2 + ". Did it help you?");
                return;
            }
        }
        else
        {
            DialogueScript.ErrorText("What exactly are you trying to kick?");
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Shows the help.
 /// </summary>
 /// <param name="arg"></param>
 /// <param name="arg2"></param>
 public void ShowHelp(string arg, string arg2)
 {
     //TODO: Currently this is being done both in InputValidation.cs and here. Simplify?
     string[] panelNames = { "MOVE", "TUTORIAL", "INTERACT", "COMMAND", "COMBAT" };
     //Check if the Player gave any additional input
     CheckString("Help", arg);
     //If not, send "null" to the InterfaceScript so that will show the help panel
     if (NoInput)
     {
         InterfaceScript.ShowHelp("null");
         //InterfaceScript.ActivateInput();
         return;
     }
     //If there are arguments, it should either be "with" + a valid help opion
     // or just a valid help option.
     if (arg.Equals("with", StringComparison.CurrentCultureIgnoreCase) &&
         CommandListScript.AllCommandsList.Any(s => s.Equals(arg2, StringComparison.CurrentCultureIgnoreCase)))
     {
         InterfaceScript.ShowHelp(arg2);
         return;
     }
     if (CommandListScript.AllCommandsList.Any(s => s.Equals(arg, StringComparison.CurrentCultureIgnoreCase)) ||
         panelNames.Any(s => s.Equals(arg, StringComparison.CurrentCultureIgnoreCase)))
     {
         InterfaceScript.ShowHelp(arg);
         return;
     }
     //Or if no valid command was given as an argument, let the Player know.
     else
     {
         DialogueScript.ErrorText("No help for that.");
     }
 }
Exemplo n.º 7
0
    /// <summary>
    /// Pulls the wall.
    /// </summary>
    /// <param name="arg">The argument.</param>
    /// <param name="length">How far to pull</param>
    public void Pull(string arg, string length)
    {
        if (arg.All(char.IsDigit))
        {
            DialogueScript.ErrorText("It'd be nice if you specified what you want to pull.");
            return;
        }
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing in front of you.");
            return;
        }
        if (arg.ToUpper() == "WALL" && hit.tag == "PushableWall")
        {
            int pushDistance;
            if (length == null)
            {
                pushDistance = 100;
            }
            else
            {
                pushDistance = int.Parse(length);
            }

            StartCoroutine(PullTheWall(hit, pushDistance));
        }
    }
Exemplo n.º 8
0
 internal bool OnCooldown(string function)
 {
     if (CooldownList.Any(s => s.Equals(function, StringComparison.CurrentCultureIgnoreCase)))
     {
         DialogueScript.ErrorText("You're currently cooling down from using that ability.");
         InterfaceScript.ActivateInput();
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Look at something. First argument (currently) needs to be "at". Calls the Examine command.
 /// </summary>
 /// <param name="arg">Players first argument, needs to be "at"</param>
 /// <param name="obj">The object to look at.</param>
 public void Look(string arg, string obj)
 {
     if (arg != null && obj != null)
     {
         if (arg.ToUpper() != "AT")
         {
             return;
         }
         MovementHappening = true;
         Examine(obj);
     }
     else
     {
         DialogueScript.ErrorText("Peering into the distance, you can see shadows.");
     }
 }
Exemplo n.º 10
0
    /// <summary>
    /// Examine an object. Distance is up to 9 meters (5 blocks ahead).
    /// </summary>
    /// <param name="arg">Object to examine</param>
    void Examine(string arg)
    {
        //TODO: Add option to examine items on floor that are not showing, i.e. weapon.
        RaycastHit hit;

        if (Physics.Raycast(PlayerScript.PlayerCamera.transform.position, transform.forward, out hit, 9))
        {
            //Find if the Player is using a valid word, then place that list into a new list.
            List <string> nameList = new List <string>();
            foreach (List <string> list in ItemNameListScript.AllItemNamesList)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (!string.Equals(list[i], arg, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }
                    nameList = list;
                }
            }
            //If nothing was placed in the list, i.e. the player didn't use a valid command
            if (nameList.Count == 0)
            {
                DialogueScript.ErrorText("I'm not sure what you want to examine...");
                return;
            }
            //Go through the now filled up list to make sure that the tag matches a string from it
            if (nameList.Any(s => string.Equals(s, hit.transform.gameObject.tag, StringComparison.CurrentCultureIgnoreCase)))
            {
                //Round the distance to what the Player is examining up to an int.
                int distance = (int)Math.Ceiling((double)hit.distance);
                DialogueScript.GameInformationText("You attempt to examine what's " + distance + " meters ahead.");
                StartCoroutine(ReturnExamination(hit.transform.gameObject, hit.transform.tag));
            }
            else
            {
                DialogueScript.ErrorText("I think you have the wrong name of that.");
            }
        }
        else
        {
            DialogueScript.ErrorText("There nothing ahead of you.");
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Pushes the wall
    /// </summary>
    /// <param name="arg">The argument.</param>
    /// <param name="length">Length (for pushing wall)</param>
    public void Push(string arg, string length)
    {
        //If the player wants to push a button
        if (string.Equals(arg, "button", StringComparison.CurrentCultureIgnoreCase))
        {
            GameObject hit = CommandScript.GetRaycastObject("Button");
            if (hit == null)
            {
                DialogueScript.ErrorText("There's nothing here to push.");
                return;
            }
            if (hit.transform.GetComponent <Button>().IsPressed == false)
            {
                MovementHappening = true;
                StartCoroutine(RotateAndInteract(hit));
            }
            else
            {
                DialogueScript.ErrorText("It seems like you've already pressed the button.");
            }
        }
        int pushDistance = 0;

        if (length != null && length.All(char.IsDigit))
        {
            pushDistance = int.Parse(length);
        }
        if (string.Equals(arg, "wall", StringComparison.CurrentCultureIgnoreCase))
        {
            GameObject hit = GetRaycastObject();
            if (hit.tag == "PushableWall")
            {
                if (pushDistance == 0)
                {
                    pushDistance = 100;
                }
                StartCoroutine(PushTheWall(hit, pushDistance));
            }
            else
            {
                DialogueScript.ErrorText("There's no wall there to push.");
            }
        }
    }
Exemplo n.º 12
0
    private IEnumerator Attacking()
    {
        //Make sure that if the player is still moving/rotating, this function won't start until movement is done
        while (MovementHappening)
        {
            yield return(new WaitForEndOfFrame());
        }
        //Get what is in front of the Player, if it's nothing inform and return
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing right in front of you");
            yield break;
        }
        if (hit.transform.tag == "Enemy")
        {
            GameObject.Find("Canvas").GetComponent <InterfaceScript>().ChangeCommandPool("off");
            //Get the sound from the weapon and do the initial attack
            GameObject.FindGameObjectWithTag("Weapon").GetComponent <AudioSource>().Play();
            int damageDone = PlayerPrefs.GetInt("Level") + PlayerPrefs.GetInt("Strength");
            //Give the damage to the enemy, then show it on the GUI
            hit.transform.GetComponent <EnemyScript>().CheckHealth(damageDone, "initial");
            GameObject.FindGameObjectWithTag("UI").GetComponent <InterfaceScript>().ShowDamage(damageDone);
            //Change to enemy turn
            hit.transform.GetComponent <EnemyScript>().GotAttacked(transform.gameObject);
            GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn;
            CombatCommands.Target           = hit.transform.gameObject;
            //Inform the player that they are in combat, and clear any extra commands they have used
            DialogueScript.CombatTextPlayer("You've engaged the foe in front of you!");
            ClearCommandPool();
            //Pause the torch countdown while in combat (and it's not the tutorial level)
            if (SceneManager.GetActiveScene().name != "Tutorial")
            {
                LevelScript.PauseTorches(true);
            }
        }
        else
        {
            DialogueScript.ErrorText("You can't attack that.");
        }
    }
Exemplo n.º 13
0
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Return))
     {
         if (GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyCombatTurn ||
             GameTurnController.CurrentState == GameTurnController.PlayerState.CommandChain ||
             GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyTurn)
         {
             DialogueScript.ErrorText("Can't do anything now.");
             InterfaceScript.DeActivateInput();
         }
         else if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat ||
                  GameTurnController.CurrentState == GameTurnController.PlayerState.PlayerTurn)
         {
             if (InterfaceScript.CommandInputField.text == "")
             {
                 DialogueScript.ErrorText("Nothing saved.");
                 InterfaceScript.ActivateInput();
                 return;
             }
             InterfaceScript.PlayerInput();
         }
     }
     //Make sure that if people hit their mouse buttons or escape, the input is still active
     if (Input.GetKeyUp(KeyCode.Mouse0) || Input.GetKeyUp(KeyCode.Mouse1) || Input.GetKeyUp(KeyCode.Escape))
     {
         InterfaceScript.ActivateInput();
     }
     //If Player hit the up-arrow, the last thing they wrote will be placed back into the input field
     if (Input.GetKeyUp(KeyCode.UpArrow) && (GameTurnController.CurrentState == GameTurnController.PlayerState.PlayerTurn ||
                                             GameTurnController.CurrentState == GameTurnController.PlayerState.Combat))
     {
         if (InterfaceScript.LastCommands == null)
         {
             return;
         }
         InterfaceScript.ActivateInput();
         InterfaceScript.CommandInputField.text = InterfaceScript.LastCommands;
         InterfaceScript.CommandInputField.MoveTextEnd(true);
         InterfaceScript.LastCommands = null;
     }
 }
Exemplo n.º 14
0
    /// <summary>
    /// Get the object.
    /// </summary>
    /// <param name="arg">Object to get</param>
    public void Get(string arg)
    {
        //TODO: Need to rewrite a bit to allow for the player to get the stone piece.
        GameObject hit = GetRaycastObject();

        if (arg.ToUpper() == "KEY")
        {
            if (hit == null)
            {
                DialogueScript.ErrorText("There's nothing there");
                return;
            }
            if (hit.transform.tag == "Key")
            {
                hit.transform.gameObject.GetComponent <AudioSource>().Play();
                DialogueScript.GameInformationText("You picked up a shiny key!");
                hit.transform.position = Vector3.one * 99999f;
                Destroy(hit.transform.gameObject, 2);
                MovementCommands.Forward("1");
                Keys += 1;
                InterfaceScript.InfoKeyText.text = "Your Keys: " + Keys;
            }
            else
            {
                DialogueScript.ErrorText("You can't get that");
            }
        }
        if (ItemNameListScript.StoneNameList.Any(s => s.Equals(arg, StringComparison.CurrentCultureIgnoreCase)))
        {
            if (hit.tag == "Tablet")
            {
                MovementCommands.Forward("1");
            }
        }
        else
        {
            DialogueScript.ErrorText("Get what?");
        }
    }
Exemplo n.º 15
0
    private void Lick(string arg, string arg2)
    {
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            if (arg == null)
            {
                DialogueScript.ErrorText("You lick your lips...");
                return;
            }
            else
            {
                DialogueScript.ErrorText("There's nothing in front of you, so your tongue licks your nose...");
                return;
            }
        }
        if (arg2 == null)
        {
            if (string.Equals(hit.transform.gameObject.tag, arg, StringComparison.CurrentCultureIgnoreCase))
            {
                DialogueScript.GameInformationText("You lick the " + arg + ". Taste good?");
                return;
            }
        }
        if (arg.ToUpper() == "THE")
        {
            if (string.Equals(hit.transform.gameObject.tag, arg, StringComparison.CurrentCultureIgnoreCase))
            {
                DialogueScript.GameInformationText("You lick " + arg + " " + arg2 + ". Taste good?");
                return;
            }
        }
        else
        {
            DialogueScript.ErrorText("You might not understand how licking works...");
        }
    }
Exemplo n.º 16
0
 /// <summary>
 /// Create an alias of a command and place it in a dictionary
 /// </summary>
 /// <param name="alias">The alias.</param>
 /// <param name="function">The function.</param>
 public void Alias(string alias, string function)
 {
     //First check that the alias is not already in use
     if (CommandListScript.AliasDictionary.ContainsKey(alias))
     {
         DialogueScript.ErrorText("You've already used that alias for something.");
         return;
     }
     //Also check that there's not already an alias in place for that function.
     if (CommandListScript.AliasDictionary.ContainsValue(function))
     {
         DialogueScript.ErrorText("Alias already exist.");
         return;
     }
     //Iterate through all the lists
     foreach (var list in CommandListScript.ValidCommandsList)
     {
         //Perform a reverse for loop on each list so that they can be changed
         for (int i = list.Count - 1; i > -1; i--)
         {
             //If the current string in the list is equal to the function the player want to make an alias from
             if (string.Equals(list[i], function, StringComparison.CurrentCultureIgnoreCase))
             {
                 //Add their alias to the list
                 list.Add(alias);
                 //Then add the alias to the aliaslist
                 CommandListScript.AliasDictionary.Add(alias, function);
                 //CommandListScript.AliasesList.Add(alias);
                 //Inform the player that they've saved the command
                 DialogueScript.MovementText(
                     "You create an alias out of that command.");
                 return;
             }
         }
     }
     DialogueScript.ErrorText("I'm not sure that's a thing you know how to do.");
 }
Exemplo n.º 17
0
    /// <summary>
    /// Enters the specified argument.
    /// </summary>
    /// <param name="arg">The argument.</param>
    public void Enter()
    {
        //CheckString("Enter", arg);
        GameObject hit = CommandScript.GetRaycastObject();

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing in front of you to enter");
            return;
        }
        if (hit.transform.tag == "Hatch")
        {
            if (LevelScript.ExitOpen || SceneManager.GetActiveScene().name == "Tutorial")
            {
                PlayerPrefs.SetInt("PlayedTutorial", 1);
                DialogueScript.GameInformationText("You slowly descend into the darkness.");
                GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <LevelChanger>().ChangeLevel();
                LevelFinished = true;
                return;
            }

            DialogueScript.ErrorText("You can't enter something that isn't open.");
        }
    }
Exemplo n.º 18
0
    public void Slam()
    {
        if (OnCooldown("slam"))
        {
            return;
        }
        lastMove = "Slam";
        int damageToWeapon = Random.Range(0, 2);

        if (PlayerPrefs.GetInt("Level") < 2)
        {
            DialogueScript.ErrorText("I think you're trying to do something you've not learned yet.");
            DialogueScript.CombatTextEnemy("Your confusing face makes the foe ready to strike.");
            ChangeTurn(null, null);
            return;
        }
        DialogueScript.GameInformationText("You slam your weapon hard into the enemy, stunning him!");
        if (PlayerPrefs.GetInt("StrenghtWeaponBuff") > 0 && damageToWeapon > 2)
        {
            PlayerPrefs.SetInt("StrengthWeaponBuff", PlayerPrefs.GetInt("StrenghtWeaponBuff") - damageToWeapon);
            DialogueScript.GameInformationText("Your weapon dulls in with your attack.");
        }
        EndOfTurn("Slam", 3, Random.Range(PlayerPrefs.GetInt("Strength") / 2, PlayerPrefs.GetInt("Strenght")));
    }
Exemplo n.º 19
0
    /// <summary>
    /// Move the Player forward 'steps' blocks.
    /// </summary>
    /// <param name="steps"></param>
    /// <returns></returns>
    private IEnumerator MoveForward(int steps)
    {
        for (int i = 0; i < (steps * 20); i++)
        {
            if (i % 20 == 0 || i == 0 && steps > 0)
            {
                CorrectPosition();
                GetComponent <AudioSource>().Play();
                GameObject hit         = CommandScript.GetRaycastObject();
                bool       canContinue = false;
                if (hit == null)
                {
                    continue;
                }
                switch (hit.transform.tag)
                {
                case "Tablet":
                    DialogueScript.GameInformationText("You swoop up a piece of interesting stone on your way past...");
                    hit.GetComponent <PuzzlePieceScript>().WalkedOverPiece();
                    canContinue = true;
                    break;

                case "Hatch":
                    if (LevelScript.ExitOpen)
                    {
                        DialogueScript.GameInformationText("You almost trip and fall into the black void....");
                        DialogueScript.GameInformationText("Maybe you should try to enter it instead?");
                        MovementHappening = false;
                    }
                    if (!LevelScript.ExitOpen)
                    {
                        canContinue = true;
                    }
                    break;

                case "Enemy":
                case "Door":
                case "Chest":
                case "Wall":
                case "PushableWall":
                case "Button":
                case "Torch":
                    DialogueScript.ErrorText("You can't move further that direction");
                    MetObstacle       = true;
                    MovementHappening = false;
                    break;

                case "Stairs":
                    DialogueScript.ErrorText("That'd make you walk into the ladder.");
                    DialogueScript.ErrorText("Maybe try to climb it?");
                    MetObstacle       = true;
                    MovementHappening = false;
                    break;

                case "Key":
                    DialogueScript.GameInformationText("You pick up a key as you walk past it.");
                    hit.transform.gameObject.GetComponent <AudioSource>().Play();
                    hit.transform.position = Vector3.one * 99999f;
                    Destroy(hit.transform.gameObject, 2);
                    Keys += 1;
                    InterfaceScript.InfoKeyText.text = "Your Keys: " + Keys;
                    canContinue = true;
                    break;
                }
                if (!canContinue)
                {
                    yield break;
                }
            }
            transform.Translate(0, 0, 0.1f);
            yield return(new WaitForEndOfFrame());
        }
        CorrectRotation();
        MovementHappening = false;
    }
Exemplo n.º 20
0
    /// <summary>
    /// If the GameObject is to the right or left, rotates camera that way, then back once done.
    /// </summary>
    /// <param name="hit"></param>
    /// <returns></returns>
    IEnumerator RotateAndInteract(GameObject hit)
    {
        //Set the initial direction to 0. -2 is left and 2 is right
        int direction = 0;
        //Get the relative point of the GameObject
        var relativePoint = transform.InverseTransformPoint(hit.transform.position);

        print(relativePoint);
        //If it is less than -0.2 (set to -0.2 to compensate for any slight errors)
        if (relativePoint.x < -0.1)
        {
            direction = -2;
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("LookLeft", true);
            yield return(new WaitForSeconds(2));
        }
        //Else if it's more than 0.2 rotate the other way
        else if (relativePoint.x > 0.1)
        {
            direction = 2;
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("LookRight", true);
            yield return(new WaitForSeconds(2));
        }
        //Do a switch to check what the Player is trying to rotate towards
        switch (hit.tag)
        {
        case "Torch":
            GameObject lightGameObject = hit.transform.FindChild("Point light").gameObject;
            if (lightGameObject.GetComponent <Light> ().intensity == 4)
            {
                DialogueScript.ErrorText("This light is already fully lit");
            }
            else if (lightGameObject.GetComponent <Light> ().intensity < 4)
            {
                lightGameObject.GetComponent <Light> ().intensity = 4;
                DialogueScript.GameInformationText("You've relit the torch.");
                LevelScript.RestartTorch(hit.transform.gameObject);
                lightGameObject.GetComponent <Light> ().intensity = 4;
                DialogueScript.GameInformationText("The flame seems to burn brighter again.");
            }
            yield return(new WaitForSeconds(0.5f));

            break;

        case "Button":
            //Mark the button as pressed and play the sound and animation for it
            if (GameObject.Find("Clue").GetComponent <Clue>().FoundPuzzlePiece || SceneManager.GetActiveScene().name == "Tutorial")
            {
                hit.transform.GetComponent <Button>().IsPressed = true;
                hit.transform.GetComponent <AudioSource>().Play();
                hit.transform.gameObject.GetComponentInChildren <Animation>().Play();
                //Text feedback for the Player
                DialogueScript.GameInformationText("The button creaks into the wall...");
                //Make the LevelScript check if the puzzle is done (i.e. the buttons are pressed). Only if it's not the tutorial.
                if (SceneManager.GetActiveScene().name != "Tutorial")
                {
                    LevelScript.CheckPuzzle();
                }
                else if (SceneManager.GetActiveScene().name == "Tutorial")
                {
                    GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <Tutorial>().OpenHatch();
                }
                yield return(new WaitForSeconds(0.5f));

                break;
            }
            DialogueScript.ErrorText("Trying to push the button and failing, you think you are missing something from this dungeon.");
            yield return(new WaitForSeconds(0.5f));

            break;
        }
        //Then rotate the camera back the opposite direction of previously
        if (direction == -2)
        {
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("LookLeft", false);
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("IdleFromLeft", true);
            yield return(new WaitForSeconds(2));

            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("IdleFromLeft", false);
        }
        else if (direction == 2)
        {
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("LookRight", false);
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("IdleFromRight", true);
            yield return(new WaitForSeconds(2));

            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>().SetBool("IdleFromRight", false);
        }
        //End movement so the Activation function can continue.
        MovementHappening = false;
    }
Exemplo n.º 21
0
    /// <summary>
    /// Attempts to open an object in the scene.
    /// </summary>
    /// <param name="arg">Object to be opened.</param>
    public void Open(string arg)
    {
        CheckString("Open", arg);
        if (NoInput)
        {
            return;
        }
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing in front of you.");
            return;
        }
        if (InputString == "CHEST")
        {
            if (hit.GetComponent <Chest>().HasBeenLooted)
            {
                DialogueScript.ErrorText("It's empty.");
                return;
            }
            if (Keys == 0 && hit.transform.tag == "Chest")
            {
                DialogueScript.ErrorText("You don't have a key.");
                return;
            }
            //If the Player has keys and is opening a chest, the sound and animation should play
            // to give feedback. ItemGenerator should create an item to be looted.
            //TODO: ItemGenerator doesn't provide proper items outside of some potions.
            if (Keys > 0 && hit.transform.tag == "Chest")
            {
                //while (hit.transform.forward == transform.forward) {
                //    hit.transform.Rotate(0, 0, 180);
                //}
                hit.transform.gameObject.GetComponent <AudioSource>().Play();
                hit.transform.gameObject.GetComponent <Animator>().SetBool("OpenChest", true);
                DialogueScript.GameInformationText("You open the chest.");
                hit.transform.gameObject.AddComponent <ItemGenerator>();
                hit.GetComponent <Chest>().HasBeenLooted = true;
                Keys -= 1;
                InterfaceScript.InfoKeyText.text = "Your Keys: " + Keys;
                return;
            }
            DialogueScript.ErrorText("There's no chest here to open.");
        }

        if ((InputString == "TRAPDOOR" || InputString == "HATCH") && hit.transform.tag == "Hatch")
        {
            if (LevelScript.ExitOpen)
            {
                return;
            }
            DialogueScript.GameInformationText("You can't open like this.");
            DialogueScript.GameInformationText("Maybe somewhere else.");
        }

        if (InputString == "DOOR")
        {
            if (hit.tag != "Door" && hit.tag != "CellDoor")
            {
                return;
            }
            switch (hit.transform.gameObject.tag)
            {
            case "Door":
                //Door shouldn't be opened unless Player has a key - if they do it should play the animation
                // and disable the collider so the Player can pass.
                //TODO: Fix the f*****g animation.
                if (hit.transform.gameObject.GetComponent <WoodenDoor>().IsLocked)
                {
                    if (Keys > 0)
                    {
                        DialogueScript.GameInformationText("You unlock the door with your key.");
                        hit.GetComponentInChildren <Animator>().SetBool("OpenWoodenDoor", true);
                        hit.GetComponent <Collider>().enabled = false;
                    }
                    else
                    {
                        DialogueScript.GameInformationText("You are lacking the key to open this door.");
                    }
                }
                else
                {
                    hit.GetComponentInChildren <Animator>().SetBool("OpenWoodenDoor", true);
                }
                break;

            case "CellDoor":
                if (Keys > 0)
                {
                    DialogueScript.GameInformationText("You unlock the door with your key.");
                    hit.GetComponentInChildren <Animator>().SetBool("CellDoorOpen", true);
                }
                else
                {
                    DialogueScript.GameInformationText("You are lacking the key to open this door.");
                }
                break;
            }
        }
    }
Exemplo n.º 22
0
    /// <summary>
    /// Enables the Player to 'go' back up a level. Player needs to use 'Go up'.
    /// </summary>
    /// <param name="arg">Where to go</param>
    /// <param name="length">How far to go</param>
    private void Go(string arg, int length)
    {
        //First check if the Player want to use Go with a number to move
        if (arg.All(char.IsDigit))
        {
            Forward(arg);
            return;
        }
        //Otherwise check what the argument given was.
        switch (arg.ToUpper())
        {
        case "UP":
            if (length != 0)
            {
                DialogueScript.ErrorText("I don't think you need to specify how far to go up.");
                return;
            }
            //Check for stairs
            GameObject hit = GetRaycastObject("Stairs");
            //If found
            if (hit != null)
            {
                //Look at the stairs
                transform.LookAt(hit.transform.position);
                //Change level to one up
                GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <LevelChanger>().GoUp();
                //And stop the function from continuing since the enemies don't need to move when the Player changes level.
                StopCoroutine("ActivatingCommands");
            }
            else
            {
                //Otherwise inform the Player that there are no stairs next to them.
                DialogueScript.ErrorText("There are no stairs here.");
            }
            break;

        case "FORWARD":
            Forward(length.ToString());
            break;

        case "LEFT":
            if (length == 0)
            {
                length = 1;
            }
            Left(length.ToString());
            break;

        case "RIGHT":
            if (length == 0)
            {
                length = 1;
            }
            Right(length.ToString());
            break;

        case "BACK":
            if (length == 0)
            {
                length = 1;
            }
            Back(length.ToString());
            break;
        }
    }
Exemplo n.º 23
0
    /// <summary>
    /// Print out a list of argument
    /// </summary>
    /// <param name="arg">The argument.</param>
    new public void List(string arg)
    {
        CheckString("List", arg);
        if (NoInput)
        {
            return;
        }
        if (arg.ToUpper() == "ALIAS")
        {
            //Make sure that the Player has actually saved an alias
            if (CommandListScript.AliasDictionary.Count != 0)
            {
                //Inform the Player that these are the aliases created
                DialogueScript.GameInformationText(
                    "Here's a list of aliases. ");
                //Iterate through the dictionary and print out each alias alongside the function
                foreach (string s in CommandListScript.AliasDictionary.Keys)
                {
                    string value = CommandListScript.AliasDictionary[s];
                    DialogueScript.MovementText(s + " : " + value);
                }
            }
            else
            {
                DialogueScript.ErrorText("No aliases saved.");
            }
        }

        if (arg.ToUpper() == "COMMANDS")
        {
            StringBuilder builtString = new StringBuilder();
            foreach (var list in CommandListScript.ValidCommandsList)
            {
                foreach (string s in list)
                {
                    builtString.Append(s).Append(" | ");
                }
            }
            foreach (string s in CommandListScript.CommandsList)
            {
                builtString.Append(s).Append(" | ");
            }
            foreach (string s in CommandListScript.CombatCommands)
            {
                builtString.Append(s).Append(" | ");
            }
            InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15);
        }

        if (string.Equals(arg, "emotes", StringComparison.CurrentCultureIgnoreCase))
        {
            var builtString = new StringBuilder();
            foreach (string s in CommandListScript.EmoteList)
            {
                builtString.Append(s).Append(" - ");
            }
            InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15);
        }
        if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat)
        {
            InterfaceScript.ActivateInput();
        }
    }