Skip to content

Commit

Permalink
Added procedural generation of door seal elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawton committed Jan 30, 2016
1 parent 7e338d7 commit bdd1821
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 13 deletions.
9 changes: 9 additions & 0 deletions Assets/Custom.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scenes/Instructions.unity
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: .691176474, g: .665765584, b: .665765584, a: 1}
m_Sprite: {fileID: 21300000, guid: f9e594f4fc98d2949ad07cdfa5510bd2, type: 3}
m_Sprite: {fileID: 21300000, guid: 1e8055add97ca3c46a50ae4726535086, type: 3}
m_Type: 2
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down
57 changes: 57 additions & 0 deletions Assets/Scripts/ArrayGenerator.cs
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++
}

}

}

12 changes: 12 additions & 0 deletions Assets/Scripts/ArrayGenerator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Assets/Scripts/ReagentList.cs
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;

}
12 changes: 12 additions & 0 deletions Assets/Scripts/ReagentList.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions Assets/Scripts/ReagentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@ public class ReagentManager : MonoBehaviour {

// Use this for initialization
void Start () {
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"))
};
reagents = ReagentList.reagents;

GameObject panel = GameObject.Find("Reagents");
foreach(Reagent reagent in reagents) {
Expand Down

0 comments on commit bdd1821

Please sign in to comment.