Speeed! (スピーード!)
開発中
Running Dungeon(ランニングダンジョン)
開発中
ツール:Unity、Visual Studio
言語: C#
プラットフォーム: Android
こちらは横スクロールRPGランゲーム。走る、ジャンプ、スライディング、の3つの基本操作でプレイヤーは永遠とダンジョンを進んでいきスコアを競い合うゲームです。アイテムなどをショップで買い、装備することでどんどん前に進めることができます。
キャラクターもダンジョンも複数あり、どのアイテムがどのキャラクターに、どのダンジョンに活用できるのかなどをプレイヤーに考えさせるところがポイントです。
私はプログラム、と絵の両方担当しております。またプログラムの方はGitHubにアップロードされておりませんので、こちらで一部を紹介させていただきます。
using UnityEngine;
using System.Collections;
public class BatScript : MonoBehaviour
{
public GameObject parent;
private bool m_counterClockWise = true;
// 円の半径
private float r;
private float x;
private float y;
// 角度
private float alfa;
private Vector2 basePoint;
void calcBat()
{
Vector2 offset;
offset.x = parent.transform.position.x + 0.5f;//transform.parent.transform.position.x;
offset.y = basePoint.y;//transform.parent.transform.position.y;
x = Mathf.Cos (alfa) * r;
y = Mathf.Sin (alfa) * r;
Vector3 newPos = new Vector3 (offset.x + x, offset.y + y);
transform.position = newPos;
}
// Use this for initialization
void Start ()
{
var random = Random.Range(0, 2);
if(random == 0)
{
m_counterClockWise = true;
}
else
{
m_counterClockWise = false;
}
alfa = 0.0f;
r = 1.45f;
basePoint = new Vector2 (transform.position.x, transform.position.y);
Vector2 offset;
offset.x = basePoint.x;
offset.y = basePoint.y;//transform.parent.transform.position.y;
x = Mathf.Cos (alfa) * r;
y = Mathf.Sin (alfa) * r;
Vector3 newPos = new Vector3 (offset.x + x, offset.y + y);
transform.position = newPos;
}
// Update is called once per frame
void Update ()
{
if (m_counterClockWise)
alfa += 2.0f * Time.deltaTime;
else
alfa -= 2.0f * Time.deltaTime;
calcBat ();
}
}
モンスター基本行動スクリプト
using UnityEngine;
using System.Collections;
//Lizard script has a simple attacking behaviour
public class LizardScript : MonoBehaviour {
[SerializeField]
private int m_maxHp = 30;
private int m_hp;
private bool m_inCombat = false;
private bool m_attacking = false;
[SerializeField]
private float m_waitingTime = 1.5f;
private float m_timeCounter = 0.0f;
private float m_impulseTime = 0.6f;
private float m_reverseTime = 0.8f;
private float m_resetTime = 1.5f;
private Vector3 m_originalPos;
private Vector3 m_originalScale;
private GameObject m_hpBar;
private PlayerStates m_playerStates;
private int m_rarity = 0;
//of 100%
private int m_dropRate = 50;
// Use this for initialization
void Start ()
{
m_originalPos = transform.position;
m_hpBar = transform.FindChild("hpBar").gameObject;
m_originalScale = m_hpBar.transform.localScale;
m_hp = m_maxHp;
var character = GameObject.Find("character");
m_playerStates = character.GetComponent<PlayerStates>();
}
void DropChest()
{
m_playerStates.DropChest();
}
void UpdateHPBar()
{
var scale = m_hpBar.transform.localScale;
//rule of three calculation
//max hp ----- 100%
//current hp ---- X?
scale.x = ((float)(m_hp * m_originalScale.x) / (float)m_maxHp);
m_hpBar.transform.localScale = scale;
if(m_hp <= 0)
{
transform.tag = "Untagged";
transform.name = "deadMonster";
m_playerStates.SetCombat(false);
var luck = m_playerStates.GetLuck() * 2;
var dropped = Random.Range(0, 100);
if(m_dropRate + luck >= dropped)
{
//drop chest
DropChest();
}
}
}
// Update is called once per frame
void Update ()
{
if(transform.tag == "InCombatMonster")
{
//receive dmg
if(m_playerStates.GetAttack())
{
var dmg = m_playerStates.GetDamage();
if(dmg > m_hp)
{
m_hp -= m_hp;
}
else
{
m_hp -= dmg;
}
UpdateHPBar();
m_playerStates.SetAttack(false);
}
//Wait and start attacking
if (!m_attacking)
{
m_timeCounter += Time.deltaTime;
//time to attack
if (m_timeCounter >= m_waitingTime)
{
m_attacking = true;
m_timeCounter = 0.0f;
m_originalPos = transform.position;
}
}
//hard coded attack animation
else
{
m_timeCounter += Time.deltaTime;
if (m_timeCounter <= m_impulseTime)
{
var pos = transform.position;
pos.x = Mathf.MoveTowards(pos.x, (m_originalPos.x + 1.0f), 1.66f * Time.deltaTime);
transform.position = pos;
}
else
{
if (m_timeCounter <= m_reverseTime)
{
var pos = transform.position;
pos.x = Mathf.MoveTowards(pos.x, (m_originalPos.x - 1.0f), 10.0f * Time.deltaTime);
transform.position = pos;
}
else
{
var pos = transform.position;
pos.x = Mathf.MoveTowards(pos.x, (m_originalPos.x), 5.33f * Time.deltaTime);
transform.position = pos;
if(m_timeCounter >= m_resetTime)
{
m_attacking = false;
m_timeCounter = 0.0f;
}
}
}
}
}
}
}