示例#1
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (GrammarBlockUtils.IsUnit(attribute, "system"))
     {
         return(AttributeMatchResult.POSITIVE);
     }
     return(AttributeMatchResult.NEUTRAL);
 }
示例#2
0
 //public Taker dependencyBehavers;
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (actualBehaver != null)
     {
         return(actualBehaver.MatchAttribue(attribute));
     }
     return(GrammarBlockUtils.IsUnit(attribute, baseGUnit.word) ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEUTRAL);
 }
示例#3
0
 void Giver <IEnumerable <BehaverAgent>, GrammarBlock> .Give(GrammarBlock key, Taker <IEnumerable <BehaverAgent> > colletor)
 {
     if (GrammarBlockUtils.IsUnit(key, nameOnCreate))
     {
         var inst = Utilities.ConsistentInstantiate(seekingAgentPrefab);
         inst.behaverAttribute = seekingAgentPrefab.behaverAttribute;
         inst.gameObject.SetActive(true);
         colletor.Take(new List <BehaverAgent> {
             inst.behaverAgent
         });
     }
 }
示例#4
0
		void Giver<IEnumerable<BehaverAgent>, GrammarBlock>.Give(GrammarBlock key, Taker<IEnumerable<BehaverAgent>> colletor) {
			if (GrammarBlockUtils.IsUnit(key, "button")) {
				GrammarBlockUtils.ForEachUnits(
					key.modifier,
					(unit) => {
						MonoBBehaverAgent newButton;
						nameToButtonDict[unit.word] = newButton = GameObject.Instantiate(textButtonPrefab);
						newButton.GetComponent<TextViewer>().SetText(unit.word);
						newButton.GetComponent<BehaverAgent>().TryFittingSpace(new Vector3(0.4f, 1f, 1));
						colletor.Take(new List<BehaverAgent> { newButton.behaverAgent });
					}
				);
			}
		}
示例#5
0
        UnityBehaviorCheckTrigger UnityBehaviorChecker.ReadyCheckBehavior(BehaviorExpression bExpr, UnityBehaviorReadySupport listener)
        {
            UnityBehaviorCheckTrigger trigger = null;

            if (GrammarBlockUtils.IsUnit(bExpr.verb, "hit"))
            {
                var button = GrammarBlockUtils.ShallowSeek(bExpr.verb.modifier, "button");
                GrammarBlockUtils.ForEachUnits(
                    button.modifier,
                    (unit) => {
                    trigger = FindObjectOfType <GUIBehaver>().NewHitButtonCheckTrigger(unit.word);
                }
                    );
                return(trigger);
            }
            return(trigger);
        }
示例#6
0
        GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
        {
            if (!GrammarBlockUtils.IsUnit(sourceGBlock, "each"))
            {
                return(default(GBlockConvertResult));
            }
            if (!GrammarBlockUtils.IsUnit(sourceGBlock.modifier, "turn"))
            {
                return(default(GBlockConvertResult));
            }
            var newSubject = listener.subBlockConverter.ConvertGBlock(sourceGBlock.modifier, listener).result;
            var newVerb    = new StdMutableGUnit {
                word = "begin"
            };

            (newVerb as MutableGrammarBlock).AddMetaInfo(StdMetaInfos.verbalBlock);
            MutableClusterGrammarBlock newSV = new StdMutableClusterGBlock();

            newSV.AddBlock(newSubject);
            newSV.AddBlock(newVerb);
            newSV.AddMetaInfo(StdMetaInfos.conditionSV);
            return(new GBlockConvertResult(true, newSV));
        }
示例#7
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     return(GrammarBlockUtils.IsUnit(attribute, "player") ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEGATIVE);
 }
示例#8
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     return(GrammarBlockUtils.IsUnit(attribute, behaverAttribute.word) ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEUTRAL);
 }
示例#9
0
        GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
        {
            //only applly to SV or Condition SV
            if (!GrammarBlockUtils.HasMetaInfo(sourceGBlock, StdMetaInfos.sv.word) && !GrammarBlockUtils.HasMetaInfo(sourceGBlock, StdMetaInfos.conditionSV.word))
            {
                return(default(GBlockConvertResult));
            }
            //search passive be
            List <GrammarUnit> passiveVerbList = null;
            var originalSubject  = sourceGBlock.cluster.blocks[0];
            var convertedSubject = listener.subBlockConverter.ConvertGBlock(originalSubject, listener).result;
            var originalVerbs    = sourceGBlock.cluster.blocks[1];

            GrammarBlockUtils.DeepForEachBlockUnit(
                originalVerbs,
                (mainVerbUnit) => {
                if (GrammarBlockUtils.IsUnit(mainVerbUnit, "be"))
                {
                    GrammarBlockUtils.DeepForEachBlockUnit(
                        mainVerbUnit.modifier,
                        (contentVerbUnit) => {
                        if (passiveVerbList == null)
                        {
                            passiveVerbList = new List <GrammarUnit>();
                        }
                        passiveVerbList.Add(contentVerbUnit);
                    },
                        StdMetaInfos.verbalBlock.word
                        );
                }
            },
                StdMetaInfos.verbalBlock.word
                );
            //no passive verb found
            if (passiveVerbList == null)
            {
                return(default(GBlockConvertResult));
            }
            //search normal verbs
#if false
            List <GrammarBlock> normalVerbList = null;
            GrammarBlockUtils.ForEachUnits(
                originalVerbs,
                (gUnit) => {
                if (GrammarBlockUtils.ShallowSeekByMetaInfo(sourceGBlock.cluster.blocks[1], StdMetaInfos.verbalBlock.word) != null)
                {
                    if (normalVerbList == null)
                    {
                        normalVerbList = new List <GrammarBlock>();
                    }
                    normalVerbList.Add(gUnit);
                }
            },
                StdMetaInfos.modifierCluster.word
                );
#endif
            MutableGrammarBlock converted = null;
            #region passive only
            if (passiveVerbList.Count > 0)
            {
                var newSVCluster = new StdMutableClusterGBlock {
                };
                StdMutableClusterGBlock newSV = null;
                foreach (var passiveVerb in passiveVerbList)
                {
                    newSV = new StdMutableClusterGBlock {
                    };
                    (newSV as MutableClusterGrammarBlock).AddBlock(defaultSubject);
                    var activizedVerb = listener.subBlockConverter.ConvertGBlock(passiveVerb, listener).result;
                    activizedVerb.AddModifier(convertedSubject);
                    (newSV as MutableClusterGrammarBlock).AddBlock(activizedVerb);
                    (newSVCluster as MutableClusterGrammarBlock).AddBlock(newSV);
                    (newSV as MutableClusterGrammarBlock).AddMetaInfo(sourceGBlock.metaInfo);
                }
                if (passiveVerbList.Count == 1)
                {
                    converted = newSV;
                    GBlockConvertUtility.ApplyModAndMeta(converted, sourceGBlock, listener);
                }
                else
                {
                    converted = newSVCluster;
                    var convLis = new MixedGBlockConvertListener {
                        _baseLisetner  = listener,
                        _metaConverter = new ClusterGBlockConverter {
                            converters = new List <GBlockConverter> {
                                new GBlockConverter_Replace {
                                    number = new Dictionary <string, GrammarBlock> {
                                        { StdMetaInfos.sv.word, StdMetaInfos.sentenceCluster },
                                        { StdMetaInfos.conditionSV.word, StdMetaInfos.sentenceCluster }
                                    }
                                },
                                listener.metaConverter
                            }
                        }
                    };
                    GBlockConvertUtility.ApplyModAndMeta(converted, sourceGBlock, convLis);
                }
            }
            #endregion
            #region no result
            if (converted == null)
            {
                return(default(GBlockConvertResult));
            }

            return(new GBlockConvertResult(true, converted));

            #endregion
        }