800*600
http://sourceforge.net/projects/project-autoset/postdownload?source=dlp
jdk-7u79-windows-i586.exe 다운
http://autoset.net/xe/download_autoset_9_0_0
https://dev.mysql.com/downloads/workbench/ 다운
Windows (x86, 32-bit), MSI Installer |
상속은 클래스명 앞에 반드시 abstract 를 붙인다!
상속받은 자식은 override 를 붙인다!!
==[interface]==============================================================
using UnityEngine;
using System.Collections;
public interface IFMeet{
void Meet(CPlayer player);
}
==[player]==============================================================
using UnityEngine;
using System.Collections;
public class CPlayer : MonoBehaviour
{
public float speed = 5;
public int _hp;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(Vector2.right * h * speed * Time.deltaTime);
transform.Translate(Vector2.up * v * speed * Time.deltaTime);
}
public void Hit(int damage)
{
HpDown(damage);
if (damage <= 0)
{
Die();
}
Debug.Log("플레이어의 현재 체력은 : " + _hp);
}
public void Die()
{
Debug.Log("플레이어가 사망 했습니다,");
_hp = 0;
Destroy(gameObject, 0.5f);
}
public void HpUp(int hp)
{
Debug.Log("플레이어의 체력이" + hp + "만큼 채워집니다");
_hp += hp;
}
public void HpDown(int damage)
{
Debug.Log("플레이어가 " + damage + " 만큼 타격받았습니다.");
_hp -= damage;
}
void OnTriggerEnter2D(Collider2D col)
{
Debug.Log("부딪힌 몬스터 : " + col.name);
IFMeet Met = col.GetComponent<IFMeet>();
Met.Meet(this);
}
}
==[monster]==============================================================
using UnityEngine;
using System.Collections;
// 클래스명 앞에 반드시 abstract 붙일것
public abstract class CMonster : MonoBehaviour, IFMeet
{
public int _damage;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Meet(CPlayer player)
{
Attack(player);
}
// 상속을 줄때 abstract를 붙인다.
// CMonster 상속한 모든 클래스는 Attack메소드를 구현 해야 함.
public abstract void Attack(CPlayer player);
}
==[mon1]==============================================================
using UnityEngine;
using System.Collections;
public class mon1 : CMonster
{
public override void Attack(CPlayer player)
{
Debug.Log(gameObject.name + " 에게 공격 받습니다.");
player.Hit(_damage);
}
}
==[mon2]==============================================================
using UnityEngine;
using System.Collections;
public class mon2 : CMonster
{
public override void Attack(CPlayer player)
{
Debug.Log(gameObject.name + "에게 공격받습니다.");
player.Hit(_damage);
}
}
==[cheart]==============================================================
using UnityEngine;
using System.Collections;
public abstract class CHeart : MonoBehaviour, IFMeet
{
public int _hpup;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Meet(CPlayer player)
{
Hpplus(player);
}
public abstract void Hpplus(CPlayer player);
}
==[heart1]==============================================================
using UnityEngine;
using System.Collections;
public class Hert1 : CHeart {
public override void Hpplus(CPlayer player)
{
Debug.Log(_hpup + " 만큼 체력이 회복됩니다.");
player.HpUp(_hpup);
}
}
==[heart2]==============================================================
using UnityEngine;
using System.Collections;
public class Heat2 : CHeart {
public override void Hpplus(CPlayer player)
{
Debug.Log(_hpup + " 만큼 체력이 회복됩니다.");
player.HpUp(_hpup);
}
}
==[trap]==============================================================
using UnityEngine;
using System.Collections;
public class CTrap : MonoBehaviour, IFMeet
{
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Meet(CPlayer player)
{
Death(player);
}
public void Death(CPlayer player)
{
Debug.Log("플레이어가 사망 합니다.");
player.Die();
}
}
==[bomb]==============================================================
using UnityEngine;
using System.Collections;
public class CBomb : MonoBehaviour, IFMeet
{
float time = 1f;
int _damage = 30;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Meet(CPlayer player)
{
Boomb(player);
}
public void Boomb(CPlayer player)
{
Debug.Log("폭탄이 폭발합니다.");
StartCoroutine(Timer(player));
}
public IEnumerator Timer(CPlayer player)
{
int i = 3;
while (i >= 1)
{
Debug.Log("폭탄 폭발 " + i + " 초전");
yield return new WaitForSeconds(time);
i--;
}
player.Hit(_damage);
}
}
댓글
댓글 쓰기