Last active
March 11, 2016 05:47
-
-
Save tetya/83d5fea1bd2880daa1e0 to your computer and use it in GitHub Desktop.
ver1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class ItemBehaviour : MonoBehaviour { | |
private SpawnManager spawn; //<! SpawnManagerで設定 | |
protected GameObject manager; | |
// 派生先で処理を拡張する | |
protected virtual void Start () { | |
//HierarchyからManagerを見つける | |
manager = GameObject.FindWithTag("Manager"); | |
} | |
// Update is called once per frame | |
void Update () { | |
//回転の演出 | |
transform.Rotate(Vector3.up, 5, Space.World); | |
} | |
//InstantiateしたSpawnManagerを受け取る | |
public void SetSpawnManager(SpawnManager spaMan){ | |
spawn = spaMan; | |
} | |
void OnTriggerEnter(Collider other){ | |
//Playerタグを持っているか確認 | |
if(other.tag == "Player"){ | |
GetItem (); | |
} | |
} | |
protected virtual void GetItem(){ | |
//対応するスポーンのカウンターを減らす | |
spawn.counter--; | |
//SEを鳴らす | |
spawn.PlaySE(); | |
//このオブジェクトを破壊 | |
Destroy (gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment