コード例 #1
0
ファイル: DbWheel.cs プロジェクト: mxdy/CircusBall
    public override void OnTriggerWheel(GameObject other)
    {
        base.OnTriggerWheel(other);

        if (other.gameObject.tag != "wheelOfMine" &&
            other.gameObject.tag != "Scenery" &&
            other.gameObject.tag != "Player")
        {
            Wheel other_wheel = other.gameObject.GetComponent <Wheel>();

            // 还没有检测
            if (!isChecked)
            {
                isChecked             = true;
                other_wheel.isChecked = true;

                // 反向
                if (other_wheel.velocity * velocity <= 0)
                {
                    ChangeDir();
                    other_wheel.ChangeDir();
                }
                else // 同向
                {
                    if (Mathf.Abs(other_wheel.velocity) >= Mathf.Abs(velocity))
                    {
                        other_wheel.ChangeDir();
                    }
                    else
                    {
                        ChangeDir();
                    }
                }
            }
            else
            {
                ChangeDir();
            }
        }
    }