[Unity] Study_001

APP 2019. 11. 5. 17:59

App을 만들어서 진입지점을 만들고, 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 () {
		
	}
}

 

 

 

: