コード例 #1
0
ファイル: SuperMetaNode.cs プロジェクト: SimianLogic/ld41
    private void PrintDisplayTree(SuperNode node, int current_depth)
    {
        string tab = "";

        for (int i = 0; i < current_depth; i++)
        {
            tab = tab + "  ";
        }
        tab = tab + "-->";

        //TODO: GET RECT TRANSFORM POSITIONS
        if (node.name == null)
        {
            Debug.Log(tab + node.GetType() + "    " + node.GetComponent <RectTransform>().position);
        }
        else
        {
            Debug.Log(tab + node.gameObject.name + "    " + node.GetComponent <RectTransform>().position);
        }

        if (node is SuperContainer)
        {
            SuperContainer container = node as SuperContainer;
            Transform      transform = container.GetComponent <Transform>();
            foreach (Transform child in transform)
            {
                PrintDisplayTree(child.GetComponent <SuperNode>(), current_depth + 1);
            }
        }
    }
コード例 #2
0
        public void GetListItemPropertiesTest2()
        {
            ListContainer list_container = new ListContainer();
            PropertyDescriptorCollection list_properties = TypeDescriptor.GetProperties(list_container);
            PropertyDescriptor           property        = list_properties ["List"];

            PropertyDescriptorCollection property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                                                 new PropertyDescriptor [] { property });

            Assert.AreEqual(1, property_coll.Count, "#A1");
            Assert.AreEqual("Value", property_coll [0].Name, "#A2");

            // Empty property descriptor array
            // Returns list_container properties, since it's not a list
            property_coll = ListBindingHelper.GetListItemProperties(list_container, new PropertyDescriptor [0]);
            Assert.AreEqual(2, property_coll.Count, "#B1");

            // Non list property
            // Returns the propeties of the type of that property
            property      = list_properties ["NonList"];
            property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                    new PropertyDescriptor [] { property });
            Assert.AreEqual(1, property_coll.Count, "#C1");
            Assert.AreEqual("Value", property_coll [0].Name, "#C2");

            // Pass two properties
            property = list_properties ["List"];
            PropertyDescriptor property2 = list_properties ["NonList"];

            property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                    new PropertyDescriptor [] { property2, property });
            Assert.AreEqual(0, property_coll.Count, "#D1");

            //
            // Third overload - doble re-direction
            //
            SuperContainer super_container = new SuperContainer();

            property = list_properties ["List"];

            property_coll = ListBindingHelper.GetListItemProperties(super_container, "ListContainer",
                                                                    new PropertyDescriptor [] { property });
            Assert.AreEqual(1, property_coll.Count, "#E1");
        }
コード例 #3
0
    public static void ProcessNode(SuperMetaNode root_node, Transform parent, Dictionary <string, object> node, GameObject maybe_recycled_node)
    {
        string name           = (string)node["name"];
        string container_type = name.Split('_')[0];

        if (containerClasses.ContainsKey(container_type))
        {
            object[] args = new object[4];
            args[0] = root_node;
            args[1] = parent;
            args[2] = node;
            args[3] = maybe_recycled_node;
            containerClasses[container_type].GetMethod("ProcessNode").Invoke(null, args);
            return;
        }

        GameObject     game_object = maybe_recycled_node;
        SuperContainer container   = null;

        if (game_object == null)
        {
            game_object = new GameObject();
            container   = game_object.AddComponent(typeof(SuperContainer)) as SuperContainer;
        }
        else
        {
            container = game_object.GetComponent <SuperContainer>();
        }

        container.CreateRectTransform(game_object, node);

        root_node.containerReferences.Add(new ContainerReference(name, container));
        container.name = name;
        container.hierarchyDescription = "";

        container.cachedMetadata = node;
        container.rootNode       = root_node;

        game_object.transform.SetParent(parent);
        container.Reset();

        root_node.ProcessChildren(container.transform, node["children"] as List <object>);
    }
コード例 #4
0
ファイル: SushiController.cs プロジェクト: SimianLogic/ld41
    // Use this for initialization
    void Start()
    {
        orders = new List <SushiPrefab>();

        metaNode       = GetComponent <SuperMetaNode>();
        queueContainer = metaNode.ContainerWithName("order_queue");

        inventory = new Dictionary <Sushi, int>();

        foreach (Sushi fish in sushi)
        {
            inventory[fish] = 0;
        }
        inventory[rice] = 0;

        AddSushiToQueue();
        AddSushiToQueue();
        AddSushiToQueue();
        AddSushiToQueue();

        foreach (SuperButtonBase button in metaNode.buttons.Values)
        {
            button.onClick += HandleButton;
        }

        Refresh();

        selected          = new List <int>();
        activeIngredients = new Dictionary <int, Sushi>();
        for (var i = 1; i <= 9; i++)
        {
            activeIngredients[i] = null;
        }

        Fill();
    }
コード例 #5
0
		public void GetListItemPropertiesTest2 ()
		{
			ListContainer list_container = new ListContainer ();
			PropertyDescriptorCollection list_properties = TypeDescriptor.GetProperties (list_container);
			PropertyDescriptor property = list_properties ["List"];

			PropertyDescriptorCollection property_coll = ListBindingHelper.GetListItemProperties (list_container,
				new PropertyDescriptor [] { property });
			Assert.AreEqual (1, property_coll.Count, "#A1");
			Assert.AreEqual ("Value", property_coll [0].Name, "#A2");

			// Empty property descriptor array 
			// Returns list_container properties, since it's not a list
			property_coll = ListBindingHelper.GetListItemProperties (list_container, new PropertyDescriptor [0]);
			Assert.AreEqual (2, property_coll.Count, "#B1");

			// Non list property
			// Returns the propeties of the type of that property
			property = list_properties ["NonList"];
			property_coll = ListBindingHelper.GetListItemProperties (list_container,
				new PropertyDescriptor [] { property });
			Assert.AreEqual (1, property_coll.Count, "#C1");
			Assert.AreEqual ("Value", property_coll [0].Name, "#C2");

			// Pass two properties
			property = list_properties ["List"];
			PropertyDescriptor property2 = list_properties ["NonList"];
			property_coll = ListBindingHelper.GetListItemProperties (list_container,
				new PropertyDescriptor [] { property2, property });
			Assert.AreEqual (0, property_coll.Count, "#D1");

			//
			// Third overload - doble re-direction
			//
			SuperContainer super_container = new SuperContainer ();
			property = list_properties ["List"];

			property_coll = ListBindingHelper.GetListItemProperties (super_container, "ListContainer",
				new PropertyDescriptor [] { property });
			Assert.AreEqual (1, property_coll.Count, "#E1");
		}
コード例 #6
0
ファイル: ConfigHelpers.cs プロジェクト: SimianLogic/ld41
 public ContainerReference(string name, SuperContainer container)
 {
     this.name      = name;
     this.container = container;
 }