当前位置: 首页>>代码示例>>C#>>正文


C# WorldState类代码示例

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


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


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