• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WorldState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WorldState的典型用法代码示例。如果您正苦于以下问题:C# WorldState类的具体用法?C# WorldState怎么用?C# WorldState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WorldState类属于命名空间,在下文中一共展示了WorldState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnTriggerEnter

    GameObject agentObject; //the agent gameObject

    #endregion Fields

    #region Methods

    public void OnTriggerEnter(Collider other)
    {
        colliderList.Add(other); //add detected object to list of "seen" objects
        if (other.gameObject.name == "Resource(Clone)") { //if it is a resource
            Debug.Log("Found " + other.tag + "!");

            //get color of resource
            string color = "";
            for(int i = 1; i < other.tag.Length; i++)
            {
                if(char.IsUpper(other.tag[i]))
                {
                    color = other.tag.Substring(0, i);
                    break;
                }
            }

            //update the workingmemory that a resource is at this position
            ((Agent)agentComponent).GetWMemory().SetFact(color, new WorkingMemoryValue(other.transform.position));

            //update the currentWorldState that resrouces of this color is available
            WorldState newState = new WorldState();
            newState.SetProperty(char.ToLower(color[0]) + color.Substring(1) + "ResourceIsAvailable", new WorldStateValue(true));
            BlackBoard.Instance.SetCurrentWorldstate(agentComponent.GetClan(), newState);
        }
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:32,代码来源:ResourceSensor.cs


示例2: World

 public World()
 {
     watch.Start();
     updateDomains = new UpdateDomain[1];
     updateDomains[0] = new UpdateDomain(watch);
     State = WorldState.Running;
 }
开发者ID:DiablosOffens,项目名称:octoawesome,代码行数:7,代码来源:World.cs


示例3: Teste

        public void Teste()
        {
                AstarPlanner Planner = new AstarPlanner();

                Planner.Actions.Add(new KillAction());
                Planner.Actions.Add(new BeProtectedAction());
                Planner.Actions.Add(new BeArmedAction());
                Planner.Actions.Add(new GoToAction("lugar0", "lugar1",2));
                Planner.Actions.Add(new GoToAction("lugar1", "lugar2", 2));
                Planner.Actions.Add(new GoToAction("lugar2", "lugar1", 2));
                Planner.Actions.Add(new GoToAction("lugar1", "lugar0", 2));


                WorldState TestWorldState = new WorldState();
                TestWorldState.SetSymbol(new WorldSymbol("Armed", false));
                TestWorldState.SetSymbol(new WorldSymbol("Place", "lugar0"));
                TestWorldState.SetSymbol(new WorldSymbol("Protected", false));
                TestWorldState.SetSymbol(new WorldSymbol("EnemyKilled", false));

                PlanSet PlanSet = Planner.CreatePlan(
                    TestWorldState,
                    new TesteGoal()
                    );

                System.Diagnostics.Debug.Assert(PlanSet != null);
            

        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:28,代码来源:PlannerTest.cs


示例4: GetNeighbours

    //get the neighbours of this node
    public List<AStarNode> GetNeighbours(bool  firstTime)
    {
        List<Action> tempList = new List<Action>();
        WorldState preConditions = new WorldState();

        if(firstTime == true)//if first node in the AStar then it will be a postCondition
        {
            preConditions = worldState;
        }
        else{ //else it will be an action so get the preconditions of that action

            preConditions = ActionManager.Instance.GetAction(this.name).preConditions;
        }

        tempList = ActionManager.Instance.GetSuitableActions(preConditions);

        foreach(Action action in tempList)
        {
            AStarNode node = new AStarNode();
            node.name = action.GetActionName();
            node.parent = this;
            node.time = action.time;

            suitableActions.Add(node);
        }
        return suitableActions;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:28,代码来源:AStarNode.cs


示例5: CreateNewPlan

    //create a new plan if old plan fails for example
    public void CreateNewPlan(WorldState currentWorldState, WorldState goalWorldState)
    {
        StopCoroutine(plan[0].Substring(0, plan[0].Length - 6));
        Destroy(transform.FindChild("Subsystem").gameObject);

        planner.SetGoalWorldState(goalWorldState);

        //Saves current plan so that agent can continue after new plan is completed
        List<string> tempPlan = new List<string>();
        foreach(string action in plan)
        {
            tempPlan.Add(action);
        }

        List<string> newPlanList = new List<string>();
        foreach (AStarNode node in planner.RunAStar(currentWorldState))
        {
            newPlanList.Add(node.GetName());
        }

        if(newPlanList.Count == 0)
        {
            //A new plan could not be made so continue on the old plan
            //Implement some kind of report up to commanders?
            Debug.Log("NEW PLAN COULD NOT BE MADE!!");
        } else
        {
            //A new plan was created, is added in front of old plan
            plan.Clear();
            plan.Add ("Crap"); //Added because remove plan[0] in update
            plan.InsertRange(1, newPlanList);
            plan.InsertRange(plan.Count, tempPlan);
        }
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:35,代码来源:Agent.cs


示例6: Contains

    //check if the worldstate contains the same properties as the worldstate ws (can still contain other as well)
    public bool Contains(WorldState ws)
    {
        Dictionary<string, WorldStateValue> wsProperties = ws.GetProperties();

        foreach(KeyValuePair<string, WorldStateValue> pair in wsProperties)
        {
            if(properties.ContainsKey(pair.Key)) //if both contains the same property key
            {

                if(properties[pair.Key].propertyValues["bool"].Equals(pair.Value.propertyValues["bool"])) //if they both also have the same value
                {
                    continue;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        return true;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:26,代码来源:WorldState.cs


示例7: Draw

        /// <summary>
        /// Render the terrain
        /// </summary>
        /// <param name="device"></param>
        /// <param name="world"></param>
        public override void Draw(GraphicsDevice device, WorldState world)
        {
            world._3D.ApplyCamera(Effect, this);
            //device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            //device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;

            device.SetVertexBuffer(VertexBuffer);
            device.Indices = IndexBuffer;

            //device.RasterizerState.CullMode = CullMode.None;
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GeomLength, 0, NumPrimitives);
            }

            device.SetVertexBuffer(GrassVertexBuffer);
            //device.Indices = GrassIndexBuffer;

            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawPrimitives(PrimitiveType.LineList, 0, GrassPrimitives);
                //device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, GrassPrimitives*2, 0, GrassPrimitives);
            };
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:31,代码来源:TerrainComponent.cs


示例8: RunAStar

    public List<AStarNode> RunAStar(WorldState currentWorldState)
    {
        AStarNode startNode = new AStarNode();
        AStarNode endNode = new AStarNode();

        startNode.SetWorldState(goalWorldState);
        endNode.SetWorldState(currentWorldState);

        AStar star = new AStar();

        List<AStarNode> plan = star.Run(startNode, endNode);

        //används under utvecklingsfasen
        /*Debug.Log("HÄR ÄR PLANEN!!!!!!!!: " + plan.Count);
        foreach(AStarNode node in plan)
        {
            Debug.Log(node.name);
        }*/
        //----------------------------

        /*foreach(AStarNode node in plan)
        {
            //TODO: dubbelkolla att returnerande action faktiskt finns
            blackBoard.setCurrentAction(node.name);

        }*/
        //blackBoard.setCurrentAction("");

        return plan;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:30,代码来源:Planner.cs


示例9: contains

    public bool contains(WorldState ws)
    {
        Dictionary<string, WorldStateValue> wsProperties = ws.getProperties();

        foreach(KeyValuePair<string, WorldStateValue> pair in properties)
        {
            if(ws.getProperties().ContainsKey(pair.Key))
            {

                if(wsProperties[pair.Key].propertyValues["bool"].Equals(pair.Value.propertyValues["bool"]))
                {
                    continue;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        return true;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:25,代码来源:WorldState.cs


示例10: GetAirSprite

        private _2DSprite GetAirSprite(WorldState world)
        {
            var _Sprite = new _2DSprite()
            {
                RenderMode = _2DBatchRenderMode.Z_BUFFER
            };
            var airTiles = TextureGenerator.GetAirTiles(world.Device);
            Texture2D sprite = null;
            switch (world.Zoom)
            {
                case WorldZoom.Far:
                    sprite = airTiles[2];
                    _Sprite.DestRect = FLOORDEST_FAR;
                    _Sprite.Depth = ArchZBuffers[14];
                    break;
                case WorldZoom.Medium:
                    sprite = airTiles[1];
                    _Sprite.DestRect = FLOORDEST_MED;
                    _Sprite.Depth = ArchZBuffers[13];
                    break;
                case WorldZoom.Near:
                    sprite = airTiles[0];
                    _Sprite.DestRect = FLOORDEST_NEAR;
                    _Sprite.Depth = ArchZBuffers[12];
                    break;
            }

            _Sprite.Pixel = sprite;
            _Sprite.SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, _Sprite.Pixel.Width, _Sprite.Pixel.Height);

            return _Sprite;
        }
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:32,代码来源:NewFloorComponent.cs


示例11: GetNeighbours

    public List<AStarNode> GetNeighbours(bool  firstTime)
    {
        List<Action> tempList = new List<Action>();
        WorldState preConditions = new WorldState();

        if(firstTime == true)//returns a list of actions suitable for the goal(a string)
        {
            preConditions = worldState;
        }
        else{
            preConditions = ActionManager.Instance.getAction(this.name).preConditions;
        }

        //go thru postConditions for this action
        //TODO: gör så det funkar för fler postConditions
        /*foreach(KeyValuePair<string, bool> pair in preConditions.getProperties())
        {
            tempList = ActionManager.Instance.getSuitableActions(pair.Key, pair.Value, preConditions);
        }*/

        tempList = ActionManager.Instance.getSuitableActions(preConditions);

        //Debug.Log("templist count: " + tempList.Count);
        foreach(Action action in tempList)
        {
            //Debug.Log("templist name: " + action.actionName);
            AStarNode node = new AStarNode();
            node.name = action.GetActionName();
            node.parent = this;
            node.time = action.time;

            suitableActions.Add(node);
        }
        return suitableActions;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:35,代码来源:AStarNode.cs


示例12: ProceduralPreConditions

 public override bool ProceduralPreConditions(WorldState WorldState)
 {
     foreach (var item in unitsNeeded)
     {
         WorldSymbol WorldSymbol =  WorldState.GetSymbol(item.Key);
         if(WorldSymbol == null || WorldSymbol.GetSymbol<int>() < item.Value)
             return false;
     }
     return true;
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:10,代码来源:Attack.cs


示例13: ProceduralPreConditions

        public override bool ProceduralPreConditions(WorldState WorldState)
        {
            foreach (var item in resourcesNeeded)
            {
                if (WorldState.GetSymbolValue<int>(item.Key) < item.Value)
                    return false;
            }

            if (WorldState.GetSymbol(HouseNeeded) == null || WorldState.GetSymbolValue<int>(HouseNeeded) == 0)
            {
                return false;
            }

            return true;
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:15,代码来源:MakeUnit.cs


示例14: Start

    // Use this for initialization
    void Start()
    {
        SpawnPoints = GameObject.FindGameObjectsWithTag("SpawnPosition");
        Player = GameObject.FindGameObjectWithTag("Player");
        Nest = GameObject.FindGameObjectWithTag("Nest");

        FishPrefabs = new string[6];
        FishPrefabs[0] = "TrumpetFish";
        FishPrefabs[1] = "Stupidwels";
        FishPrefabs[2] = "Glotzfisch";
        FishPrefabs[3] = "Krakenkatze";
        FishPrefabs[4] = "Korkenzieherfisch";
        FishPrefabs[5] = "Squarefish";

        State = WorldState.Game;
    }
开发者ID:darthcoder1,项目名称:LDJAM_CC,代码行数:17,代码来源:WorldScript.cs


示例15: GetBlueAction

    public GetBlueAction()
    {
        preConditions = new WorldState();
        preConditions.setProperty("blueResourceIsAvailable", new WorldStateValue(true));

        postConditions = new WorldState();
        postConditions.setProperty("blueResourceIsCollected", new WorldStateValue(true));

        cost = 1.0f;
        time = 4.0f;

        agentTypes = new List<string>();
        agentTypes.Add("Blue");

        this.actionName = "GetBlueAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:16,代码来源:GetBlueAction.cs


示例16: ScoutRedAction

    public ScoutRedAction()
    {
        preConditions = new WorldState();
        preConditions.SetProperty("redResourceIsAvailable", new WorldStateValue(false));

        postConditions = new WorldState();
        postConditions.SetProperty("redResourceIsAvailable", new WorldStateValue(true));

        cost = 1.0f;
        time = 4.0f;

        agentTypes = new List<string>();
        agentTypes.Add("Red");

        this.actionName = "ScoutRedAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:16,代码来源:ScoutRedAction.cs


示例17: ScoutAction

    public ScoutAction()
    {
        preConditions = new WorldState();
        preConditions.setProperty("armedWithGun", new WorldStateValue(true));

        postConditions = new WorldState();
        postConditions.setProperty("enemyVisible", new WorldStateValue(true));

        cost = 4.0f;
        time = 4.0f;

        agentTypes = new List<string>();
        agentTypes.Add("CommanderAgent");
        agentTypes.Add("Builder");

        this.actionName = "ScoutAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:17,代码来源:ScoutAction.cs


示例18: BuildBlueFloorAction

    public BuildBlueFloorAction()
    {
        preConditions = new WorldState();
        preConditions.setProperty("blueResourceIsCollected", new WorldStateValue(true));

        postConditions = new WorldState();
        postConditions.setProperty("blueFloorIsBuilt", new WorldStateValue(true));
        postConditions.setProperty("blueResourceIsCollected", new WorldStateValue(false));

        cost = 1.0f;
        time = 4.0f;

        agentTypes = new List<string>();
        agentTypes.Add("Blue");

        this.actionName = "BuildBlueFloorAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:17,代码来源:BuildBlueFloorAction.cs


示例19: LoadAction

    public LoadAction()
    {
        preConditions = new WorldState();
        preConditions.setProperty("armedWithGun", new WorldStateValue(true));

        postConditions = new WorldState();
        postConditions.setProperty("weaponLoaded", new WorldStateValue(true));

        cost = 1.0f;
        time = 1.0f;

        agentTypes = new List<string>();
        agentTypes.Add("CommanderAgent");
        agentTypes.Add("Builder");

        this.actionName = "LoadAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:17,代码来源:LoadAction.cs


示例20: BuildYellowHouseAction

    public BuildYellowHouseAction()
    {
        preConditions = new WorldState();
        preConditions.SetProperty("yellowResourceIsCollected", new WorldStateValue(true));

        postConditions = new WorldState();
        postConditions.SetProperty("yellowHouseIsBuilt", new WorldStateValue(true));
        postConditions.SetProperty("yellowResourceIsCollected", new WorldStateValue(false));

        cost = 1.0f;
        time = 4.0f;

        agentTypes = new List<string>();
        agentTypes.Add("Yellow");

        this.actionName = "BuildYellowHouseAction";
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:17,代码来源:BuildYellowHouseAction.cs



注:本文中的WorldState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WrapMode类代码示例发布时间:2022-05-24
下一篇:
C# WorldPos类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap