Created
June 28, 2015 00:55
-
-
Save gotwig/25fc56416d5cbf05959f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class LogicFraDia{ | |
public LogicFraDia () | |
{ | |
Start(); | |
} | |
public class logicFragment { | |
public int id; | |
public string name; | |
public string description; | |
public bool solved; | |
public bool discovered; | |
public int dialogID; | |
public logicFragment (int id, string name, string description, bool solved, bool discovered, int dialogID) | |
{ | |
this.id = id; | |
this.name = name; | |
this.description = description; | |
this.solved = solved; | |
this.discovered = discovered; | |
this.dialogID = dialogID; | |
} | |
} | |
public class logicDeduction { | |
public int id; | |
public string name; | |
public int[] dependencies; | |
public bool solved; | |
public bool discovered; | |
public int dialogID; | |
public logicDeduction (int id, string name, int[] dependencies, bool solved, bool discovered, int dialogID) | |
{ | |
this.id = id; | |
this.name = name; | |
this.dependencies = dependencies; | |
this.solved = solved; | |
this.discovered = discovered; | |
this.dialogID = dialogID; | |
} | |
} | |
public List<logicFragment> logicFragments = new List<logicFragment>(); | |
public List<logicDeduction> logicDeductions = new List<logicDeduction>(); | |
// Use this for initialization | |
void Start () { | |
//FILL FRAGMENTS | |
logicFragments[0] = new logicFragment(1,"asdas","tasd",false,false,0); | |
logicFragments[1] = new logicFragment(2,"asdas","tasd",false,false,0); | |
logicFragments[2] = new logicFragment(3,"asdas","tasd",false,false,0); | |
logicFragments[3] = new logicFragment(4,"asdas","tasd",false,false,0); | |
logicFragments[4] = new logicFragment(5,"asdas","tasd",false,false,0); | |
logicFragments[5] = new logicFragment(6,"asdas","tasd",false,false,0); | |
logicFragments[6] = new logicFragment(7,"asdas","tasd",false,false,0); | |
logicFragments[7] = new logicFragment(8,"asdas","tasd",false,false,0); | |
logicFragments[8] = new logicFragment(9,"asdas","tasd",false,false,0); | |
logicFragments[9] = new logicFragment(10,"asdas","tasd",false,false,0); | |
logicFragments[10] = new logicFragment(11,"asdas","tasd",false,false,0); | |
logicFragments[11] = new logicFragment(12,"asdas","tasd",false,false,0); | |
logicFragments[12] = new logicFragment(13,"asdas","tasd",false,false,0); | |
logicFragments[13] = new logicFragment(14,"asdas","tasd",false,false,0); | |
logicFragments[14] = new logicFragment(15,"asdas","tasd",false,false,0); | |
//FILL DEDUCTIONS | |
logicDeductions[0] = new logicDeduction(1,"BLABLA EPIC SAUCE BLA BLA",new int[] {1,2},false,false,0); | |
} | |
void discoverFragment(int id) { | |
logicFragments[id].discovered = true; | |
} | |
void discoverDeduction(int id) { | |
logicDeductions[id].discovered = true; | |
} | |
void solveFragment(int id) { | |
logicFragments[id].solved = true; | |
} | |
void solveDeduction(int id){ | |
logicDeductions[id].solved = true; | |
} | |
public List<logicFragment> returnFragments(bool undiscovered){ | |
List<logicFragment> outputlist = new List<logicFragment>(); | |
if (undiscovered) { | |
foreach (var x in logicFragments) { | |
if (!x.discovered) { | |
outputlist.Add(x); | |
} | |
} | |
} else { | |
outputlist = logicFragments; | |
} | |
return outputlist; | |
} | |
bool match(int id1, int id2){ | |
int dependencyMatches = 0; | |
if (!logicFragments [id1].solved == !logicFragments[id2].solved){ | |
foreach (logicDeduction i in logicDeductions){ | |
if (!i.solved){ | |
dependencyMatches = 0; | |
foreach (int ix in i.dependencies){ | |
if (ix == id1 || ix == id2) | |
dependencyMatches++; | |
} | |
if (dependencyMatches == i.dependencies.Length){ | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment