Advertisement
anden3

Quest gen

Mar 3rd, 2020
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace QuestGenerator
  5. {
  6.     public enum ActionType
  7.     {
  8.         Action1,
  9.         Action2
  10.     }
  11.  
  12.     public class Precondition
  13.     {
  14.         public string precondition;
  15.         public List<int> parameters = new List<int>();
  16.  
  17.         public bool Evaluate() => World.preconditions[precondition](this);
  18.     }
  19.  
  20.     public class Action
  21.     {
  22.         public ActionType type;
  23.         public List<Precondition> preconditions = new List<Precondition>();
  24.  
  25.         public void Execute(World world)
  26.         {
  27.             switch (type)
  28.             {
  29.                 case ActionType.Action1:
  30.                 {
  31.                     break;
  32.                 }
  33.             }
  34.         }
  35.     }
  36.  
  37.     public class Node
  38.     {
  39.         public Action action;
  40.         public Node parent = null;
  41.  
  42.         public List<int> parameters = new List<int>();
  43.         public List<Node> next = new List<Node>();
  44.     }
  45.  
  46.     public class Character
  47.     {
  48.         public bool alive;
  49.     }
  50.  
  51.     public class World
  52.     {
  53.         public static Dictionary<string, Predicate<Precondition>> preconditions
  54.             = new Dictionary<string, Predicate<Precondition>>
  55.         {
  56.             {"alive", (Precondition p) => characters[p.parameters[0]].alive }
  57.         };
  58.  
  59.         public static Character[] characters;
  60.  
  61.         public static Action[] actions;
  62.         public static Precondition[] startState;
  63.  
  64.         public List<Node> nodes = new List<Node>();
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement