示例#1
0
    private void Init()
    {
        parentObj = GameObject.Find("Parent");
        camera    = GameObject.Find("Main Camera").transform;
        pillar    = GameObject.Find("Pillar").transform;

        ball      = GameObject.Find("Ball");
        ballScale = ball.transform.localScale.x;
        newScale  = ballScale.ToString();

        newSpeed    = PlayerPrefs.GetFloat(PrefConstans.RORATE_SPEED, PrefConstans.DEFAULT_SPEED).ToString();
        newWidth    = PlayerPrefs.GetFloat(PrefConstans.GAMEOBJECT_WIDTH, PrefConstans.DEFAULT_WIDTH).ToString();
        newGravity  = PlayerPrefs.GetFloat(PrefConstans.GRAVITY, PrefConstans.DEFAULT_GRAVITY).ToString();
        newUpSpeed  = PlayerPrefs.GetFloat(PrefConstans.UP_SPEED, PrefConstans.DEFAULT_UP_SPEED).ToString();
        newUpHeight = PlayerPrefs.GetFloat(PrefConstans.UP_DISTANCE, PrefConstans.DEFAULT_UP_DISTANCE).ToString();
        newGap      = PlayerPrefs.GetFloat(PrefConstans.GAMEOBJECT_GAP, PrefConstans.DEFAULT_GAP).ToString();
        newUpSingle = PlayerPrefs.GetFloat(PrefConstans.UP_SINGLE, PrefConstans.DEFAULT_UP_SINGLE).ToString();

        objSaver = new ObjSaver();
        objSaver.Init();
        objData = objSaver.Load();
        SetArrData();

        cubePrefab     = Resources.Load <GameObject>("Models/Cube");
        cylinderPrefab = Resources.Load <GameObject>("Models/Cylinder");

        objCreater = new CreateObj();

        objList = new List <GameObject>();
        InitSavedObj();
        //for (int i = 0; i < parentObj.transform.childCount; i++)
        //{
        //    objList.Add(parentObj.transform.GetChild(i).gameObject);
        //}
    }
示例#2
0
    //创建新模型
    private void CreateNewModel(ModelType mType, GameObject obj, bool needSave)
    {
        obj.transform.SetParent(parentObj.transform);

        obj.name = string.Format("{0:000}{1}", (objList.Count + 1), objName[(int)mType]);
        obj.tag  = objName[(int)mType];

        objList.Add(obj);

        if (needSave)
        {
            if (objData == null)
            {
                objData = new ObjDataBase();
            }
            objData.modelList.Add(new ModelData(mType, PARTS.ONE, 1, 120, 1));
            SetArrData();
            objSaver.ChangeData(objData);
        }

        float curGap = PlayerPrefs.GetFloat(PrefConstans.GAMEOBJECT_GAP, PrefConstans.DEFAULT_GAP);

        obj.transform.localPosition = new Vector3(obj.transform.localPosition.x, -(curGap * (objList.Count - 1)), 0);
        camera.localPosition       -= new Vector3(0, curGap, 0);
        pillar.localPosition       -= new Vector3(0, curGap, 0);
    }
示例#3
0
 public void Init()
 {
     objDataBase  = new ObjDataBase();
     PLATFORMPATH = Application.streamingAssetsPath;
 }
示例#4
0
 public void ChangeData(ObjDataBase data)
 {
     objDataBase = data;
     Save();
 }