Beispiel #1
0
    public void SetBrushCenter(int x, int z)
    {
        _brushCenter.x = (float)x;
        _brushCenter.y = (float)z;

        Vector3 vRealPos = StageUtil.GetElementWorldPos(_paintType, x, z);

        if (_curBrushShape != null)
        {
            _curBrushShape.transform.position = vRealPos;
        }
    }
Beispiel #2
0
    void CreateStageElement(StageData.StageElement ele, int x, int z, List <GameObject> list)
    {
        if (ele == StageData.StageElement.None)
        {
            return;
        }
        GameObject stageRoot = GameObject.Find("World/Stage");

        if (stageRoot == null)
        {
            return;
        }
        if (_resources[StageUtil.GetPaintTypeIndex(ele)] == null)
        {
            return;
        }
        GameObject newObj = GameObject.Instantiate(_resources[StageUtil.GetPaintTypeIndex(ele)]) as GameObject;

        newObj.transform.position = StageUtil.GetElementWorldPos(ele, x, z);
        newObj.transform.SetParent(stageRoot.transform);
        list.Add(newObj);
    }
Beispiel #3
0
    void UpdatePaintType()
    {
        if (_curBrushShape)
        {
            GameObject.DestroyImmediate(_curBrushShape);
        }

        UnityEngine.Object asset = _resources[StageUtil.GetPaintTypeIndex(_paintType)];
        if (asset != null)
        {
            GameObject obj = UnityEngine.Object.Instantiate(asset) as GameObject;
            obj.transform.SetParent(gameObject.transform);
            obj.transform.position = StageUtil.GetElementWorldPos(_paintType, _brushCenter.x, _brushCenter.y);

            MeshRenderer renderer = obj.GetComponent <MeshRenderer>();
            if (renderer != null)
            {
                renderer.sharedMaterial.shader = Shader.Find("Legacy Shaders/Transparent/Diffuse");
                renderer.sharedMaterial.SetColor("Main Color", new Color(1f, 1f, 1f, 0.5f));
            }

            _curBrushShape = obj;
        }
    }