Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MoveAreaController : MonoBehaviour {
- public MainController MainControllerInst;
- public static List<MoveAreaController> areas = new List<MoveAreaController>();
- public MoveAreaController moveareas;
- // Use this for initialization
- void Start () {
- MainControllerInst = GameObject.Find("MainController").GetComponent<MainController>();
- }
- // Update is called once per frame
- void Update () {
- if (MainControllerInst.statusFlag == 2) {
- this.ShowMoveArea();
- }
- if (MainControllerInst.statusFlag == 4) {
- this.ClearMoveArea();
- }
- }
- public void ShowMoveArea() {
- //移動範囲にオブジェクトを作成
- CubeController cubeControllerInst = GameObject.Find("Cube").GetComponent<CubeController>();
- Vector3 nowVec3Pos = cubeControllerInst.transform.position;
- MoveAreaController areatemp;
- areatemp = Instantiate(this, new Vector3(nowVec3Pos.x - 1.0f, nowVec3Pos.y -0.49f, nowVec3Pos.z), Quaternion.identity);
- areas.Add(areatemp);
- areatemp = Instantiate(this, new Vector3(nowVec3Pos.x + 1.0f, nowVec3Pos.y - 0.49f, nowVec3Pos.z), Quaternion.identity);
- areas.Add(areatemp);
- areatemp = Instantiate(this, new Vector3(nowVec3Pos.x, nowVec3Pos.y - 0.49f, nowVec3Pos.z - 1.0f), Quaternion.identity);
- areas.Add(areatemp);
- areatemp = Instantiate(this, new Vector3(nowVec3Pos.x, nowVec3Pos.y - 0.49f, nowVec3Pos.z + 1.0f), Quaternion.identity);
- areas.Add(areatemp);
- //MainController MainControllerInst = GameObject.Find("MainController").GetComponent<MainController>();
- MainControllerInst.statusFlag = 3;
- }
- public void ClearMoveArea() {
- if(areas.Count > 1) {
- for(int i = areas.Count -1; i >= 0; --i) {
- Destroy(areas[i].gameObject);
- areas.RemoveAt (i);
- }
- }
- MainControllerInst.statusFlag = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement