2019-03-06 23:00:42 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Cylinder : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public List<GameObject> discs;
|
|
|
|
|
|
|
|
|
|
public float baseX;
|
|
|
|
|
public float baseY;
|
|
|
|
|
public float baseZ;
|
|
|
|
|
|
|
|
|
|
private float diffY = 1.5f;
|
|
|
|
|
private float startY = -6.5f;
|
|
|
|
|
|
|
|
|
|
public bool selected = false;
|
2019-03-07 21:18:46 +00:00
|
|
|
|
public GameObject control;
|
2019-03-06 23:00:42 +00:00
|
|
|
|
|
|
|
|
|
void UpdateLight()
|
|
|
|
|
{
|
|
|
|
|
if (this.selected)
|
|
|
|
|
{
|
2019-03-07 21:18:46 +00:00
|
|
|
|
this.control.transform.position = new Vector3(this.baseX, 10, this.baseZ);
|
2019-03-06 23:00:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanPutDisc(GameObject disc)
|
|
|
|
|
{
|
|
|
|
|
if (this.discs.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.discs[this.discs.Count - 1].GetComponent<Disc>().size > disc.GetComponent<Disc>().size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GameObject GetTopDisc()
|
|
|
|
|
{
|
|
|
|
|
GameObject topDisc = this.discs[this.discs.Count - 1];
|
|
|
|
|
this.discs.RemoveAt(this.discs.Count - 1);
|
|
|
|
|
return topDisc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
float y = this.startY;
|
|
|
|
|
foreach (GameObject disc in this.discs)
|
|
|
|
|
{
|
|
|
|
|
disc.transform.position = new Vector3(this.baseX, y, this.baseZ);
|
|
|
|
|
y += this.diffY;
|
|
|
|
|
}
|
|
|
|
|
this.UpdateLight();
|
|
|
|
|
}
|
|
|
|
|
}
|