コード例 #1
0
ファイル: AGDevNative.cs プロジェクト: iwaag/AGDevUnity
        public bool AskForFloatAnswer(GrammarBlock question, AnswerListener <float> listener)
        {
            var lisBridge = new FloatAnswerListenerBridge(listener);

            floatAnswerListeners.Add(lisBridge);
            return(AskForNumericAnswer(helperFactory.implPtr, implPtr, helperFactory.GBlockToGBlockPtr(question), lisBridge.callback));
        }
コード例 #2
0
		AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute) {
			lastMatchedCardAttribute = attribute;
			if (attribute.unit.word == "button" || attribute.unit.word == "title" || attribute.unit.word == "text") {
				return AttributeMatchResult.POSITIVE;
			}
			return AttributeMatchResult.NEUTRAL;
		}
コード例 #3
0
 void BehaverEquipper.EquipBehaverByAttribute(GrammarBlock attribute, BehaverEquipListener listener)
 {
     foreach (var equipper in equippers)
     {
         equipper.EquipBehaverByAttribute(attribute, listener);
     }
 }
コード例 #4
0
ファイル: TimeBehaver.cs プロジェクト: iwaag/AGBLang
        float TimeExpresssionToFloatSec(GrammarBlock timeExpression)
        {
            var vis = new TimeCountVisitor();

            GrammarBlockUtils.VisitGrammarBlock(timeExpression, vis);
            return(vis.result);
        }
コード例 #5
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.cluster != null)
     {
         var newClusterGB = new StdMutableClusterGBlock();
         foreach (var subGB in sourceGBlock.cluster.blocks)
         {
             var convertedSub = listener.subBlockConverter.ConvertGBlock(subGB, listener).result;
             if (convertedSub != null)
             {
                 newClusterGB.subBlocks.Add(convertedSub);
             }
         }
         GBlockConvertUtility.ApplyModAndMeta(newClusterGB, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newClusterGB));
     }
     else if (sourceGBlock.unit != null)
     {
         var newGUnit = new StdMutableGUnit {
             word = sourceGBlock.unit.word
         };
         GBlockConvertUtility.ApplyModAndMeta(newGUnit, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newGUnit));
     }
     return(default(GBlockConvertResult));
 }
コード例 #6
0
 void AssetImplementCustomizer <ImplType> .EditAssetRequestFromGBlock(GrammarBlock gBlock, AssetRequestUnit assetReqUnit)
 {
     assetReqUnit.assettype = assetType;
     if (gBlock.unit.word == null)
     {
         assetReqUnit.attributes.Add(gBlock.unit.word);
     }
 }
コード例 #7
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (GrammarBlockUtils.IsUnit(attribute, "system"))
     {
         return(AttributeMatchResult.POSITIVE);
     }
     return(AttributeMatchResult.NEUTRAL);
 }
コード例 #8
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);
 }
コード例 #9
0
 void Taker <GrammarBlock> .Take(GrammarBlock item)
 {
     GrammarBlockUtils.ForEach(item, "Unreadable", (gBlock) => {
         string result = fileName + " : ";
         GrammarBlockUtils.ForEachUnits((gBlock), (gUnit) => result += " " + gUnit.word);
         parent.parent.OnUnreadableFound.Invoke(result);
     });
     parent.parent.bAnalyzer.bAnlys.AnalyzeBehavior(item, this);
 }
コード例 #10
0
        AssetType AssetImplementer <AssetType> .PickImplementedAsset(GrammarBlock gBlock)
        {
            var found = customizer.implementedAssets.Find((elem) => customizer.MatchAsset(elem, gBlock));

            if (found != null)
            {
                return(customizer.ExtractAsset <AssetType>(found));
            }
            return(default(AssetType));
        }
コード例 #11
0
 void BehaverEquipper.EquipBehaverByAttribute(GrammarBlock attribute, BehaverEquipListener listener)
 {
     if (behaverPrefab != null)
     {
         if (behaverPrefab.behaver.MatchAttribue(attribute) == AttributeMatchResult.POSITIVE)
         {
             listener.OnEquipSubBehaver(behaverPrefab);
         }
     }
 }
コード例 #12
0
        ContentType AssetMediator.GetImplementedAsset <ContentType>(GrammarBlock gBlock)
        {
            var implementer = implementerGetter.assetImplGetter.GetAssetImplementer <ContentType>(gBlock);

            if (implementer != null)
            {
                return(implementer.PickImplementedAsset(gBlock));
            }
            return(default(ContentType));
        }
コード例 #13
0
ファイル: StdGBlockFilter.cs プロジェクト: iwaag/AGBLang
 public void SetPronounSolution(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     GrammarBlockUtils.DeepSeek(sourceGBlock, StdMetaInfos.nominalBlock.word, (gBlock) => {
         //acutual noun found
         if (!GrammarBlockUtils.HasMetaInfo(gBlock, StdMetaInfos.pronoun.word))
         {
             pronouc.dict["they"] = listener.subBlockConverter.ConvertGBlock(gBlock, listener).result;
         }
     }, true);
 }
コード例 #14
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (attribute.unit != null)
     {
         return(FindDef(attribute.unit.word) != null ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEGATIVE);
     }
     else
     {
     }
     return(AttributeMatchResult.NEGATIVE);
 }
コード例 #15
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.unit == null)
     {
         return(default(GBlockConvertResult));
     }
     if (sourceGBlock.unit.word.Equals(filteringString, System.StringComparison.CurrentCultureIgnoreCase))
     {
         return(new GBlockConvertResult(true, null));
     }
     return(default(GBlockConvertResult));
 }
コード例 #16
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (baseBehaver != null)
     {
         return(baseBehaver.behaver.MatchAttribue(attribute));
     }
     if (attribute.unit != null)
     {
         return(nameOnCreate == attribute.unit.word ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEGATIVE);
     }
     return(AttributeMatchResult.NEGATIVE);
 }
コード例 #17
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     foreach (var converter in converters)
     {
         var converted = converter.ConvertGBlock(sourceGBlock, listener);
         if (converted.didConvert)
         {
             return(converted);
         }
     }
     return(default(GBlockConvertResult));
 }
コード例 #18
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
         });
     }
 }
コード例 #19
0
            void AvatarPhysicalizeInterface.Search(GrammarBlock attribute, Taker <IEnumerable <BehaverAgent> > asyncTaker)
            {
                var pickedAgents = new List <BehaverAgent>();

                foreach (var agent in agents)
                {
                    if (agent.MatchAttribue(attribute) == AttributeMatchResult.POSITIVE)
                    {
                        pickedAgents.Add(agent);
                    }
                }
                asyncTaker.Take(pickedAgents);
            }
コード例 #20
0
                void Taker <GrammarBlock> .Take(GrammarBlock item)
                {
                    GrammarBlockUtils.ForEach(item, "Unreadable", (gBlock) => {
                        string result = "";
                        GrammarBlockUtils.ForEachUnits((gBlock), (gUnit) => result += " " + gUnit.word);
                        parent.parent.OnUnreadableFound.Invoke(result);
                    });
                    parent.parent.OnSucceedEvent.Invoke(new AnalysisResult {
                        gBlock = item, name = fileName, sourceText = sourceText
                    });

                    parent.parent.bAnalyzer.bAnlys.AnalyzeBehavior(item, this);
                }
コード例 #21
0
ファイル: TimeBehaver.cs プロジェクト: iwaag/AGBLang
        AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
        {
            var checker = new MultiMatchingGBlockVisitor {
                candidates = candidates
            };

            GrammarBlockUtils.VisitGrammarBlock(attribute, checker);
            if (checker.hasOne && !checker.hasUnmatch)
            {
                return(AttributeMatchResult.POSITIVE);
            }
            return(AttributeMatchResult.NEGATIVE);
        }
コード例 #22
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 });
					}
				);
			}
		}
コード例 #23
0
 ClusterBehaverEventListener GetCluster(GrammarBlock grammarBlock)
 {
     if (grammarBlock.unit != null)
     {
         eventListenerDict.TryGetValue(grammarBlock.unit.word, out var cluster);
         if (cluster == null)
         {
             cluster = new ClusterBehaverEventListener();
             eventListenerDict.Add(grammarBlock.unit.word, cluster);
         }
         return(cluster);
     }
     return(null);
 }
コード例 #24
0
        void AssetMediator.SeekAsset <ContentType>(GrammarBlock gBlock, Taker <ContentType> collLis)
        {
            var implementer = implementerGetter.assetImplGetter.GetAssetImplementer <ContentType>(gBlock);

            if (implementer != null)
            {
                implementer.SeekAsset(gBlock, new PrvtSeekLis <ContentType> {
                    collLis = collLis, parent = this
                });
                return;
            }
            //stub: should seek asset tool
            else
            {
                collLis.None();
            }
        }
コード例 #25
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.unit == null)
     {
         return(default(GBlockConvertResult));
     }
     if (number.TryGetValue(sourceGBlock.unit.word, out var value))
     {
         if (value == null)
         {
             return(new GBlockConvertResult(true, null));
         }
         //doubt : using sub block converter?
         var newMGBlock = listener.subBlockConverter.ConvertGBlock(value, listener);
         GBlockConvertUtility.ApplyModAndMeta(newMGBlock.result, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newMGBlock.result));
     }
     return(default(GBlockConvertResult));
 }
コード例 #26
0
 void BehaviorAnalyzer.AnalyzeBehavior(GrammarBlock behaviorExpressionByGBlock, Taker <BehaviorTriggerSet> listener)
 {
     //ensure behaver
     {
         var metaDepVis = new MetaInfoDependentGrammarBlockVisitor {
             doDeepSeek = true, doDeepSeekModifier = true
         };
         metaDepVis.metaToVis[StdMetaInfos.nominalBlock.word] = new EnsureBehaver {
             behaverGiver = stdGiver
         };
         GrammarBlockUtils.VisitGrammarBlock(behaviorExpressionByGBlock, metaDepVis);
     }
     //cereate behavior trigger
     {
         var rootTrigger    = new StdCompositeBehaviorTrigger();
         var namedCBTrigger = new Dictionary <string, CompositeBehaviorTrigger>();
         var processor      = new SentenceBlockRecursiveProcessor {
             subSentenceBehaviorTaker = rootTrigger, behaverSetCheck = bSetCheck, namedCBTriggers = namedCBTrigger, support = new StdBehaviorReadySupport {
                 assetMediator = assetMediator.assetMed
             }
         };
         processor.GrammarBlockCommon(behaviorExpressionByGBlock);
         if (rootTrigger.bTriggers.Count > 0 || namedCBTrigger.Count > 0)
         {
             List <NameAndBTrigger> namedTriggers = null;
             if (namedCBTrigger.Count > 0)
             {
                 namedTriggers = new List <NameAndBTrigger>();
                 foreach (var pair in namedCBTrigger)
                 {
                     namedTriggers.Add(new NameAndBTrigger {
                         name = pair.Key, bTrigger = pair.Value
                     });
                 }
             }
             var result = new BehaviorTriggerSet {
                 rootTrigger = rootTrigger.bTriggers.Count > 0 ? rootTrigger : null, namedTriggers = namedTriggers
             };
             listener.Take(result);
         }
     }
 }
コード例 #27
0
        void AssetImplementer <AssetType> .SeekAsset(GrammarBlock gBlock, AssetSeekSupportListener <AssetType> listener)
        {
            var found = (this as AssetImplementer <AssetType>).PickImplementedAsset(gBlock);

            if (found != null)
            {
                listener.collectorOnImplement.Take(found);
                return;
            }
            var newAssetReqUnit = new AssetRequestUnit {
            };

            customizer.EditAssetRequestFromGBlock(gBlock, newAssetReqUnit);
            listener.auInterfaceGiver.Give(
                newAssetReqUnit,
                new PrvtinterfaceColl {
                externalTaker = listener.collectorOnImplement, customizer = customizer
            }
                );
        }
コード例 #28
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
        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));
        }
コード例 #29
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (!GrammarBlockUtils.HasMetaInfo(sourceGBlock, StdMetaInfos.pronoun.word))
     {
         return(default(GBlockConvertResult));
     }
     if (dict.TryGetValue(sourceGBlock.unit.word, out var value))
     {
         var clusterGBC = new ClusterGBlockConverter {
             converters = new List <GBlockConverter> {
                 new GBlockConverter_GUnitFilter {
                     filteringString = StdMetaInfos.pronoun.word
                 },
                 listener.metaConverter
             }
         };
         GBlockConvertUtility.ApplyModAndMeta(value, sourceGBlock, listener, clusterGBC);
         return(new GBlockConvertResult {
             didConvert = true, result = value
         });
     }
     return(default(GBlockConvertResult));
 }
コード例 #30
0
ファイル: StdGBlockConverters.cs プロジェクト: iwaag/AGBLang
 public static void ApplyModAndMeta(
     MutableGrammarBlock newBlock,
     GrammarBlock sourceBlock,
     GBlockConvertListener listener,
     GBlockConverter metaConv = null,
     GBlockConverter modConv  = null
     )
 {
     if (sourceBlock.metaInfo != null)
     {
         var metaLis = new MixedGBlockConvertListener {
             _subBlockConverter = listener.metaConverter,
             _metaConverter     = PassThroughGBlockConverter.instance,
             _modConverter      = PassThroughGBlockConverter.instance
         };
         var result = listener.metaConverter.ConvertGBlock(sourceBlock.metaInfo, metaLis);
         if (result.result != null)
         {
             newBlock.AddMetaInfo(result.result);
         }
     }
     if (sourceBlock.modifier != null)
     {
         var modLis = new MixedGBlockConvertListener {
             _subBlockConverter = listener.modConverter,
             _metaConverter     = listener.metaConverter,
             _modConverter      = listener.modConverter,
             _baseLisetner      = listener
         };
         var result = listener.modConverter.ConvertGBlock(sourceBlock.modifier, modLis);
         if (result.result != null)
         {
             newBlock.AddModifier(result.result);
         }
     }
     listener.AdditionalEdit(newBlock);
 }