投稿者: chosuke
Unity C# メソッド
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
int playerHp = 100;
int playerAtk = 50;
int bossHp = 100;
int bossAtk = 20;
// Start is called before the first frame update
void Start()
{
Debug.Log(“魔王が現れた!”);
Turn();
Debug.Log(“魔王のHPが” + bossHp + “になった。魔王をやっつけた!”);
}
void Turn()
{
Debug.Log(“勇者HP: ” + playerHp);
Debug.Log(“魔王HP: ” + bossHp);
Debug.Log(“勇者の攻撃 魔王に” + playerAtk + “のダメージを与えた”);
Debug.Log(“魔王の攻撃 勇者に” + bossAtk + “のダメージを与えた”);
playerHp -= bossAtk;
bossHp -= playerAtk;
}
// Update is called once per frame
void Update()
{
// 何か追加の処理があればここに記述する
}
}
Unity C# ゲームプログラミング
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
int playerHp = 100;
int playerAtk = 50;
int bossHp = 100;
int bossAtk = 20;
Debug.Log(“魔王が現れた!”);
Debug.Log(“勇者HP” + playerHp);
Debug.Log(“魔王HP” + bossHp);
Debug.Log(“勇者の攻撃 魔王に” + playerAtk + “のダメージを与えた”);
Debug.Log(“魔王の攻撃 勇者に” + bossAtk + “のダメージを与えた”);
playerHp = bossAtk;
bossHp -= playerAtk;
Debug.Log(“勇者HP” + playerHp);
Debug.Log(“魔王HP” + bossHp);
Debug.Log(“勇者の攻撃 魔王に” + playerAtk + “のダメージを与えた”);
Debug.Log(“魔王の攻撃 勇者に” + bossAtk + “のダメージを与えた”);
playerHp -= bossAtk;
bossHp -= playerAtk;
Debug.Log(“勇者HP” + playerHp);
Debug.Log(“魔王HP” + bossHp);
Debug.Log(“勇者の攻撃 魔王に” + playerAtk + “のダメージを与えた”);
Debug.Log(“魔王の攻撃 勇者に” + bossAtk + “のダメージを与えた”);
playerHp -= bossAtk;
bossHp -= playerAtk;
Debug.Log(“魔王のHPが” + bossHp + “になった。魔王をやっつけた!”);
}
// Update is called once per frame
void Update()
{
}
}
EXCEL UPPER 関数
【EXCEL】 数式と関数
【C#】string型とchar型
using System;
class string01
{
public static void Main()
{
char[] chararray = new char[3];
chararray[0] = 'a';
chararray[1] = 'b';
chararray[2] = 'c';
string str;
str = new string(chararray);
Console.WriteLine(str);
char[] title = { 'a', 'i', 'u', 'e', 'o', 'k' };
string strTitle = new string(title);
Console.WriteLine(strTitle);
string strx = "C#プログラム";
int n = strx.Length;
Console.WriteLine("「{0}」の文字数は{1}です", strx, n);
char c = strx[1];
Console.WriteLine("「{0}」の2番目の文字は「{1}」です", strx, c);
}
}
