Пример #1
0
        /// <summary>
        /// Creates a deep copy of the game state.
        /// </summary>
        /// <returns></returns>
        public GameState Clone()
        {
            GameState newState = new GameState();

            // Characters (as structs are copied by value)
            newState.Characters = new List <Character>();
            foreach (Character character in Characters)
            {
                newState.AddCharacter(character.Clone());
            }

            foreach (Item item in Items)
            {
                newState.AddItem(item.Clone());
            }

            foreach (KeyValuePair <string, List <DialogueLine> > kvp in Conversations)
            {
                List <DialogueLine> lines = new List <DialogueLine>();
                foreach (DialogueLine line in kvp.Value)
                {
                    lines.Add(line);
                }
                newState.SetConversation(kvp.Key, lines);
            }

            newState.Player    = this.Player.Clone();
            newState.Intensity = this.Intensity;
            return(newState);
        }
Пример #2
0
        public static GameState TellWantToKill(GameState state, Character instigator, Character receiver, Item item)
        {
            GameState newState = state.Clone();

            if (instigator != null && receiver != null)
            {
                newState.Player.AddStatus(instigator.Name + "WantsToKill" + receiver.Name);

                Location loc = DramaManager.Instance
                               .GetNewItemLocation(state, instigator);

                Item guardItem = new Item(instigator.Name + "Item" + "Lethal", loc.X, loc.Y);
                newState.AddItem(guardItem);
                guardItem.AddStatus("Lethal");

                Random r = new Random();

                if (r.Next(0, 2) == 0)
                {
                    guardItem.AddStatus("Distance");
                }

                guardItem.SetHidden(false);

                if (instigator.Name.Contains(DramaManager.PRISONER_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Hey so I need you to get this thing for me. In order to take out a jerk."));
                }
                else if (instigator.Name.Contains(DramaManager.GUARD_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "One of these monsters wishes me ill. Fetch me this device to stop them."));
                }
            }
            return(newState);
        }
Пример #3
0
        /// <summary>
        /// The instigating character is given a quest by the the receiving character.
        /// The receiving character is dehidden and their initial item quest is added to the world state.
        /// </summary>
        public static GameState IntroduceCharacterQuest(GameState state, Character instigator, Character receiver, Item item)
        {
            GameState newState = state.Clone();
            Location  loc      = DramaManager.Instance
                                 .GetNewItemLocation(state, instigator);

            var instigatorIndex = newState.Characters.FindIndex(c => c.Name == instigator.Name);

            newState.Characters[instigatorIndex].Hidden = false;

            Item guardItem = new Item(instigator.Name + "Item", loc.X, loc.Y);

            newState.AddItem(guardItem);
            guardItem.SetHidden(false);

            newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Hey get this!"));

            return(newState);
        }
Пример #4
0
        //Introduces a character by dehiding them, and adding their initial item quest to the world state
        public static GameState IntroduceMurderQuest(GameState state, Character instigator, Character receiver, Item item)
        {
            GameState newState = state.Clone();

            if (instigator != null && receiver != null)
            {
                Location loc = DramaManager.Instance
                               .GetNewItemLocation(state, instigator);

                var instigatorIndex = newState.Characters.FindIndex(c => c.Name == instigator.Name);

                newState.Characters[instigatorIndex].Hidden = false;

                Item guardItem = new Item(instigator.Name + "Item" + "Lethal", loc.X, loc.Y);
                newState.AddItem(guardItem);
                guardItem.AddStatus("Lethal");
                guardItem.SetHidden(false);

                Random r = new Random();

                if (r.Next(0, 2) == 0)
                {
                    guardItem.AddStatus("Distance");
                }

                newState.Player.AddStatus(instigator.Name + "WantsToKill" + receiver.Name);
                newState.Player.AddStatus("Knows" + instigator.Name);

                if (instigator.Name.Contains(DramaManager.PRISONER_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Hey buddy, not sure who you are, but I need this thing."));
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Gonna use it to take down a jerk. Sounds good, right?"));
                }
                else if (instigator.Name.Contains(DramaManager.GUARD_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Entity, I require your assistance."));
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "One of these monsters wishes me ill. Fetch this device to stop them."));
                }
            }
            return(newState);
        }
Пример #5
0
        /// <summary>
        /// Introduces an escape quest.
        /// </summary>
        /// <returns></returns>
        public static GameState IntroduceEscapeQuest(GameState state, Character instigator, Character receiver, Item item)
        {
            GameState newState = state.Clone();

            if (instigator != null && receiver != null)
            {
                Location loc = DramaManager.Instance.GetNewItemLocation(state, instigator);

                var escapee = newState.GetCharacter(instigator.Name);
                escapee.Hidden = false;

                Item key = new Item(instigator.Name + "Item" + "Liberating", loc.X, loc.Y);
                newState.AddItem(key);
                key.AddStatus("Liberating");
                key.SetHidden(false);

                Random r = new Random();

                //if (r.Next(0, 2) == 0) {
                //    key.AddStatus("Distance");
                //}

                //newState.Player.AddStatus(instigator.Name + "Wants" + key.Name);
                newState.Player.AddStatus("Knows" + instigator.Name);

                if (instigator.Name.Contains(DramaManager.PRISONER_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Hey buddy, not sure who you are, but I need this thing."));
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "I need to try and get out of this place. I'll make it worth your while."));
                }
                else if (instigator.Name.Contains(DramaManager.GUARD_TITLE))
                {
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "Entity, I require your assistance."));
                    newState.AddLine(instigator.Name, new DialogueLine(instigator.Name, "One of these monsters wishes to escape. Fetch me the device they desire and I'll reward you."));
                }
            }
            return(newState);
        }
Пример #6
0
    /// <summary>
    /// Creates a deep copy of the game state.
    /// </summary>
    /// <returns></returns>
    public GameState Clone()
    {
      GameState newState = new GameState();
      // Characters (as structs are copied by value)
      newState.Characters = new List<Character>();
      foreach (Character character in Characters) {
	newState.AddCharacter(character.Clone());			
      }

      foreach (Item item in Items) {
	newState.AddItem(item.Clone());			
      }

      foreach(KeyValuePair<string,List<DialogueLine>> kvp in Conversations){
	List<DialogueLine> lines = new List<DialogueLine>();
	foreach(DialogueLine line in kvp.Value){
	  lines.Add(line);
	}
	newState.SetConversation(kvp.Key,lines);
      }

      newState.Player = this.Player.Clone();
      newState.Intensity = this.Intensity;
      return newState;
    }