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 }
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 }
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 }
func (sp *PlayerController) OnCollisionExit(arbiter engine.Arbiter) { if arbiter.GameObjectB() == sp.Floor { sp.Floor = nil } }