LoginSignup
15
1

More than 3 years have passed since last update.

借金の利息がバーチャルペットになって画面を散歩するアプリを作ります

Last updated at Posted at 2020-12-18

この記事は

「クソアプリ2 Advent Calendar 2020」の19日目の記事となります。

はじめに

親の教えとして「何事もポジティブに」と教育を受けてきました。
おかげか大体のことはポジティブに考えることがきました。

しかし、世の中には無理じゃね?というものもあります。

       借 金

どうポジティブにとらえたらいいんだ。。。
負のものしか含まれていないぞ。
ポケ〇ンをやりながら考えていました。

モ、モンスターにおきかえてみるか。

できたもの

借金をリボモンというモンスターで管理できる財テクアプリです。

AppStoreリンク
https://apps.apple.com/us/app/%E3%83%AA%E3%83%9C%E3%83%A2%E3%83%B3/id1544644650

image.png

コンセプト

借金をするほど強くなる(ポジティブに見える)アプリをつくる。

開発ツール

Unity

生まれたもの

7.gif

タイトル通り散歩します、借金が。

5千兆円借金してみる

7.gif

う、うわああああああああああ。

色々とバグってますがあれです。
クソアプリなんで許して。

最低限の借金返済アプリの体裁は一応整えていたりします

モンスターをタッチすると借金返済できます。
ギリギリ使えるレベルにするのもクソアプリ製作の楽しいところですよね。
8.gif

実装

カレンダーの実装は下サイトから頂戴しました
Unityのカレンダーアセット作った!-alberttecの日記
今回のクソアプリで見た目部分も着手できたのはカレンダー配布がめちゃ大きいです。神配布感謝です。

キャラクターはアセットストアで購入(7$)
Pixel Mobs-UnityeAssetStore

キャラクターの移動
SetNextPosition()で移動先を指定してLerpで移動。
移動が完了したらRecenter()で移動先を再指定です。

mob.cs
void Update()
{
    float interval = 5;
    elapsedTime += Time.deltaTime / interval ;

    Vector2 tmpPos = Vector2.Lerp(beforePosition, nextPosition, elapsedTime);
    rectTransform.localPosition = new Vector3(tmpPos.x, tmpPos.y, 0);

    if (IsMoved)
    {
        Init();
    }
}

private void Init()
{
    SetNextPosition();
    elapsedTime = 0;
}

public void Recenter()
{
    beforePosition = new Vector2(rectTransform.localPosition.x, rectTransform.localPosition.y);
    elapsedTime = 0;
}

private void SetNextPosition()
{
    beforePosition = new Vector2(rectTransform.localPosition.x, rectTransform.localPosition.y);
    int randX = Random.Range(-MaxX, MaxX);
    int randY = Random.Range(-MaxY, MaxY);
    nextPosition = new Vector2(randX, randY);
}

借金の計算式系
コア部分を抜粋したものです。
LoanPrincipalListには元金
LoanAnnualInterestListには利率
です。
最初、doubleではなくfloatで型指定した結果、1000万以上借金をすると100円になる素敵なバグが発生しました。

LoanCalculation.cs
// 元金
public double GetPrincipal(int index)
{
    return LoanPrincipalList.Count == 0 ? 0 : LoanPrincipalList[index];
}

// 1日あたりの利息
public double GetOneDayDebt(int index)
{
    double pricipal = LoanPrincipalList.Count != 0 ? LoanPrincipalList[index] : 0;
    double annualInterest = LoanAnnualInterestList.Count != 0 ? LoanAnnualInterestList[index] : 0;
    double oneYearDebt = pricipal * (annualInterest / 100);// 100は百分率になおしている
    return Math.Round(oneYearDebt / OneYear);// 365は1年
}

public double GetTotalMoney(int index)
{
    double pricipal = LoanPrincipalList.Count == 0 ? 0 : LoanPrincipalList[index];
    double annualInterest = LoanAnnualInterestList.Count == 0 ? 0 : LoanAnnualInterestList[index];

    double totalDebt = GetTotalDebt(index);
    return pricipal + totalDebt;
}

// 利息の合計
public double GetTotalDebt(int index)
{
    double diffTotalDays = GetDifferenceTotalDays(index);// 現在日から支払日までの差
    double oneDayPricipal = GetOneDayDebt(index);// 一日あたりの年利
    return Math.Ceiling(diffTotalDays * oneDayPricipal);// 年利で発生した金額
}

// 現在日から支払日の差
private double GetDifferenceTotalDays(int index)
{
    DateTime today = DateTime.Today;
    DateTime loanLastRepaymentHistory = (LoanLastRepaymentHistory.Count != 0 ? LoanLastRepaymentHistory[index] : today);

    TimeSpan diffDay = (today - loanLastRepaymentHistory);
    return diffDay.TotalDays;
}

余談

せっかくつくったのでAppleStoreに申請しようとたところキーワードという欄があるそうです。
アプリ検索用に100字以内で検索ワードを記述できるようです。

実際に記述したもの

ギャンブル,サラ金,デビット,プロミス,モビット,リボ,リボモン,リボルビング,レイク,ローン,借入,借金,債務,元金,利子,利息,残高,消費者金融,計算,負債,返済,金利

この世の地獄みたいなキーワードランキングがあったら上位に食い込めそうです。

最後に

借金が増えるほどモンスターがいっぱいになっていきます。
なんか楽しい気持ちになってきた気がします。
これで少しは借金をポジティブに考えられるようになった気がします。
わーい。
めでたしめでたし。

15
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
1