예제 #1
0
    private void _updateWeaponChange(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        String          name = "WeaponSlotPanel_" + weaponOrder + "_" + weaponIndex;
        WeaponSlotPanel currentWeaponSlotPanel = (WeaponSlotPanel)_gridContainerWeaponSlots.GetNode(name);

        Agent  agent  = _inventory.GetAgent();
        Weapon weapon = agent.GetWeapons(weaponOrder)[weaponIndex];

        ItemResource itemResource = null;

        if (weapon != null)
        {
            itemResource = _inventoryManager.GetPurchasableItemByID(weapon.ItemResourceID);
        }

        currentWeaponSlotPanel.Initialize(itemResource, weaponOrder, weaponIndex);

        _populateWeaponChoices(weaponOrder, weaponIndex);
    }
    public async void SearchSimulation()
    {
        Control root = GetNode("SearchSimulation") as Control;

        root.SetVisible(true);

        Tween tween = new Tween();

        AddChild(tween);

        // setting up maps
        GridContainer  mapContainer = root.GetNode("NodeMaps") as GridContainer;
        List <NodeMap> maps         = new List <NodeMap>();

        foreach (Node node in mapContainer.GetChildren())
        {
            maps.Add(node.GetNode("NodeMap") as NodeMap);
        }

        // setup the chart
        Control chart = root.GetNode("Chart") as Control;


        Random random = new Random();
        int    seed   = -1;

        foreach (NodeMap maze in maps)
        {
            maze.SetWidth(55);
            maze.ResizeBlock();
        }

        // rename the title and size
        (mapContainer.GetNode("DFS/GraphTitle") as Label).Text      = "DFS - " + maps[0].width + " x " + maps[0].height;
        (mapContainer.GetNode("BFS/GraphTitle") as Label).Text      = "BFS - " + maps[1].width + " x " + maps[1].height;
        (mapContainer.GetNode("Dijkstra/GraphTitle") as Label).Text = "Dijkstra - " + maps[2].width + " x " + maps[2].height;
        (mapContainer.GetNode("AStar/GraphTitle") as Label).Text    = "AStar - " + maps[3].width + " x " + maps[3].height;

        // reset the active nodemap
        activeNodeMaps.Clear();
        paths.Clear();
        foreach (NodeMap map in maps)
        {
            activeNodeMaps.Add(map, true);
            // connect the signals
            map.Connect("finished_pathfinding", this, nameof(OnPathFound));
            paths[map] = new Tuple <Godot.Collections.Array <int>, Godot.Collections.Array <int> >(new Godot.Collections.Array <int>(), new Godot.Collections.Array <int>());
        }

        for (int i = 0; i < 20; i++)
        {
            seed = random.Next();

            foreach (NodeMap maze in maps)
            {
                maze.seed = seed;
                maze.GenerateMap();
            }

            foreach (NodeMap map in maps)
            {
                activeNodeMaps[map] = true;
                WaitForActiveNodeMaps(map);
            }

            await ToSignal(this, "active_nodemaps_finished");

            // record place
            foreach (NodeMap map in maps)
            {
                activeNodeMaps[map] = true;
            }

            // record distance here and expansion
            maps[0].DFS();
            maps[1].BFS();
            maps[2].Dijkstra();
            maps[3].AStar();

            await ToSignal(this, "active_nodemaps_finished");

            // toggle all the info now
        }

        await ToSignal(this, "next");

        tween = CommonTweenUtil.Fade(root, 0.3f, 1, 0, tween);
        tween.Start();
        await ToSignal(tween, "tween_completed");

        tween.QueueFree();
        root.SetVisible(false);

        EmitSignal("section_finished");
    }