コード例 #1
0
        public FPSAgentKebabiste()
        {
            selector = new Selector();

            // Si vie inférieur à un montant, va se cacher
            SequenceAction    wantToHide            = new SequenceAction(() => SetIntent(Action.Hide));
            SequenceCondition sequenceConditionHide = new SequenceCondition(CheckLowLife, wantToHide);

            selector.AddNode(sequenceConditionHide);

            // Si ammo inférieur à un montant, va recharger
            SequenceAction    wantToReload            = new SequenceAction(() => SetIntent(Action.Reload), EndReload);
            SequenceCondition sequenceConditionReload = new SequenceCondition(CheckAmmo, wantToReload);

            selector.AddNode(sequenceConditionReload);

            // Si Ok
            Selector       findOrShootSelector = new Selector();
            NodeAlwaysTrue shootOrMove         = new NodeAlwaysTrue(findOrShootSelector);

            // Si cible en vue, tire
            SequenceAction    shootOpponent             = new SequenceAction(() => SetIntent(Action.Shoot));
            SequenceCondition sequenceConditionCanShoot = new SequenceCondition(CanShootOpponent, shootOpponent);

            findOrShootSelector.AddNode(sequenceConditionCanShoot);

            // Si cible non en vu, se déplacer
            SequenceAction goNearAction     = new SequenceAction(() => SetIntent(Action.GoNear));
            NodeAlwaysTrue alwaysTrueGoNear = new NodeAlwaysTrue(goNearAction);

            findOrShootSelector.AddNode(alwaysTrueGoNear);

            selector.AddNode(shootOrMove);
        }
コード例 #2
0
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
            IHaveConnectionScope source = context.Instance as IHaveConnectionScope;
            ViewTableBase        design;

            if (source == null)
            {
                return;
            }

            design = source.DesignTable;

            if (design.Name != source.TableScope)
            {
                using (DataTable table = source.GetConnection().GetSchema("Columns", new string[] { source.CatalogScope, null, source.TableScope }))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        selector.AddNode(row[3].ToString(), row[3], null);
                    }
                }
            }
            else
            {
                Table tbl = design as Table;
                if (tbl != null)
                {
                    foreach (Column c in tbl.Columns)
                    {
                        selector.AddNode(c.ColumnName, c.ColumnName, null);
                    }
                }
            }
        }
コード例 #3
0
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
            IHaveConnectionScope source = context.Instance as IHaveConnectionScope;
            Table design;

            if (source == null)
            {
                return;
            }

            design = source.DesignTable as Table;

            using (DataTable table = source.GetConnection().GetSchema("Tables", new string[] { source.CatalogScope }))
            {
                foreach (DataRow row in table.Rows)
                {
                    bool add = true;
                    if (design != null && (row[2].ToString() == design.OldName || row[2].ToString() == design.Name))
                    {
                        add = false;
                    }

                    if (add)
                    {
                        selector.AddNode(row[2].ToString(), row[2], null);
                    }
                }
            }
            if (design != null)
            {
                selector.AddNode(design.Name, design.Name, null);
            }
        }
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);

            var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement;

            selector.AddNode("(None)", null, null);
            foreach (XElement entityType in new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model))
            {
                selector.AddNode(entityType.Attribute("Name").Value, entityType, null);
            }
        }
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);

            var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement;

            selector.AddNode("(None)", null, null);
            foreach (XElement entityType in new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model))
            {
                selector.AddNode(entityType.Attribute("Name").Value, entityType, null);
            }
        }
コード例 #6
0
        public AgentKebabiste()
        {
            selector = new Selector();

            // Init different sequences

            // Si le stress est trop haut
            SequenceAction sequenceTakeBreak = new SequenceAction(() =>
                                                                  SetIntent(new KebabisteIntent {
                action = Action.TakeBreak
            })
                                                                  );
            SequenceCondition sequenceCheckStress = new SequenceCondition(CheckStressCondition, sequenceTakeBreak);

            selector.AddNode(sequenceCheckStress);

            // Si il manque des ingrédients pour la recette
            CreateSequenceForRecipe();

            // Si l'adversaire à un niveau de stress élevé ou il est trop en avance
            SequenceAction sequenceAttackOpponent = new SequenceAction(() =>
            {
                Action attackAction = Random.Range(0, 2) == 0 ? Action.FakeClient : Action.Corrupt;
                SetIntent(new KebabisteIntent
                {
                    action = attackAction
                });
            });
            SequenceCondition sequenceOpponentCondition =
                new SequenceCondition(CheckOpponentStressCondition, sequenceAttackOpponent);

            selector.AddNode(sequenceOpponentCondition);

            // Si le seuil d'ingredient préparé est trop bas
            CreateSequencePrepareIngredient();

            // Si un plat est attendu et peut être préparé
            SequenceAction sequencePrepareRecipe = new SequenceAction(() =>
                                                                      SetIntent(new KebabisteIntent {
                action = Action.CreateDish
            })
                                                                      );
            SequenceCondition sequenceRecipeCanBeMade =
                new SequenceCondition(CheckRecipeCanBeMade, sequencePrepareRecipe);

            selector.AddNode(sequenceRecipeCanBeMade);

            // action par defaut;
            NodeAlwaysTrue defaultSequence = new NodeAlwaysTrue();

            selector.AddNode(defaultSequence);
        }
コード例 #7
0
        private void CreateSequenceForRecipe()
        {
            foreach (Ingredient ing in Enum.GetValues(typeof(Ingredient)))
            {
                SequenceAction sequenceOrderIngredient = new SequenceAction(() =>
                                                                            SetIntent(new KebabisteIntent {
                    action     = Action.OrderIngredient,
                    ingredient = ing
                })
                                                                            );
                SequenceCondition sequenceMissingIngredients =
                    new SequenceCondition(() => CheckMissingIngredient(ing), sequenceOrderIngredient);

                selector.AddNode(sequenceMissingIngredients);
            }
        }
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);

            var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement;

            selector.AddNode("(None)", null, null);
            var items = new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model).Select(et => et.Attribute("Name").Value).OrderBy(n => n).ToList();
            foreach (string entityTypeName in items)
            {
                selector.AddNode(entityTypeName, entityTypeName, null);
            }

            //int nOfItems = selector.Height / selector.ItemHeight;
            selector.Height = selector.ItemHeight * Math.Min(items.Count + 1, 8);
        }
コード例 #9
0
 protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
 {
     if (context?.Instance != null)
     {
         _selector              = selector;
         selector.CheckBoxes    = true;
         selector.BeforeSelect += SelectBefore;
         selector.Clear();
         var instance = context.Instance as ConnectionInfo;
         foreach (ApiType category in Enum.GetValues(typeof(ApiType)))
         {
             if (category != ApiType.None)
             {
                 var node = selector.AddNode(category.ToString(), (int)category, null);
                 if (instance != null)
                 {
                     node.Checked = (instance.Type & category) == category;
                 }
             }
         }
         selector.SelectedNode = null;
     }
     else
     {
         base.FillTreeWithData(selector, context, provider);
     }
 }
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);

            var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement;

            selector.AddNode("(None)", null, null);
            var items = new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model).Select(et => et.Attribute("Name").Value).OrderBy(n => n).ToList();

            foreach (string entityTypeName in items)
            {
                selector.AddNode(entityTypeName, entityTypeName, null);
            }

            //int nOfItems = selector.Height / selector.ItemHeight;
            selector.Height = selector.ItemHeight * Math.Min(items.Count + 1, 8);
        }
コード例 #11
0
ファイル: Table.cs プロジェクト: cody82/spacewar-arena
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
              IHaveConnection source = context.Instance as IHaveConnection;

              if (source == null) return;

              using (DataTable table = source.GetConnection().GetSchema("Catalogs"))
              {
            foreach (DataRow row in table.Rows)
            {
              selector.AddNode(row[0].ToString(), row[0], null);
            }
              }
        }
コード例 #12
0
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            object       manager    = Activator.CreateInstance(_managerType, new object[] { provider });
            DbConnection connection = (DbConnection)context.Instance;

            ObjectSelectorEditor.SelectorNode node;

            _selector = selector;

            _selector.Clear();

            if (manager != null)
            {
                int    items = (int)_managerType.InvokeMember("GetConnectionCount", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, null);
                string dataProvider;
                string connectionString;
                string connectionName;

                for (int n = 0; n < items; n++)
                {
                    connectionString = (string)_managerType.InvokeMember("GetConnectionString", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
                    connectionName   = (string)_managerType.InvokeMember("GetConnectionName", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
                    dataProvider     = (string)_managerType.InvokeMember("GetProvider", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
                    if (String.Compare(dataProvider, "Npgsql", true) == 0)
                    {
                        node = selector.AddNode(connectionName, connectionString, null);

                        if (String.Compare(connectionString, connection.ConnectionString, true) == 0)
                        {
                            selector.SelectedNode = node;
                        }
                    }
                }
                selector.AddNode("<New Connection...>", this, null);
            }
        }
コード例 #13
0
ファイル: Table.cs プロジェクト: TrevorDArcyEvans/EllieSpeed
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
            IHaveConnection source = context.Instance as IHaveConnection;

            if (source == null)
            {
                return;
            }

            using (DataTable table = source.GetConnection().GetSchema("Catalogs"))
            {
                foreach (DataRow row in table.Rows)
                {
                    selector.AddNode(row[0].ToString(), row[0], null);
                }
            }
        }
コード例 #14
0
ファイル: Index.cs プロジェクト: lucianocampos/Npgsql2
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
              IHaveConnectionScope source = context.Instance as IHaveConnectionScope;
              ViewTableBase design;

              if (source == null) return;

              design = source.DesignTable;

              if (design.Name != source.TableScope)
              {
            using (DataTable table = source.GetConnection().GetSchema("Columns", new string[] { source.CatalogScope, null, source.TableScope }))
            {
              foreach (DataRow row in table.Rows)
              {
            selector.AddNode(row[3].ToString(), row[3], null);
              }
            }
              }
              else
              {
            Table tbl = design as Table;
            if (tbl != null)
            {
              foreach (Column c in tbl.Columns)
              {
            selector.AddNode(c.ColumnName, c.ColumnName, null);
              }
            }
              }
        }
コード例 #15
0
ファイル: Table.cs プロジェクト: cody82/spacewar-arena
 protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
 {
     base.FillTreeWithData(selector, context, provider);
       selector.AddNode("BINARY", "BINARY", null);
       selector.AddNode("NOCASE", "NOCASE", null);
 }
コード例 #16
0
ファイル: Table.cs プロジェクト: TrevorDArcyEvans/EllieSpeed
 protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
 {
     base.FillTreeWithData(selector, context, provider);
     selector.AddNode("BINARY", "BINARY", null);
     selector.AddNode("NOCASE", "NOCASE", null);
 }
コード例 #17
0
ファイル: Index.cs プロジェクト: lucianocampos/Npgsql2
        protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
        {
            base.FillTreeWithData(selector, context, provider);
              IHaveConnectionScope source = context.Instance as IHaveConnectionScope;
              Table design;

              if (source == null) return;

              design = source.DesignTable as Table;

              using (DataTable table = source.GetConnection().GetSchema("Tables", new string[] { source.CatalogScope }))
              {
            foreach (DataRow row in table.Rows)
            {
              bool add = true;
              if (design != null && (row[2].ToString() == design.OldName || row[2].ToString() == design.Name))
            add = false;

              if (add)
            selector.AddNode(row[2].ToString(), row[2], null);
            }
              }
              if (design != null)
            selector.AddNode(design.Name, design.Name, null);
        }
コード例 #18
0
    protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider)
    {
      object manager = Activator.CreateInstance(_managerType, new object[] { provider });
      DbConnection connection = (DbConnection)context.Instance;
      ObjectSelectorEditor.SelectorNode node;

      _selector = selector;

      _selector.Clear();

      if (manager != null)
      {
        int items = (int)_managerType.InvokeMember("GetConnectionCount", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, null);
        string dataProvider;
        string connectionString;
        string connectionName;

        for (int n = 0; n < items; n++)
        {
          connectionString = (string)_managerType.InvokeMember("GetConnectionString", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
          connectionName = (string)_managerType.InvokeMember("GetConnectionName", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
          dataProvider = (string)_managerType.InvokeMember("GetProvider", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { n });
          if (String.Compare(dataProvider, "System.Data.SQLite", StringComparison.OrdinalIgnoreCase) == 0)
          {
            node = selector.AddNode(connectionName, connectionString, null);
            
            if (String.Compare(connectionString, connection.ConnectionString, StringComparison.OrdinalIgnoreCase) == 0)
              selector.SelectedNode = node;
          }
        }
        selector.AddNode("<New Connection...>", this, null);
      }
    }
コード例 #19
0
ファイル: AI.cs プロジェクト: Snowball115/SOL-AIBehaviourTree
    public void InitBehaviourTree()
    {
        // ********************
        // Initialise Blackboard and store data for later use
        // ********************
        bb = new Blackboard();
        bb.AddData(_agentData.EnemyFlagName, GameObject.Find(_agentData.EnemyFlagName));
        bb.AddData(_agentData.FriendlyFlagName, GameObject.Find(_agentData.FriendlyFlagName));
        bb.AddData(_agentData.EnemyBase.name, GameObject.Find(_agentData.EnemyBase.name));
        bb.AddData(_agentData.FriendlyBase.name, GameObject.Find(_agentData.FriendlyBase.name));
        bb.AddData(Names.HealthKit, GameObject.Find(Names.HealthKit));
        bb.AddData(Names.PowerUp, GameObject.Find(Names.PowerUp));
        bb.AddData("HasEnemyFlag", _agentData.HasEnemyFlag);
        bb.AddData("HasFriendlyFlag", _agentData.HasFriendlyFlag);
        bb.AddData("EnemyFlagCarrier", enemyFlagCarrier);

        enemyFlag    = (GameObject)bb.GetData(_agentData.EnemyFlagName);
        friendlyFlag = (GameObject)bb.GetData(_agentData.FriendlyFlagName);
        enemyBase    = (GameObject)bb.GetData(_agentData.EnemyBase.name);
        friendlyBase = (GameObject)bb.GetData(_agentData.FriendlyBase.name);

        // ********************
        // Composite Nodes
        // ********************
        Sequence mainEntryLoop  = new Sequence(true);
        Selector selecMainEntry = new Selector();
        Sequence seqStealFlag   = new Sequence();
        Sequence seqCarryFlag   = new Sequence();
        Sequence seqAttack      = new Sequence();

        Sequence seqRecoverFlag   = new Sequence();
        Selector selecRecoverFlag = new Selector();
        Sequence seqRecoverPathA  = new Sequence();
        Sequence seqRecoverPathB  = new Sequence();

        // ********************
        // Node connections
        // ********************
        mainEntryLoop.AddNode(selecMainEntry);
        mainEntryLoop.AddNode(new Repeater(mainEntryLoop));

        selecMainEntry.AddNode(seqStealFlag);
        selecMainEntry.AddNode(seqCarryFlag);
        selecMainEntry.AddNode(seqRecoverFlag);

        AttackNearbyEnemy attackNode = new AttackNearbyEnemy(_agentActions, _agentSenses, 0);

        seqAttack.AddNode(attackNode);
        seqAttack.AddNode(new RepeatUntilNodeFails(attackNode));

        seqStealFlag.AddNode(new GoToRandomPos(_agentActions));
        seqStealFlag.AddNode(new Wait(2));
        seqStealFlag.AddNode(new ComparePosition(enemyFlag, enemyBase, 5));
        seqStealFlag.AddNode(new GoToPos(this, _agentActions, enemyBase, 2, seqAttack));
        seqStealFlag.AddNode(new IsItemInView(_agentSenses, enemyFlag));
        seqStealFlag.AddNode(new GoToPos(this, _agentActions, enemyFlag));
        seqStealFlag.AddNode(new CollectItem(_agentActions, _agentSenses, _agentInventory, enemyFlag));

        seqCarryFlag.AddNode(new IsCarryingEnemyFlag(_agentData));
        seqCarryFlag.AddNode(new GoToRandomPos(_agentActions));
        seqCarryFlag.AddNode(new Wait(1));
        seqCarryFlag.AddNode(new GoToPos(this, _agentActions, friendlyBase, 2));
        seqCarryFlag.AddNode(new DropItem(_agentActions, enemyFlag));

        seqRecoverFlag.AddNode(new Inverter(new ComparePosition(friendlyFlag, friendlyBase, 5)));
        seqRecoverFlag.AddNode(selecRecoverFlag);
        selecRecoverFlag.AddNode(seqRecoverPathA);
        selecRecoverFlag.AddNode(seqRecoverPathB);

        seqRecoverPathA.AddNode(new GetEnemyFlagCarrier(this, bb));
        seqRecoverPathA.AddNode(new GoToPos(this, _agentActions, "EnemyFlagCarrier", bb));
        seqRecoverPathA.AddNode(attackNode);

        seqRecoverPathB.AddNode(new GoToPos(this, _agentActions, friendlyFlag));
        seqRecoverPathB.AddNode(new IsItemInView(_agentSenses, friendlyFlag));
        seqRecoverPathB.AddNode(new CollectItem(_agentActions, _agentSenses, _agentInventory, friendlyFlag));
        seqRecoverPathB.AddNode(new GoToPos(this, _agentActions, friendlyBase, 2));
        seqRecoverPathB.AddNode(new DropItem(_agentActions, friendlyFlag));

        // ********************
        // Set root node here and start tree
        // ********************
        myTree = new BehaviourTree(mainEntryLoop, this);
        myTree.Traverse();
    }