public override void HitBottom(UnityBlock b) { if (!(this.groundState is FallingState)) { mover.yMoveDir = -1; base.HitBottom(b); if (b is BrickBlock) { BrickBlock brick = (BrickBlock)b; if (!brick.isHit) { SFX.PlayClip(SFX.blockClip); } } else if (b is QuestionBlock) { QuestionBlock question = (QuestionBlock)b; if (!question.struck) { SFX.PlayClip(SFX.coinClip); } } b.HitBottom(); } }
public override void HitTop(UnityBlock b) { if (!(this.groundState is JumpingState) && !(this.groundState is RisingState)) { base.HitTop(b); Land(); } }
public override void HitBottom(UnityBlock b) { if (!(this.groundState is FallingState)) { base.HitBottom(b); mover.yMoveDir = -1; } }
private void Hit(GameObject gameObject) { UnityBlock block = gameObject.GetComponent <UnityBlock>(); if (block != null) { block.Hit(this); } }
protected virtual void CheckForBlockCollisions(UnityMover m) { UnityBlock b = null; Vector2 vec = Vector2.zero; float dst = 10; //initialize this to an unimportant value m.mover.unitTouchCount = 0; m.mover.blockTouchCount = 0; foreach (UnityBlockChunk chunk in m.unityBlockChunksCurrentlyIn) { foreach (UnityBlock uBlock in chunk.unityBlocks) { if (Utility.Intersectcs(m.entity.rect, uBlock.block.rect) && m.gameObject.activeSelf) { Vector2 newVec = m.entity.position - uBlock.block.position; float newDst = newVec.magnitude; if (newDst < dst) { vec = newVec; dst = newDst; b = uBlock; } m.mover.unitTouchCount++; m.mover.blockTouchCount++; } } } if (m.mover.blockTouchCount > 0) { float minAngle = Utility.MinDropAngle(m.entity.rect, b.block.rect); minAngle = 90 - minAngle; float angle = Vector2.Angle(vec, Vector2.up); if (angle < minAngle) { m.HitTop(b); } else if (angle >= minAngle && angle <= 180 - minAngle) { m.HitSide(b, vec.x); } else { m.HitBottom(b); } Debug.DrawRay(b.block.rect.position, vec); } }
public override void HitSide(UnityBlock b, float side) { base.HitSide(b, side); mover.speed *= -1; }
public override void HitTop(UnityBlock b) { base.HitTop(b); Land(); }
public virtual void HitBottom(UnityBlock b) { mover.HitBottom(b.block); }
public virtual void HitSide(UnityBlock b, float side) { mover.HitSide(b.block, side); }
//Block collisions public virtual void HitTop(UnityBlock b) { mover.HitTop(b.block); }