예제 #1
0
    override protected void UpdateObj(ObjectsData data = null)
    {
        if (data != null)
        {
            Debug.Log("Exception argument in UpdateObj branch class");
            return;
        }

        foreach (var item in GeneralController.m_savedata.m_obj)
        {
            if (item.id == this.id)
            {
                string[] tmpText = new string[1];
                tmpText[0] = textCs.text;
                item.texts = tmpText;

                int[] tmpColor = new int[1];
                tmpColor[0] = (int)ColorClass.dic [textCs.color];
                item.Colors = tmpColor;

                base.UpdateObj(item);
                return;
            }
        }
    }
    public static void SpawnObjects(ObjectsData objectData, Transform parent, MeshSettings meshSettings, int seed)
    {
        Random.seed = seed;

        while (true)
        {
            if (parent.FindChild("ObjectsWorld"))
            {
                DestroyImmediate(parent.FindChild("ObjectsWorld").gameObject);
            }
            else
            {
                break;
            }
        }
        GameObject objPreParent = new GameObject("ObjectsWorld");

        objPreParent.transform.parent   = parent;
        objPreParent.transform.position = parent.position;

        for (int i = 0; i < objectData.objectList.Count; i++)
        {
            if (objectData.objectList[i].pointsToSpawn.Count > 0 && objectData.objectList[i].isSpawn)
            {
                GameObject objParent = new GameObject();
                if (objectData.objectList[i].objectToSpawn == null)
                {
                    objParent.name = "Default Cube";
                }
                else
                {
                    objParent.name = objectData.objectList[i].objectToSpawn.name;
                }
                objParent.transform.parent        = objPreParent.transform;
                objParent.transform.position      = objPreParent.transform.position;
                objParent.transform.localPosition = Vector3.zero;
                for (int k = 0; k < objectData.objectList[i].pointsToSpawn.Count; k++)
                {
                    Vector3    position = new Vector3(objectData.objectList[i].pointsToSpawn[k].x, objectData.objectList[i].pointsToSpawn[k].y, objectData.objectList[i].pointsToSpawn[k].z);
                    GameObject objChild;
                    if (objectData.objectList[i].objectToSpawn == null)
                    {
                        objChild      = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        objChild.name = "Default Cube Child " + k;
                    }
                    else
                    {
                        objChild      = Instantiate(objectData.objectList[i].objectToSpawn);
                        objChild.name = objectData.objectList[i].objectToSpawn.name + " - " + k + 1;
                    }
                    objChild.transform.parent        = objParent.transform;
                    objChild.transform.localPosition = position;
                    objChild.transform.rotation      = new Quaternion(objChild.transform.rotation.x, objChild.transform.rotation.y + Random.Range(0, 10), objChild.transform.rotation.z, objChild.transform.rotation.w);
                    objChild.transform.localScale    = new Vector3(objChild.transform.localScale.x + objectData.objectList[i].ScaleOffset + Random.Range(0, 1),
                                                                   objChild.transform.localScale.y + objectData.objectList[i].ScaleOffset + Random.Range(0, 1),
                                                                   objChild.transform.localScale.z + objectData.objectList[i].ScaleOffset + Random.Range(0, 1));
                }
            }
        }
    }
예제 #3
0
        static void Main(String[] args)
        {
            objectsData = new ObjectsData();
            objectList  = new CObjectCollection();
            String connectionString = "Data Source=localhost;Initial Catalog=pulse_db_game;User ID=root;Password=84@41%%wi96^4";

            dbConnection = new MySqlConnection(connectionString);
            dbConnection.Open();

            /*
             * initCollection();
             * LuaFramework frame = new LuaFramework();
             * frame.BindLuaAPIFunction(new testApi());
             * frame.BindLuaAPIFunction(new InitApi());
             * frame.BindLuaAPIFunction(new MapApi());
             * frame.ExecuteFile("main.lua");
             */
            ThreadStart tStart       = new ThreadStart(listen);
            Thread      serverThread = new Thread(tStart);

            serverThread.Start();

            Thread.Sleep(100);
            Console.ReadLine();
        }
예제 #4
0
    ObjectsData GetPooledObject()
    {
        foreach (ObjectsData child in PooledObjects)                    // Found a pooled object
        {
            if (!child.aPooledObject.activeInHierarchy)
            {
                child.aPooledObject.SetActive(true);
                return(child);
            }
        }

        // Could not find a pooled object. Creating a new object
        GameObject clone;

        clone = Instantiate(spikePrefab, wayPoints[0], spikePrefab.transform.rotation) as GameObject;

        clone.transform.parent = gameObject.transform;

        ObjectsData temp = new ObjectsData();

        temp.aPooledObject      = clone;
        temp.headingToThisIndex = 0;

        PooledObjects.Add(temp);

        return(temp);
    }
예제 #5
0
    override protected void UpdateObj(ObjectsData data = null)
    {
        if (data != null)
        {
            Debug.Log("Exception argument in UpdateObj branch class");
            return;
        }

        foreach (var item in GeneralController.m_savedata.m_obj)
        {
            if (item.id == this.id)
            {
                string[] tmp = new string[text.Length];

                for (int count = 0; count < text.Length; count++)
                {
                    tmp[count] = text[count].GetComponent <Text>().text;
                }
                item.texts = tmp;

                int[] tmpColor = new int[text.Length];
                for (int count = 0; count < text.Length; count++)
                {
                    tmpColor[count] = (int)ColorClass.dic
                                      [text[count].GetComponent <Text>().color];
                }
                item.Colors = tmpColor;

                item.lineNum = tmp.Length;

                base.UpdateObj(item);
                return;
            }
        }
    }
예제 #6
0
    override protected void LoadSaveDataMain(ObjectsData data)
    {
        int difference = data.lineNum - defaultLineNum;

        if (difference > 0)
        {
            for (int count = 0; count < difference; count++)
            {
                LineEdit(EditorDirect.Up, EditorAct.Add);
            }
        }
        else if (difference < 0)
        {
            difference = Mathf.FloorToInt(Mathf.Abs((float)difference));
            for (int count = 0; count < difference; count++)
            {
                LineEdit(EditorDirect.Down, EditorAct.Remove);
            }
        }

        for (int count = 0; count < data.lineNum; count++)
        {
            text[count].GetComponent <Text>().text  = data.texts[count];
            text[count].GetComponent <Text>().color = ColorClass.list[data.Colors[count]][1];

            ColorBlock colorBlock = button[count].GetComponent <Button>().colors;
            colorBlock.normalColor      = ColorClass.list[data.Colors[count]][0];
            colorBlock.highlightedColor = ColorClass.list[data.Colors[count]][0];
            colorBlock.disabledColor    = ColorClass.list[data.Colors[count]][0];
            colorBlock.pressedColor     = ColorClass.list[data.Colors[count]][1];
            button[count].GetComponent <Button>().colors = colorBlock;
        }
    }
예제 #7
0
    public static void Save()
    {
        //save to a certain path
        savePath = Application.dataPath + "/Saved_Scenes/" + SaveFile + ".txt";

        File.WriteAllText(savePath, "");

        objects.Clear();
        //save objects properties in current scene as JASON format
        FileStream fileStream = new FileStream(savePath, FileMode.Create);

        using (StreamWriter writer = new StreamWriter(fileStream))
        {
            foreach (GameObject obj in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
            {
                if (obj.GetComponent <MeshFilter>() != null)
                {
                    objects.Add(obj);
                    ObjectsData tempData = new ObjectsData();
                    tempData.type     = obj.GetComponent <MeshFilter>().sharedMesh.name;
                    tempData.name     = obj.name;
                    tempData.position = obj.transform.position;
                    tempData.scale    = obj.transform.localScale;
                    tempData.rotation = obj.transform.rotation.eulerAngles;
                    string data = JsonUtility.ToJson(tempData);
                    writer.Write(data);
                    writer.Write("\n");
                }
            }
        }
    }
    public GameObject Create(ObjectsData data)
    {
        _GetInstanceGameObjectFromObjectData(data);

        instanceTargetObj.GetComponent <ButtonTranspoter>().LoadSaveDataTrans(data);

        return(instanceTargetObj);
    }
예제 #9
0
    override protected void AddNewObjBrunch(ref ObjectsData data)
    {
        if (data == null)
        {
            Debug.Log("data is null");
            return;
        }

        data.type       = (int)thisObjType;
        data.Colors [0] = (int)ColorClass.dic[(Color32)imageCs.color];         //editMethods.ChooseColor(imageCs.color);
    }
예제 #10
0
    virtual protected void UpdateObj(ObjectsData data = null)
    {
        if (data == null)
        {
            Debug.Log("Exception argument in UpdateObj base class");
            return;
        }

        DataAccess(data);
        return;
    }
예제 #11
0
    private void LoadSaveDataBefore(ObjectsData data)
    {
        InitializeSetParam();

        this.id      = data.id;
        this.type    = (ObjType)data.type;
        this.lineNum = data.lineNum;
        Vector3 position = new Vector3(data.posX, data.posY, 1);

        this.gameObject.transform.localPosition = position;

        this.gameObject.transform.localScale = new Vector3(data.scaling, data.scaling, 0);
    }
예제 #12
0
    override protected void LoadSaveDataMain(ObjectsData data)
    {
        textCs.text  = data.texts[0];
        textCs.color = ColorClass.list[data.Colors[0]][1];

        ColorBlock colorBlock = buttonCs.colors;

        colorBlock.normalColor      = ColorClass.list[data.Colors[0]][0];
        colorBlock.highlightedColor = ColorClass.list[data.Colors[0]][0];
        colorBlock.disabledColor    = ColorClass.list[data.Colors[0]][0];
        colorBlock.pressedColor     = ColorClass.list[data.Colors[0]][1];
        buttonCs.colors             = colorBlock;
    }
예제 #13
0
    private void AddNewObj()
    {
        var data = new ObjectsData();

        InitializeSetParam();
        AddNewObjBrunch(ref data);

        data.id = GetCurId;

        DataAccess(data);

        GeneralController.SetNewObject(data, this);
        Debug.Log("いがあああ" + data.type);
    }
예제 #14
0
    private void DataAccess(ObjectsData data)
    {
        data.lineNum = this.lineNum;

        data.posX = this.transform.localPosition.x;
        Debug.Log("save data.posx = " + data.posX);
        data.posY = this.transform.localPosition.y;
        Debug.Log("save data.posy = " + data.posY);

        data.angle = this.transform.rotation.eulerAngles.z;
        Debug.Log("save data.angle = " + data.angle);

        data.scaling = this.transform.localScale.x;
        Debug.Log("save data.scaling = " + data.scaling);
    }
예제 #15
0
    override protected void AddNewObjBrunch(ref ObjectsData data)
    {
        if (data == null)
        {
            Debug.Log("data is null");
            return;
        }

        data.type = (int)thisObjType;

        data.texts    = new string[1];
        data.texts[0] = textCs.text;
        data.Colors   = new int[1];

        data.Colors [0] = (int)ColorClass.dic [(Color32)textCs.color];
    }
    static public void RemoveObject(long id)
    {
        var tmpObjList = new List <ObjectsData> ();

        tmpObjList.AddRange(m_savedata.m_obj);

        ObjectsData tmpA = null;

        foreach (var item in tmpObjList)
        {
            if (item.id == id)
            {
                tmpA = item;
            }
            if (item.id > id)
            {
                item.id--;
            }
        }
        if (tmpA != null)
        {
            tmpObjList.Remove(tmpA);
            m_savedata.m_general.curId--;
        }
        m_savedata.m_obj = tmpObjList.ToArray();


        BaseObj tmpB = null;

        foreach (var item in instatiatedObj)
        {
            if (item.ID == id)
            {
                tmpB = item;
            }
            if (item.ID > id)
            {
                item.ID--;
            }
        }
        if (tmpB != null)
        {
            instatiatedObj.Remove(tmpB);
        }

        curId--;
    }
    static public void SetNewObject(ObjectsData data, BaseObj obj)
    {
        int length = m_savedata.m_obj.Length;

        ObjectsData[] tmpArray = new ObjectsData[length + 1];

        for (int count = 0; count < length + 1; count++)
        {
            if (count == length)
            {
                tmpArray [count] = data;
            }
            else
            {
                tmpArray [count] = m_savedata.m_obj [count];
            }
        }

        m_savedata.m_obj = tmpArray;
        instatiatedObj.Add(obj);
    }
예제 #18
0
    IEnumerator C_SpikeMovement(ObjectsData SpikeClone)
    {
        bool isMoving = true;

        while (isMoving)
        {
            yield return(null);

            while (Vector2.Distance(SpikeClone.aPooledObject.transform.localPosition, wayPoints[SpikeClone.headingToThisIndex]) > 0.01f)
            {
                SpikeClone.aPooledObject.transform.localPosition = Vector3.MoveTowards(SpikeClone.aPooledObject.transform.localPosition, wayPoints[SpikeClone.headingToThisIndex], Time.deltaTime * moveSpeed * speedMultiplier);
                yield return(null);
            }
            SpikeClone.aPooledObject.transform.localPosition = wayPoints[SpikeClone.headingToThisIndex];

            if (forward)
            {
                SpikeClone.headingToThisIndex++;
                if (SpikeClone.headingToThisIndex > 3)
                {
                    SpikeClone.headingToThisIndex = 3;
                    isMoving = false;
                }
            }
            else
            {
                SpikeClone.headingToThisIndex--;
                if (SpikeClone.headingToThisIndex < 0)
                {
                    SpikeClone.headingToThisIndex = 0;
                    isMoving = false;
                }
            }

            yield return(null);
        }

        SpikeClone.aPooledObject.SetActive(false);
        yield return(null);
    }
예제 #19
0
    public TerrainChunk(Vector2 coord, HeightMapSettings heightMapSettings, MeshSettings meshSettings, LODInfo[] detailLevels, int colliderLODIndex, Transform parent, Transform viewer, Material material, ObjectsData objectsData, int number)
    {
        this.coord             = coord;
        this.detailLevels      = detailLevels;
        this.colliderLODIndex  = colliderLODIndex;
        this.heightMapSettings = heightMapSettings;
        this.meshSettings      = meshSettings;
        this.viewer            = viewer;
        this.objectsData       = objectsData;

        sampleCentre = coord * meshSettings.meshWorldSize / meshSettings.meshScale;
        Vector2 position = coord * meshSettings.meshWorldSize;

        bounds = new Bounds(position, Vector2.one * meshSettings.meshWorldSize);


        meshObject                    = new GameObject("TerrainChunk" + number);
        meshRenderer                  = meshObject.AddComponent <MeshRenderer>();
        meshFilter                    = meshObject.AddComponent <MeshFilter>();
        meshCollider                  = meshObject.AddComponent <MeshCollider>();
        meshRenderer.material         = material;
        meshObject.transform.position = new Vector3(position.x, 0, position.y);
        meshObject.transform.parent   = parent;
        SetVisible(false);


        lodMeshes = new LODMesh[detailLevels.Length];
        for (int i = 0; i < detailLevels.Length; i++)
        {
            lodMeshes[i] = new LODMesh(detailLevels[i].lod);

            lodMeshes[i].updateCallback += UpdateTerrainChunk;
            if (i == colliderLODIndex)
            {
                lodMeshes[i].updateCallback += UpdateCollisionMesh;
            }
        }

        maxViewDst = detailLevels [detailLevels.Length - 1].visibleDstThreshold;
    }
예제 #20
0
    override protected void AddNewObjBrunch(ref ObjectsData data)
    {
        if (data == null)
        {
            Debug.Log("data is null");
            return;
        }

        data.type    = (int)thisObjType;
        lineNum      = text.Length;
        data.lineNum = lineNum;
        data.texts   = new string[lineNum];
        data.Colors  = new int[lineNum];


        for (int count = 0; count < lineNum; count++)
        {
            data.texts [count]  = text [count].GetComponent <Text>().text;
            data.Colors [count] = (int)ColorClass.dic
                                  [text [count].GetComponent <Text>().color];
        }
    }
    public void _GetInstanceGameObjectFromObjectData(ObjectsData data)
    {
        foreach (var item in GeneralController.instanceThisGameObject.GetComponent <CreateObjControll>().instanceCreateObjects)
        {
            targetObjType = item.GetComponent <ButtonTranspoter>().type;
            Debug.Log("searching object type == " + targetObjType);
            if (targetObjType == (ObjType)data.type)
            {
                Debug.Log("hit object type == " + targetObjType);
                targetObjOriginal = item;
                break;
            }
        }

        if (targetObjOriginal == null)
        {
            Debug.LogWarning("not found this argument type");
            return;
        }

        InstantiateObj();
    }
예제 #22
0
    void Start()
    {
        if (restartOnReset)
        {
            EventManager.resetObjects += Reset;
        }

        float spriteHeight = 0;

        foreach (Transform child in transform)                  // Populate the SubObjects list
        {
            ObjectsData temp = new ObjectsData();

            if (child.GetComponent <SpriteRenderer> () != null)                 // Populate the SpriteHeight list
            {
                SpriteRenderer TEMP = child.GetComponent <SpriteRenderer> ();
                spriteHeight = (TEMP.sprite.bounds.size.y * child.transform.localScale.y);
            }
            else
            {
                spriteHeight = 0;
            }

            temp.objectsPosition  = child.transform;
            temp.startingPosition = child.transform.localPosition;
            temp.endingPositon    = child.transform.localPosition + new Vector3(0, spriteHeight, 0);
            SubObjects.Add(temp);
        }

        maxIndex = SubObjects.Count - 1;
        SubObjects [maxIndex].isLastObject = true;
        startingPosition = gameObject.transform.position;
        if (enableOnStart)
        {
            Start_Machine();
        }
    }
 public void LoadSaveDataTrans(ObjectsData data)
 {
     script.LoadSaveData(data);
 }
예제 #24
0
 private void LoadSaveDataAfter(ObjectsData data)
 {
     this.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, data.angle));
 }
예제 #25
0
 virtual protected void AddNewObjBrunch(ref ObjectsData data)
 {
 }
예제 #26
0
 virtual public void LoadSaveData(ObjectsData data)
 {
     LoadSaveDataBefore(data);
     LoadSaveDataMain(data);
     LoadSaveDataAfter(data);
 }
예제 #27
0
 override protected void LoadSaveDataMain(ObjectsData data)
 {
     imageCs.color = editMethods.GetColor(data.Colors[0], ColorDepth.thin);
 }
    public GameObject GetSelectTargetObject(long id)
    {
        ObjectsData data = _GetSelectedObjectData(id);

        return(GetComponent <CreateObjControll> ().Create(data));
    }
예제 #29
0
    IEnumerator C_In_Out(ObjectsData singleObject)
    {
        // Calcuate start and ending position
        singleObject.isActive = true;
        do
        {
            if (singleObject.extending)
            {
                while (singleObject.duration <= 1)                      // Move Out
                {
                    singleObject.duration += Time.deltaTime * speed * speedMultiplier;
                    singleObject.objectsPosition.localPosition = Vector3.Lerp(singleObject.startingPosition, singleObject.endingPositon, singleObject.duration);
                    yield return(null);
                }

                singleObject.extending = false;
                yield return(null);

                while (singleObject.duration >= 0)                      // Move In
                {
                    singleObject.duration -= Time.deltaTime * speed * speedMultiplier;
                    singleObject.objectsPosition.localPosition = Vector3.Lerp(singleObject.startingPosition, singleObject.endingPositon, singleObject.duration);
                    yield return(null);
                }

                singleObject.extending = true;
            }
            else
            {
                while (singleObject.duration >= 0)                      // Move In
                {
                    singleObject.duration -= Time.deltaTime * speed * speedMultiplier;
                    singleObject.objectsPosition.localPosition = Vector3.Lerp(singleObject.startingPosition, singleObject.endingPositon, singleObject.duration);
                    yield return(null);
                }
                singleObject.extending = true;
            }


            {
                if (objectResetDelay != 0 && !waitForReset)
                {
                    yield return(new WaitForSeconds(objectResetDelay));
                }
                else
                {
                    yield return(null);
                }
            }
        }while(!waitForReset);
        singleObject.isActive = false;


        if (singleObject.isLastObject)
        {
            if (forward)
            {
                currentIndex = 0;
            }
            else
            {
                currentIndex = maxIndex;
            }

            yield return(new WaitForSeconds(delayBetweenReset / speedMultiplier));

            StartCoroutine("C_LoopThroughList");
        }
    }
예제 #30
0
 public void AddObjectToSaveList(ObjectsData objectsData)
 {
     listOfObjects.Add(objectsData);
 }