[Unity] Study_001
APP 2019. 11. 5. 17:59App을 만들어서 진입지점을 만들고, App의 속성에 Item과 Weapon을 추가했다.
GameObject인 Item과 Weapon을 만들고,
Script인 Item 과 Weapon을 각각 Component로서 추가했다.
App.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Study_001;
public class App : MonoBehaviour {
public int hp;
public int hitDamage;
public string name;
public float range;
public bool hasSkill;
public Item item;
public Weapon weapon;
void Awake()
{
Debug.Log("App클래스의 Awake메서드 호출됨");
}
void OnEnable()
{
Debug.Log("App클래스의 OnEnable메서드 호출됨");
}
// Use this for initialization
void Start () {
Debug.Log("Start");
this.hp = 100;
Debug.LogFormat("hp: {0}",this.hp);
var test = new Test();
Debug.LogFormat("test: {0}", test);
hp -= hitDamage;
Debug.LogFormat("홍길동의 Hp는 {0}", hp);
Debug.LogFormat("홍길동의 사정거리는 {0}", range);
if (hasSkill)
{
Debug.LogFormat("스킬을 가지고 있습니다.");
}
else
{
Debug.LogFormat("스킬을 가지고 있지 않습니다.");
}
}
// Update is called once per frame
void Update () {
Debug.Log("Update");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapon : Item {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
'APP' 카테고리의 다른 글
[Unity] 코루틴으로 이동하는것 해볼것 (0) | 2019.11.13 |
---|---|
[Unity] 2019-11-13 Study_002 역직렬화(캐릭터,웨폰) 인게임(캐릭터,웨폰 생성) (0) | 2019.11.13 |
[Unity] 2019-11-11 Study002 캐릭터의 이동, 애니메이션, grandchild 찾기 (0) | 2019.11.12 |
[Unity] 화살표 그리기 3종류 (0) | 2019.11.07 |
[Unity] Study_002 (0) | 2019.11.05 |