示例#1
0
        public MoveResults MoveResults(Direction direction)
        {
            MoveResults       result = new MoveResults();
            PrintInstructions pi     = result.PrintInstructions;

            result.Success   = false;
            result.DoorState = DoorState(direction);

            switch (result.DoorState)
            {
            case Types.DoorState.Locked:
            case Types.DoorState.Sealed:
                break;

            case Types.DoorState.Open:
                result.Success = true;
                break;
            }

            pi.NewLine("The ")
            .Add($"{direction}", GetDoorColor(CurrentRoomPosition, direction));

            if (result.Success)
            {
                pi.Add($" door was {result.DoorState}");
            }
            else
            {
                pi.Add($" door is {result.DoorState}");
            }

            return(result);
        }
示例#2
0
    List <Card> mPlayer1Cards;                  //Player 1 list

    // Use this for initialization
    void Start()
    {
        mDeck         = DeckGO.GetComponent <Deck> ();                          //Get Ref to Deck so we can talk to it
        mPrint        = GetComponent <PrintInstructions> ();                    //Get PrintInstructions to Deck so we can talk to it
        mPlayer1Cards = new List <Card> ();                                     //Initialise the list
        mDeck.MakeDeck();                                                       //Make a Deck
        mPrint.ClearText();                                                     //Use Print to print to UI Canvas
        mPrint.AddText(string.Format("Made Deck with {0} cards", mDeck.Count)); //Some Debug
    }
示例#3
0
        public PrintInstructions PrintInstructions(string banner, string spaces = "  ")
        {
            PrintInstructions result = new PrintInstructions();
            int          row, col, rowOffset, colOffset;
            RoomPosition position;
            char         c;


            for (row = 0; row < 3; row++)
            {
                result.NewLine(spaces);

                for (col = 0; col < 7; col++)
                {
                    c        = RoomsTemplate[row][col];
                    position = RoomPosition.One;
                    // rowOffset = 0;
                    // colOffset = 0;
                    result.Add(DeligateMap[c](c, row, col, position));
                }

                for (col = 7; col < 13; col++)
                {
                    c        = RoomsTemplate[row][col];
                    position = RoomPosition.Two;
                    // rowOffset = 0;
                    colOffset = 6;
                    result.Add(DeligateMap[c](c, row, col - colOffset, position));
                }
            }

            for (row = 3; row < 5; row++)
            {
                result.NewLine(spaces);

                for (col = 0; col < 7; col++)
                {
                    c         = RoomsTemplate[row][col];
                    position  = RoomPosition.Three;
                    rowOffset = 2;
                    // colOffset = 0;
                    result.Add(DeligateMap[c](c, row - rowOffset, col, position));
                }

                for (col = 7; col < 13; col++)
                {
                    c         = RoomsTemplate[row][col];
                    position  = RoomPosition.Four;
                    rowOffset = 2;
                    colOffset = 6;
                    result.Add(DeligateMap[c](c, row - rowOffset, col - colOffset, position));
                }
            }

            return(result);
        }
示例#4
0
        public PrintInstructions MergedDescription()
        {
            PrintInstructions result = new PrintInstructions();

            if (FullyMerged())
            {
                result.NewLine("Woah! WHAT IS GOING ON???");
                result.NewLine("The transdimensional waves have aligned!");
                result.NewLine("You are experiencing the ")
                .Add(RoomInfo[RoomIdentifier.A].Character.ToString(), RoomColors[RoomIdentifier.A])
                .Add(RoomInfo[RoomIdentifier.D].Character.ToString(), RoomColors[RoomIdentifier.D])
                .Add(RoomInfo[RoomIdentifier.C].Character.ToString(), RoomColors[RoomIdentifier.C])
                .Add(RoomInfo[RoomIdentifier.B].Character.ToString(), RoomColors[RoomIdentifier.B])
                .Add(" intermodultion... Noice!");
                result.NewLine();
            }

            return(result);
        }
示例#5
0
        internal void Put(string option)
        {
            string noun = option.Substring(0, option.IndexOf(" "));
            string verb = option.Substring(option.IndexOf(" ") + 1).Trim();

            Noun nounEnum;
            Verb verbEnum;

            PrintInstructions pi = new PrintInstructions();

            if (Enum.TryParse(_textInfo.ToTitleCase(noun), out nounEnum))
            {
                if (Enum.TryParse(_textInfo.ToTitleCase(verb), out verbEnum))
                {
                    switch (nounEnum)
                    {
                    case Noun.Calculator:
                        switch (verbEnum)
                        {
                        case Verb.Away:
                            pi.Add("You turn the calculator off and put it in your pocket", ConsoleColor.DarkGreen);
                            SetCalculator(false);
                            SetPrintInstructions(pi);
                            return;
                        }
                        break;
                    }
                }
                pi.Add("You can't put the ");
                pi.Add(noun, ConsoleColor.DarkRed);
                pi.Add($" '{verb}' ", ConsoleColor.DarkRed);

                SetPrintInstructions(pi);
                return;
            }
            pi.Add("There is no ");
            pi.Add($"'{noun}' ", ConsoleColor.DarkRed);
            pi.Add("to put ");
            pi.Add(verb, ConsoleColor.DarkRed);
            SetPrintInstructions(pi);
        }
示例#6
0
        public PrintInstructions GetRoomDescription()
        {
            PrintInstructions result = new PrintInstructions();

            result.NewLine("You are in the ")
            .Add(RoomInfo[CurrentRoom.Id].Name, CurrentRoom.Color)
            .Add($" ({RoomInfo[CurrentRoom.Id].Character}) Room");

            result.NewLine();
            result.NewLine("Exits:");

            ConsoleColor northDoor = GetDoorColor(CurrentRoomPosition, Direction.North);
            ConsoleColor eastDoor  = GetDoorColor(CurrentRoomPosition, Direction.East);
            ConsoleColor southDoor = GetDoorColor(CurrentRoomPosition, Direction.South);
            ConsoleColor westDoor  = GetDoorColor(CurrentRoomPosition, Direction.West);

            result.NewLine($"    {northDoor}", northDoor).Add(" door to the North");
            result.NewLine($"    {eastDoor}", eastDoor).Add(" door to the East");
            result.NewLine($"    {southDoor}", southDoor).Add(" door to the South");
            result.NewLine($"    {westDoor}", westDoor).Add(" door to the West");
            result.NewLine();

            if (CurrentRoom.Items.Count == 0)
            {
                result.NewLine("The Room is empty");
            }
            else
            {
                result.NewLine("Items in the room");
                CurrentRoom.Items.ForEach(item =>
                {
                    result.NewLine("    ").Add(item.ItemDescription);
                });
            }

            return(result);
        }
示例#7
0
        public void SetPrintInstructions(PrintInstructions instructions = null)
        {
            PrintInstructions = _rooms.PrintInstructions("");

            Calculator calc = _game.CurrentPlayer.Inventory.Find(item =>
            {
                return(item is Calculator);
            }) as Calculator;

            if (calc != null)
            {
                if (calc.On)
                {
                    PrintInstructions.NewLine();
                    PrintInstructions.AddInstructions(calc.Display);
                }
            }

            if (instructions != null)
            {
                PrintInstructions.NewLine();
                PrintInstructions.AddInstructions(instructions);
            }
        }
示例#8
0
        internal void Unlock(string option)
        {
            PrintInstructions pi = new PrintInstructions();

            string[] options = option.Trim().Split(" ");
            string   direction;
            string   noun;

            if (options[0] == "")
            {
                pi.Add("What did you want to unlock?", ConsoleColor.Blue);
                SetPrintInstructions(pi);
                return;
            }

            if (options.Length < 2)
            {
                direction = options[0];
                noun      = "";
            }
            else
            {
                direction = options[0];
                noun      = options[1];
            }

            Noun      nounEnum;
            Direction directionEnum;

            // Check for direction
            if (Enum.TryParse(_textInfo.ToTitleCase(direction), out directionEnum))
            {
                // Check the noun
                if (Enum.TryParse(_textInfo.ToTitleCase(noun), out nounEnum))
                {
                    switch (nounEnum)
                    {
                    case Noun.Door:
                        // They have given us a valid direction and "Door"
                        if (_rooms.Lock.DoorIsLocked(_rooms.CurrentRoomPosition, directionEnum))
                        {
                            UnlockDoor();
                            return;
                            // Ok This door is locked
                        }
                        else
                        {
                            pi.Add($"The {directionEnum} is not locked", ConsoleColor.Blue);
                            SetPrintInstructions(pi);
                            return;
                        }

                    default:
                        // We dont have anything else to unlock at this direction
                        pi.Add($"There is no {directionEnum} {nounEnum} to Unlock");
                        SetPrintInstructions(pi);
                        return;
                    }
                }
                // We were given a valid direction but an invalid noun
                pi.Add($"There is no {directionEnum} {noun} to Unlock");
                SetPrintInstructions(pi);
                return;
            }
            else if (Enum.TryParse(_textInfo.ToTitleCase(direction), out nounEnum)) // Check for a noun in the direction place
            {
                switch (nounEnum)
                {
                case Noun.Door:
                    // Which door???
                    pi.Add($"Which {nounEnum} did you want to unlock?", ConsoleColor.Blue);
                    pi.NewLine($"Did you mean 'unlock [north|east|south|west] door'?", ConsoleColor.Blue);
                    SetPrintInstructions(pi);
                    return;

                case Noun.Calculator:
                    // The calculator is unlocked...
                    if (PlayerHasItem(noun.ToLower()))
                    {
                        pi.Add("The calculator is unlocked", ConsoleColor.DarkGreen);
                        SetPrintInstructions(pi);
                        return;
                    }
                    else
                    {
                        pi.Add("You don't have a calculator to unlock", ConsoleColor.DarkRed);
                        SetPrintInstructions(pi);
                        return;
                    }

                default:
                    pi.Add($"There is no '{noun}' to unlock", ConsoleColor.DarkRed);
                    SetPrintInstructions(pi);
                    return;
                }
            }
            else
            {
                // We were given an unknown noun and direction
                pi.Add($"There is no '{option}' to unlock", ConsoleColor.DarkRed);
                SetPrintInstructions(pi);
                return;
            }
        }
示例#9
0
        private void UnlockDoor()
        {
            bool trying = true;

            KeyPadLock kpl = _rooms.CurrentRoom.FindItem(KeyPadLock.KeyPadName) as KeyPadLock;

            string msg = "";

            while (trying)
            {
                // Print Title
                // Print Rooms
                // Print KeyPad

                Console.Clear();
                Log log = new Log();

                PrintInstructions calcPrintInstructions = null;

                // Print Title
                Program.TitleController.DrawHeader();

                // Print Rooms
                _rooms.PrintInstructions("").Lines.ForEach(line =>
                {
                    line.Instructions.ForEach(instruction =>
                    {
                        log.Add(instruction.Text, instruction.Foreground, instruction.Background);
                    });
                    log.Print();
                });

                Calculator calc = _game.CurrentPlayer.Inventory.Find(item =>
                {
                    return(item is Calculator);
                }) as Calculator;

                if (calc != null)
                {
                    if (calc.On)
                    {
                        calcPrintInstructions = calc.Display;
                    }
                }

                PrintInstructions unlockInstructions = new PrintInstructions().AddInstructions(kpl.Display);

                if (calcPrintInstructions != null)
                {
                    unlockInstructions.RightJoin(calcPrintInstructions);
                }

                unlockInstructions.NewLine(msg, ConsoleColor.DarkRed);

                unlockInstructions.Lines.ForEach(line =>
                {
                    line.Instructions.ForEach(instruction =>
                    {
                        log.Add(instruction.Text, instruction.Foreground, instruction.Background);
                    });
                    log.Print();
                });

                log.NewLine();

                log.Add("Enter the ");
                log.Add("code", ConsoleColor.DarkRed);
                log.Add(" to unlock the door (type 'quit' to stop trying)");
                log.Print();

                string userInput = Console.ReadLine();

                if (userInput.ToLower().Trim() == "quit")
                {
                    SetPrintInstructions(new PrintInstructions("You couldn't unlock the door", ConsoleColor.DarkRed));
                    return;
                }

                if (userInput == "use calculator")
                {
                    SetCalculator(true);
                    continue;
                }

                try
                {
                    int numVal = Int32.Parse(userInput.Substring(0, 5));

                    bool unlocked = kpl.Unlock(numVal);

                    if (unlocked)
                    {
                        Classes.Lock lk = _rooms.Lock;
                        calcPrintInstructions = new PrintInstructions();
                        calcPrintInstructions.NewLine("You Unlocked the ")
                        .Add($"{lk.KeyPadDoorDirection}", _rooms.GetDoorColor(lk.KeyPadRoomPosition, lk.KeyPadDoorDirection))
                        .Add(" DOOR!!!");
                        calcPrintInstructions.NewLine("NICE JOB!!!", ConsoleColor.Green);
                        lk.Unlock();
                        return;
                    }
                    else
                    {
                        msg = $"  '{userInput}' does not unlock the door. Good try though.";
                    }
                }
                catch (FormatException e)
                {
                    msg = $"  '{userInput}' does not unlock the door";
                }
            }
        }
示例#10
0
        public MoveResults MovePlayer(Direction direction)
        {
            MoveResults result = MoveResults(direction);

            if (result.Success)
            {
                if (FullyMerged() || Lock.Locked)
                {
                    CurrentRoomPosition = GetAdjoiningRoomPosition(CurrentRoomPosition, direction);
                }
                else
                {
                    switch (Level)
                    {
                    case Types.Level.One:
                        switch (direction)
                        {
                        case Direction.East:
                        case Direction.West:
                            RotateRooms(CurrentRoomPosition, direction);
                            break;

                        case Direction.North:
                        case Direction.South:
                            FlipRooms(direction);
                            break;
                        }
                        break;

                    case Types.Level.Two:
                        switch (direction)
                        {
                        case Direction.North:
                        case Direction.South:
                            RotateRooms(CurrentRoomPosition, direction);
                            break;

                        case Direction.East:
                        case Direction.West:
                            FlipRooms(direction);
                            break;
                        }
                        break;
                    }

                    if (FullyMerged())
                    {
                        AddCards();
                    }
                }
            }

            if (result.Success)
            {
                BaseRoom room = RoomPositions[CurrentRoomPosition];
                result.PrintInstructions.NewLine("You enter the ", ConsoleColor.DarkGreen)
                .Add(RoomInfo[room.Id].Name, room.Color)
                .Add(" room.", ConsoleColor.DarkGreen);
            }

            PrintInstructions mergedMessage = MergedDescription();

            mergedMessage.AddInstructions(result.PrintInstructions);

            result.PrintInstructions = mergedMessage;

            return(result);
        }