コード例 #1
0
ファイル: AIBase.cs プロジェクト: LeafMountain/Kroken
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (aiCheckStatus.DidNotHitEnemy(collision))
        {
            if (aiCheckStatus.IsThistoTheRightOfMe(collision) || aiCheckStatus.IsThisToTheLeftOfMe(collision))
            {
                aiMovement.InvertXDirection();

                if (myType != EnemyType.Floater && myType != EnemyType.Surfer)
                {
                    AIVisuals.FlipSpriteOnX(mySpriteRenderer,
                                            waterParticles.GetComponent <SpriteRenderer>(),
                                            aiMovement.direction.x, myType);
                }
            }

            if (aiCheckStatus.IsThisAboveMe(collision) || aiCheckStatus.IsThisBeneathMe(collision))
            {
                aiMovement.InvertYDirection();
            }
        }
        else if (aiCheckStatus.HitEnemy(collision) && aiCheckStatus.IsWhatIHitBigger(collision))
        {
            if (aiCheckStatus.IsThistoTheRightOfMe(collision) || aiCheckStatus.IsThisToTheLeftOfMe(collision))
            {
                aiMovement.InvertXDirection();

                if (myType != EnemyType.Floater && myType != EnemyType.Surfer)
                {
                    AIVisuals.FlipSpriteOnX(mySpriteRenderer,
                                            waterParticles.GetComponent <SpriteRenderer>(),
                                            aiMovement.direction.x, myType);
                }
            }

            if (aiCheckStatus.IsThisAboveMe(collision) || aiCheckStatus.IsThisBeneathMe(collision))
            {
                aiMovement.InvertYDirection();
            }
        }
    }