コード例 #1
0
 private void Generate()
 {
     _manager   = FindObjectOfType <MANAGER.CityManager>();
     myRenderer = this.GetComponent <MeshRenderer>();
     myMesh     = this.GetComponent <MeshFilter>();
     this.GetComponent <MeshCollider>().enabled = false;
 }
コード例 #2
0
 void OnEnable()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Destroy(gameObject);
     };
 }
コード例 #3
0
        private void PlaceBlock(int slope, int nextRotation, int x, int y, int z)
        {
            Vector3    incVector = Vector3.right * inc_x + Vector3.up * inc_y + Vector3.forward * inc_z;
            Quaternion nextQuat  = Quaternion.Euler(0f, nextRotation, 0f);

            //Debug.Log(CityManager.CheckTile(x + inc_x, y + inc_y, z + inc_z));
            if (CityManager.CheckTile(x + inc_x, y + inc_y, z + inc_z) == false)
            {
                CityManager.floorOccupied[x + inc_x, y + inc_y, z + inc_z] = true;
                child        = Instantiate(tilePrefab, transform.position + (incVector * CityManager.size), nextQuat);
                child.parent = this.transform;
                child.GetComponent <RouteTile>().Initialize(slope, nextRotation);
                recursionCount++;
            }
            else if (recursionCount > 0)
            {
                Destroy(this);
            }
        }
コード例 #4
0
    public void Begin()
    {
        _city = MANAGER.CityManager.Instance;
        if (recursion <= 0)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _size = MANAGER.CityManager.size;
            switch (tileType)
            {
            case 0:
                //meshstuff
                break;

            case 1:
                //meshstuff
                break;

            case 2:
                //meshstuff
                break;

            default:
                posX = MANAGER.CityManager.floorOccupied.GetLength(0) / 2;
                posY = 0;
                posZ = MANAGER.CityManager.floorOccupied.GetLength(2) / 2;
                float xPos = posX - MANAGER.CityManager.floorOccupied.GetLength(0) / 2;
                float zPos = posZ - MANAGER.CityManager.floorOccupied.GetLength(2) / 2;
                this.transform.position = new Vector3((xPos * _size) + _size / 2, (posY * _size), (zPos * _size) + _size / 2);
                break;
            }
            //Debug.Log(posX + "  " + posY + "  " + posZ);
            CheckNewTile();
        }
    }