當前位置: 首頁>>代碼示例>>Python>>正文


Python Composite.set_child方法代碼示例

本文整理匯總了Python中compositecore.Composite.set_child方法的典型用法代碼示例。如果您正苦於以下問題:Python Composite.set_child方法的具體用法?Python Composite.set_child怎麽用?Python Composite.set_child使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在compositecore.Composite的用法示例。


在下文中一共展示了Composite.set_child方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_children_with_tag_may_return_spoofed_children_with_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_get_children_with_tag_may_return_spoofed_children_with_tag(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.add_spoof_child(component_2)
     self.assertIn(component_1, c.get_children_with_tag(tag_1))
     self.assertIn(component_2, c.get_children_with_tag(tag_1))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:10,代碼來源:composite_test.py

示例2: test_when_adding_component_of_existing_type_old_component_should_be_removed

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_when_adding_component_of_existing_type_old_component_should_be_removed(self):
     c = Composite()
     component_first = DummyComponent("x")
     component_second = DummyComponent("x")
     c.set_child(component_first)
     c.set_child(component_second)
     self.assertFalse(c.x is component_first)
     self.assertTrue(c.x is component_second)
開發者ID:co,項目名稱:TheLastRogue,代碼行數:10,代碼來源:compositecore_test.py

示例3: test_get_children_with_tag_returns_all_children_with_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_get_children_with_tag_returns_all_children_with_tag(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.set_child(component_2)
     self.assertIn(component_1, c.get_children_with_tag(tag_1))
     self.assertIn(component_2, c.get_children_with_tag(tag_1))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:10,代碼來源:composite_test.py

示例4: test_get_children_with_does_not_return_removed_children

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_get_children_with_does_not_return_removed_children(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.set_child(component_2)
     c.remove_component(component_1)
     self.assertNotIn(component_1, c.get_children_with_tag(tag_1))
     self.assertIn(component_2, c.get_children_with_tag(tag_1))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:composite_test.py

示例5: test_get_children_with_tag_should_not_return_removed_spoofed_children

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_get_children_with_tag_should_not_return_removed_spoofed_children(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.add_spoof_child(component_2)
     c.reset_spoofed_children()
     self.assertIn(component_1, c.get_children_with_tag(tag_1))
     self.assertNotIn(component_2, c.get_children_with_tag(tag_1))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:composite_test.py

示例6: test_when_a_component_is_removed_by_type_it_should_not_be_gettable_by_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_when_a_component_is_removed_by_type_it_should_not_be_gettable_by_tag(self):
     c = Composite()
     component1 = DummyComponent("x", "a")
     c.set_child(component1)
     self.assertEqual(len(c.get_children_with_tag("a")), 1)
     self.assertTrue(component1 in c.get_children_with_tag("a"))
     c.remove_component_of_type("x")
     self.assertEqual(len(c.get_children_with_tag("a")), 0)
     self.assertFalse(component1 in c.get_children_with_tag("a"))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:compositecore_test.py

示例7: test_get_relative_of_type_should_return_sibling_if_sibling_matches

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_get_relative_of_type_should_return_sibling_if_sibling_matches(self):
     c = Composite()
     component1 = DummyComponent("A")
     component2 = DummyComponent("B")
     c.set_child(component1)
     c.set_child(component2)
     self.assertTrue(component1.has_relative_of_type("B"),
                     "No relative with component " + component1.component_type + " was found.")
     self.assertTrue(component1.get_relative_of_type("B") is component2)
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:compositecore_test.py

示例8: new_explosion_cloud

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
def new_explosion_cloud(game_state, density):
    explosion = Composite()
    set_cloud_components(game_state, explosion, density)
    explosion.graphic_char.color_fg = colors.YELLOW
    explosion.set_child(Description("Explosion", "Don't go near it."))
    explosion.set_child(DisappearCloudActor())
    explosion.set_child(ExplosionDamageShareTileEffect())
    explosion.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_explosion_cloud))
    explosion.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.EXPLOSION))
    return explosion
開發者ID:co,項目名稱:TheLastRogue,代碼行數:12,代碼來源:cloud.py

示例9: test_when_a_component_is_overwritten_it_should_not_be_gettable_by_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_when_a_component_is_overwritten_it_should_not_be_gettable_by_tag(self):
     c = Composite()
     component1 = DummyComponent("x", "a")
     component2 = DummyComponent("x", "a")
     component3 = DummyComponent("x", "a")
     c.set_child(component1)
     c.set_child(component2)
     c.set_child(component3)
     self.assertEqual(len(c.get_children_with_tag("a")), 1)
     self.assertFalse(component1 in c.get_children_with_tag("a"))
     self.assertFalse(component2 in c.get_children_with_tag("a"))
     self.assertTrue(component3 in c.get_children_with_tag("a"))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:14,代碼來源:compositecore_test.py

示例10: new_fire_cloud

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
def new_fire_cloud(game_state, density):
    fire = Composite()
    set_cloud_components(game_state, fire, density)
    set_non_flying_cloud_components(fire)
    fire.graphic_char.icon = icon.FIRE
    fire.graphic_char.color_fg = colors.RED
    fire.set_child(Description("Fire", "Don't get burnt."))
    fire.set_child(SpreadToFlammableDisappearActor())
    fire.set_child(FireDamageShareTileEffect())
    fire.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_fire_cloud))
    fire.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FIRE))
    return fire
開發者ID:co,項目名稱:TheLastRogue,代碼行數:14,代碼來源:cloud.py

示例11: test_when_composite_should_be_able_to_get_children_of_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
 def test_when_composite_should_be_able_to_get_children_of_tag(self):
     c = Composite()
     component1 = DummyComponent("x", "a")
     component2 = DummyComponent("y", "a")
     component3 = DummyComponent("z", "a")
     component4 = DummyComponent("Q", "Q")
     c.set_child(component1)
     c.set_child(component2)
     c.set_child(component3)
     c.set_child(component4)
     self.assertFalse(component4 in c.get_children_with_tag("a"))
     self.assertTrue(component1 in c.get_children_with_tag("a"))
     self.assertTrue(component2 in c.get_children_with_tag("a"))
     self.assertTrue(component3 in c.get_children_with_tag("a"))
開發者ID:co,項目名稱:TheLastRogue,代碼行數:16,代碼來源:compositecore_test.py

示例12: test_get_children_with_tag_should_also_get_grandchildren_with_tag

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
    def test_get_children_with_tag_should_also_get_grandchildren_with_tag(self):
        parent = Composite()
        child_1 = TestComponent(id_1, [])
        child_2 = Composite("test")
        grandchild_1 = TestComponent(id_1, [tag_1])
        grandchild_2 = TestComponent(id_2, [tag_2])

        parent.set_child(child_1)
        parent.set_child(child_2)

        child_2.set_child(grandchild_1)
        child_2.set_child(grandchild_2)

        children_with_tag_1 = parent.get_children_with_tag(tag_1)
        self.assertFalse(grandchild_2 in children_with_tag_1, "Grandchild with wrong tag is returned.")
        self.assertTrue(grandchild_1 in children_with_tag_1, "Grandchild is not found.")
開發者ID:co,項目名稱:TheLastRogue,代碼行數:18,代碼來源:composite_test.py

示例13: new_poison_cloud

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
def new_poison_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.GREEN
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_poison_cloud))
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.POISON))
    cloud.set_child(PoisonCloudShareTileEffect())
    return cloud
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:cloud.py

示例14: new_frost_cloud

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
def new_frost_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.LIGHT_BLUE
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_frost_cloud))
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FROST))
    cloud.set_child(FrostCloudShareTileEffect())
    return cloud
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:cloud.py

示例15: new_dust_cloud

# 需要導入模塊: from compositecore import Composite [as 別名]
# 或者: from compositecore.Composite import set_child [as 別名]
def new_dust_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.LIGHT_ORANGE
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_dust_cloud))
    cloud.set_child(DustLowerHitOfEntityShareTileEffect())
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.DUST))
    return cloud
開發者ID:co,項目名稱:TheLastRogue,代碼行數:11,代碼來源:cloud.py


注:本文中的compositecore.Composite.set_child方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。