public void ExecuteRule(Rule rule, Area area) { if (_leaves[area].Contains(rule)) // addition: start to using automatic rules { Debug.Log("Execute: " + rule.parent.outputs[0].name); _leaves[area].Remove(rule); if (rule.parent.parent != null) { Rule parent = rule.parent; parent.children.Remove(rule); if (parent.children.Count == 0) { _leaves[area].Add(parent); if (parent.automatic) { GameItem.ExecuteRule(parent, true, parent.inputs[0].gameItem); } } } else { Debug.Log("Finished this area!"); Statistics.Instance.FinishPuzzle(area); Player.Instance.ShowFinishMessage(_currentArea.name); //oven timer sound Debug.Log("Added to finished areas."); Debug.Log("Ping."); if (area.IsFinal()) { TriggerEnd(); } else { Debug.Log("Checking for next areas. "); foreach (Area connectedArea in area.connectedTo) { Debug.Log("Attempting to generate puzzle for " + connectedArea.name); GenerateForArea(connectedArea); } Player.Instance.ShowObjective(false); } } } }
public void OnMouseDown() { _gameItem.ExecuteRule(rule); }