コード例 #1
0
    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();
        }
    }
コード例 #2
0
 public override void HitTop(UnityBlock b)
 {
     if (!(this.groundState is JumpingState) && !(this.groundState is RisingState))
     {
         base.HitTop(b);
         Land();
     }
 }
コード例 #3
0
    public override void HitBottom(UnityBlock b)
    {
        if (!(this.groundState is FallingState))
        {
            base.HitBottom(b);

            mover.yMoveDir = -1;
        }
    }
コード例 #4
0
    private void Hit(GameObject gameObject)
    {
        UnityBlock block = gameObject.GetComponent <UnityBlock>();

        if (block != null)
        {
            block.Hit(this);
        }
    }
コード例 #5
0
ファイル: MoveState.cs プロジェクト: Kobakat/Super-Oiram
    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);
        }
    }
コード例 #6
0
 public override void HitSide(UnityBlock b, float side)
 {
     base.HitSide(b, side);
     mover.speed *= -1;
 }
コード例 #7
0
 public override void HitTop(UnityBlock b)
 {
     base.HitTop(b);
     Land();
 }
コード例 #8
0
 public virtual void HitBottom(UnityBlock b)
 {
     mover.HitBottom(b.block);
 }
コード例 #9
0
 public virtual void HitSide(UnityBlock b, float side)
 {
     mover.HitSide(b.block, side);
 }
コード例 #10
0
 //Block collisions
 public virtual void HitTop(UnityBlock b)
 {
     mover.HitTop(b.block);
 }