/// <summary> /// 現在のゲームフィールドからルールが適用可能な候補を取得する /// </summary> /// <returns></returns> public Candidate[] GetApplyCandidates() { var result = new List <Candidate>(); foreach (var rule in _rules) { // オブジェクト候補を作れるかのチェック var typesAndObjs = SameNumberObjectGroupsByType(CurrentObjectSet, rule.BeforeObjectSet); if (typesAndObjs == null) { break; } foreach (var objlist in typesAndObjs) { var objset = new VRiscuitObjectSet(objlist); var score = CalcScore(rule.BeforeObjectSet, objset, rule.RuleScoreCoefficient); // scoreで足切り if (NormalizeScore(score) < 0.1) { continue; } var cand = new Candidate(rule, objset, score); result.Add(cand); } } return(result.ToArray()); }
/// <summary> /// 初期化。シングルトンと必要なテーブルの用意 /// </summary> private void Start() { IVRiscuitObjectSet currentObjectSet = new VRiscuitObjectSet(); if (_objectsRoot != null) { foreach (Transform obj in _objectsRoot.transform) { var vobj = obj.GetComponent <IVRiscuitObject>(); if (vobj == null) { continue; } currentObjectSet.Add(vobj); } } List <IRule> rules = new List <IRule>(); if (_rulesRoot != null) { foreach (Transform obj in _rulesRoot.transform) { var rule = obj.GetComponent <IRuleSet>(); if (rule == null) { continue; } rules.AddRange(rule.Rules); } } _manager = new RuleManager(currentObjectSet, rules); }
protected void AddRule(IVRiscuitObject[] before, IVRiscuitObject[] after) { var beforeSet = new VRiscuitObjectSet(before); Debug.Log(beforeSet != null); var rule = new VRiscuitRule(new BeforePattern(new VRiscuitObjectSet(before)), new AfterPattern(new VRiscuitObjectSet(after))); Debug.Log(rule); _rules.Add(rule); }