3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ドラクエの戦闘開始時の敵モンスター名表示

Last updated at Posted at 2013-10-18

スクリーンショット 2013-10-18 23.36.59.jpg

"ドラクエフォント"と言うフォントを使ってUnityでドラクエの戦闘画面くらいは作ってみようとやってました。

this.guiText.text = "&#########################’\n" +
					"”  < <   <                $\n" +
					"”エロほうすのこうけき!              $\n" +
					"”>            <  <        $\n" +
					"”ヒサロナイトAに 33のタメーシ!        $\n" +
					"”                         $\n" +
					"”                         $\n" +
					"”                         $\n" +
					"”                         $\n" +
					")%%%%%%%%%%%%%%%%%%%%%%%%%(";

こういう感じで一文字ずつ全角の文字が特定のドラクエフォントに対応するので、文字列に入力してやってみようと言う試みです。最後まで作りきるか途中で無理そうになって諦めるかはまだ分かりません。ここでの文章はすべてこういう風にやったという自分だけの前提で進めたものであることをご理解お願いいたします。

■戦闘開始時の敵モンスター名の表示

まずは戦闘開始時にランダムで選ばれた敵モンスター名を表示するところです。
濁点を表示するのに1行使うので敵モンスター名は2行で表示します。ドラクエフォントでは濁点は全角の"<"で表示出来ます。

今、敵モンスター名の濁点を表す文字列が次の関数の第一引数enemy_name_1、濁点を除いた名前を表す文字列を第二引数enemy_name_2とします。

ウインドウに表示出来る文字数は最大25文字です。まず第二引数に与えられた名前の文字列に全角スペースのブランクを何個足したら最大の25文字になるか調べることで敵モンスター名が何文字であるか判定します。

敵モンスター名が何文字であるか判明したら、その名前を表す文字列に"か あらわれた!"と言うお馴染みの文字列を後ろから足します。同じように濁点を表す文字列にも"<       "と言う文字列(「〜が あらわれた!」の「が」の濁点)を後ろから足します。

あとは1行が25文字で構成されるのでピッタリ25文字になるように後ろから全角スペースのブランクを必要な数だけ足します。これでランダムに選ばれた敵モンスターの名前を表示出来るようになりました。

public string EnemyEncountMessage(string enemy_name_1, string enemy_name_2)
{
	
	string enemy_encount_1 = null;
	string enemy_encount_2 = null;
	
	string enemy_encount_message_1 = "<       ";
	string enemy_encount_message_2 = "か あらわれた!";
	
	string blank01 = " ";
	string blank02 = "  ";
	string blank03 = "   ";
	string blank04 = "    ";
	string blank05 = "     ";
	string blank06 = "      ";
	string blank07 = "       ";
	string blank08 = "        ";
	string blank09 = "         ";
	string blank10 = "          ";
	string blank11 = "           ";
	string blank12 = "            ";
	string blank13 = "             ";
	string blank14 = "              ";
	string blank15 = "               ";
	string blank16 = "                ";
	string blank17 = "                 ";
	string blank18 = "                  ";
	string blank19 = "                   ";
	string blank20 = "                    ";
	string blank21 = "                     ";
	string blank22 = "                      ";
	string blank23 = "                       ";
	string blank24 = "                        ";
	string blank25 = "                         ";
	
	if(enemy_name_2.Length + blank15.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank07 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank07 + "$\n";
	}
	else if(enemy_name_2.Length + blank16.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank08 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank08 + "$\n";
	}
	else if(enemy_name_2.Length + blank17.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank09 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank09 + "$\n";
	}
	else if(enemy_name_2.Length + blank18.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank10 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank10 + "$\n";
	}
	 if(enemy_name_2.Length + blank19.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank11 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank11 + "$\n";
	}
	else if(enemy_name_2.Length + blank20.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank12 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank12 + "$\n";
	}
	else if(enemy_name_2.Length + blank21.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank13 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank13 + "$\n";
	}
	else if(enemy_name_2.Length + blank22.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank14 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank14 + "$\n";
	}
	else if(enemy_name_2.Length + blank23.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank15 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank15 + "$\n";
	}
	else if(enemy_name_2.Length + blank24.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank16 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank16 + "$\n";
	}
	else if(enemy_name_2.Length + blank25.Length == DraqueWindow.window_string_max)
	{
		enemy_encount_1 = "”" + enemy_name_1 + enemy_encount_message_1 + blank17 + "$\n";
		enemy_encount_2 = "”" + enemy_name_2 + enemy_encount_message_2 + blank17 + "$\n";
	}
	
	Debug.Log((string)enemy_encount_1 + enemy_encount_2);
	return enemy_encount_1 + enemy_encount_2;
	
}
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?