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


Golang engine.Arbiter類代碼示例

本文整理匯總了Golang中github.com/vova616/GarageEngine/engine.Arbiter的典型用法代碼示例。如果您正苦於以下問題:Golang Arbiter類的具體用法?Golang Arbiter怎麽用?Golang Arbiter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: OnCollisionEnter

func (pu *PowerUp) OnCollisionEnter(arbiter engine.Arbiter) bool {
	if pu.GameObject() != nil && (arbiter.GameObjectA() == Player || arbiter.GameObjectB() == Player) {
		PowerUpShip(pu.Type)
		pu.GameObject().Destroy()
	}
	return true
}
開發者ID:gulinfang,項目名稱:GarageEngine,代碼行數:7,代碼來源:PowerUp.go

示例2: OnCollisionExit

func (c *Chest) OnCollisionExit(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag == "player" {
			c.playerIn = false
		}
	}
}
開發者ID:banad,項目名稱:PirateLand,代碼行數:7,代碼來源:chest.go

示例3: OnCollisionEnter

func (c *Chest) OnCollisionEnter(arbiter engine.Arbiter) bool {

	if arbiter.GameObjectB().Tag == "player" {
		c.playerIn = true
	}
	return true
}
開發者ID:banad,項目名稱:PirateLand,代碼行數:7,代碼來源:chest.go

示例4: OnCollisionExit

func (pl *Player) OnCollisionExit(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == pl.pSplint {
		pl.pSplint = nil
	} else if arbiter.GameObjectB() == pl.pLader {
		pl.pLader = nil
		pl.GameObject().Physics.Body.IgnoreGravity = false
		pl.GameObject().Sprite.SetAnimation("player_stand")
	}
}
開發者ID:banad,項目名稱:PirateLand,代碼行數:9,代碼來源:player.go

示例5: OnCollisionEnter

func (s *Item) OnCollisionEnter(arbiter engine.Arbiter) bool {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag == "player" {
			if s.takeable {
				s.coll(s.GameObject())
				s.GameObject().Destroy()
			}
		}
	}
	return true
}
開發者ID:banad,項目名稱:PirateLand,代碼行數:11,代碼來源:item.go

示例6: OnCollisionEnter

func (sp *PlayerController) OnCollisionEnter(arbiter engine.Arbiter) bool {
	//println("Enter " + arbiter.GameObjectB().Name())
	count := 0
	for _, con := range arbiter.Contacts {
		//println(arbiter.Normal(con).Y)
		if -arbiter.Normal(con).Y > 0.9 {
			count++
		}
	}
	if count >= 2 {
		sp.Floor = arbiter.GameObjectB()
	}

	return true
}
開發者ID:gulinfang,項目名稱:GarageEngine,代碼行數:15,代碼來源:PlayerController.go

示例7: OnCollisionEnter

func (ds *Destoyable) OnCollisionEnter(arbiter engine.Arbiter) bool {
	if !ds.Alive {
		return true
	}
	var dmg *DamageDealer = nil
	var enemyDestoyable *Destoyable

	enemy := arbiter.GameObjectB()

	if enemy == nil {
		return true
	}

	dmg, _ = enemy.ComponentTypeOf(dmg).(*DamageDealer)
	enemyDestoyable, _ = enemy.ComponentTypeOf(enemyDestoyable).(*Destoyable)

	if enemyDestoyable == nil || enemyDestoyable.Team == ds.Team {
		return true
	}

	if dmg != nil {
		ds.HP -= dmg.Damage
	}
	if ds.destoyableFuncs != nil {
		ds.destoyableFuncs.OnHit(enemy, dmg)
	}

	if ds.HP <= 0 {
		ds.Alive = false
		if ds.destoyableFuncs != nil {
			ds.destoyableFuncs.OnDie(false)
		} else {
			ds.GameObject().Destroy()
		}
	}

	return true
}
開發者ID:gulinfang,項目名稱:GarageEngine,代碼行數:38,代碼來源:Destroyable.go

示例8: OnCollisionPostSolve

func (pl *Player) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == nil {
		return
	}
	if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
		count := 0
		for _, con := range arbiter.Contacts {
			if arbiter.Normal(con).Y < -0.9 {
				count++

			}
		}
		if count >= 1 {
			if pl.GameObject().Sprite.CurrentAnimation() == "player_jump" {
				pl.GameObject().Sprite.SetAnimation("player_stand")
			}
			pl.LastFloor = arbiter.GameObjectB()

			pl.OnGround = true
		}
	}

}
開發者ID:banad,項目名稱:PirateLand,代碼行數:23,代碼來源:player.go

示例9: OnCollisionEnter

func (pl *Player) OnCollisionEnter(arbiter engine.Arbiter) bool {

	if arbiter.GameObjectB().Tag == "lader" {
		pl.pLader = arbiter.GameObjectB()
		if pl.GameObject().Sprite.CurrentAnimation() != "player_climb" {
			pl.GameObject().Sprite.SetAnimation("player_climb")
		}
		pl.GameObject().Physics.Body.IgnoreGravity = true
		pl.OnGround = false
	}
	if pl.Hitable && arbiter.GameObjectB().Tag == "splinter" {
		pl.pSplint = arbiter.GameObjectB()
		engine.StartCoroutine(func() {
			for pl.pSplint != nil {
				pl.Hit()
				engine.CoYieldCoroutine(pl.Hitted)
			}
		})
	}
	return true
}
開發者ID:banad,項目名稱:PirateLand,代碼行數:21,代碼來源:player.go

示例10: OnCollisionPostSolve

func (s *Enemy) OnCollisionPostSolve(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag != "lader" && arbiter.GameObjectA().Tag != "lader" {
			count := 0
			for _, con := range arbiter.Contacts {
				if arbiter.Normal(con).Y < -0.9 {
					count++

				}
			}
			if count >= 1 {
				if s.GameObject().Sprite.CurrentAnimation() == "enemy_jump" {
					s.GameObject().Sprite.SetAnimation("enemy_stand")
				}
				s.LastFloor = arbiter.GameObjectB()

				s.OnGround = true
			}
			count = 0
			for _, con := range arbiter.Contacts {
				if math.Abs(float64(arbiter.Normal(con).X)) > 0.9 {
					count++

				}
			}
			if count >= 1 {
				s.jump = true
			}
			if arbiter.GameObjectB().Tag == "player" {
				if Player.PlComp.Hitable && s.Attack {
					Player.PlComp.Hit()
				}
				if s.hitable && Player.PlComp.Attack {
					s.Hit()
				}
			}
		}
	}

}
開發者ID:banad,項目名稱:PirateLand,代碼行數:40,代碼來源:Enemy.go

示例11: OnCollisionExit

func (sp *PlayerController) OnCollisionExit(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == sp.Floor {
		sp.Floor = nil
	}
}
開發者ID:gulinfang,項目名稱:GarageEngine,代碼行數:5,代碼來源:PlayerController.go


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