-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added procedural generation of door seal elements
- Loading branch information
Lawton
committed
Jan 30, 2016
1 parent
7e338d7
commit bdd1821
Showing
8 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
using System; | ||
|
||
public class ArrayGenerator : MonoBehaviour { | ||
|
||
//Important lists | ||
static List<Reagent> reagents = ReagentList.reagents; | ||
public static List<Reagent> elem = new List<Reagent>(); | ||
|
||
// Use this for initialization | ||
void Start () { | ||
SelectElem (2); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
|
||
} | ||
//generate the list of elements for the door array | ||
public void SelectElem(int n) { | ||
int len = reagents.Count; | ||
int index = 0; | ||
|
||
//generate first element- | ||
elem.Add(reagents[UnityEngine.Random.Range(0, len)]); | ||
int reagentIndex = 1; | ||
bool contradiction = false; | ||
|
||
//iterating to generate the rest of the items | ||
while (reagentIndex < n - 1) | ||
{ | ||
//select the location of the new reagent | ||
index = UnityEngine.Random.Range(0, len); | ||
//test this choice against all existing... | ||
for (int elemIndex = 0; elemIndex < elem.Count; elemIndex++) | ||
{ | ||
//test the chosen reagent against the current existing element | ||
if (reagents[index].Name == "Holy" && elem[elemIndex].Name == "Darkness" | ||
|| reagents[index].Name == "Darkness" && elem[elemIndex].Name == "Holy") | ||
{ | ||
//if a contradiction exist it flags this and breaks the loop | ||
contradiction = true; | ||
break; | ||
} | ||
} | ||
//adds the element if no Dark/light contraction is found | ||
if (contradiction == false) | ||
{ | ||
elem.Add(reagents[index]); | ||
reagentIndex++ | ||
} | ||
|
||
} | ||
|
||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
using ReagentManager; | ||
|
||
public class ReagentList { | ||
|
||
public static List<Reagent> reagents = new List<Reagent> (){ | ||
new Reagent("Charcoal", | ||
"Burnt wood... Some say that if you use it to draw a summoning array on someone’s face, you could bring out his true self. So far people who’ve tried this just looked like idiots.", | ||
Resources.Load<Sprite>("Item_Charcoal")), | ||
new Reagent("Holy Relic", | ||
"An ancient relic used in some religion. Someone possibly would kill for it. And you’re about to use it to open a door. You monster.", | ||
Resources.Load<Sprite>("Item_Cross")), | ||
new Reagent("Flask", | ||
"'I swear, this is water. I guarantee it!' *hic*", | ||
Resources.Load<Sprite>("Item_Flask")) | ||
}; | ||
|
||
public static List<Reagent> elem = ArrayGenerator.elem; | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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