Exemple #1
0
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
}
Exemple #2
0
func (c *Chest) OnCollisionExit(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() != nil {
		if arbiter.GameObjectB().Tag == "player" {
			c.playerIn = false
		}
	}
}
Exemple #3
0
func (c *Chest) OnCollisionEnter(arbiter engine.Arbiter) bool {

	if arbiter.GameObjectB().Tag == "player" {
		c.playerIn = true
	}
	return true
}
Exemple #4
0
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")
	}
}
Exemple #5
0
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
}
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
}
Exemple #8
0
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
}
Exemple #9
0
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()
				}
			}
		}
	}

}
Exemple #10
0
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
		}
	}

}
func (sp *PlayerController) OnCollisionExit(arbiter engine.Arbiter) {
	if arbiter.GameObjectB() == sp.Floor {
		sp.Floor = nil
	}
}