Example #1
0
    private void BulidOrNot()
    {
        if (canBuild && Input.GetMouseButtonDown(0))
        {
            //修正对象坐标
            Vector3 fixedPos = buildingInfo.locat[0, 0].pos;
            fixedPos.x        += buildingInfo.widght / 2f - 0.5f;
            fixedPos.z        += buildingInfo.length / 2f - 0.5f;
            fixedPos.y         = transform.position.y;
            transform.position = fixedPos;

            //修改建造状态
            buildingInfo.didDraw    = false;
            buildingInfo.buildState = BuildState.Normal;
            GridDrawer.DropRectangle(gikey);
            //记录建筑信息
            ctrl.AddNewBuiliding(this);
        }
        else if (Input.GetMouseButtonDown(1))
        {
            //清空建造提示
            GridDrawer.DropRectangle(gikey);
            //销毁对象
            Destroy(gameObject);
            //修改建造状态
            buildingInfo.buildState = BuildState.Normal;
        }
    }