Exemplo n.º 1
0
    private TerrainRamdonSpawner OneByType(H hType)
    {
        TerrainRamdonSpawner res = null;

        if (hType == H.Tree)
        {
            res = HandleTheList(_tree);
        }
        else if (hType == H.Grass)
        {
            res = HandleTheList(_lawn);
        }
        else if (hType == H.Stone)
        {
            res = HandleTheList(_stone);
        }
        else if (hType == H.Iron)
        {
            res = HandleTheList(_iron);
        }
        else if (hType == H.Gold)
        {
            res = HandleTheList(_gold);
        }
        else if (hType == H.Ornament)
        {
            res = HandleTheList(_orna);
        }

        return(res);
    }
Exemplo n.º 2
0
    internal void AddToPool(StillElement stillElement)
    {
        stillElement.enabled = false;
        TerrainRamdonSpawner res = stillElement;

        res.transform.SetParent(transform);
        res.transform.position = new Vector3();
        //_list.Add(res.gameObject);

        if (res.HType == H.Tree)
        {
            _tree.Add(res);
        }
        else if (res.HType == H.Grass)
        {
            _lawn.Add(res);
        }
        else if (res.HType == H.Stone)
        {
            _stone.Add(res);
        }
        else if (res.HType == H.Iron)
        {
            _iron.Add(res);
        }
        else if (res.HType == H.Gold)
        {
            _gold.Add(res);
        }
        else if (res.HType == H.Ornament)
        {
            _orna.Add(res);
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// Adds or remove items from the currentMineVisHelp list
 /// </summary>
 /// <param name="isToAdd">is is true we add otherwise remove</param>
 /// <param name="obj">the new obj</param>
 public void AddVisHelpList(bool isToAdd, TerrainRamdonSpawner obj)
 {
     if (isToAdd)
     {
         //print(obj.name + " added to selection");
         currentMineVisHelp.Add(SelectionGO.CreateSelection(Root.selectMine1, obj.transform.position, obj.IndexAllVertex,
                                                            obj.name + " Selection", container: transform));
     }
     else if (!isToAdd && currentMineVisHelp.Count > 0)
     {
         for (int i = 0; i < currentMineVisHelp.Count; i++)
         {
             if (currentMineVisHelp[i].IndexAllVertex == obj.IndexAllVertex)
             {
                 //print(currentMineVisHelp[i].IndexAllVertex + " currentMineVisHelp[i].IndexAllVertex");
                 //print(obj.IndexAllVertex + " obj.IndexAllVertex");
                 currentMineVisHelp[i].Destroy();
                 currentMineVisHelp.RemoveAt(i);
                 i--;
             }
         }
     }
     //updates the needed list on TerraSpawnController
     p.TerraSpawnController.UpdateLocalLists(obj);
 }
Exemplo n.º 4
0
 private void AddToItsList(TerrainRamdonSpawner terra, List <TerrainRamdonSpawner> listP)
 {
     if (terra != null)
     {
         //_list.Add(terra);
         listP.Add(terra);
     }
 }
Exemplo n.º 5
0
Arquivo: Router.cs Projeto: Cdrix/SM
    private List <Building> helperBuilds = new List <Building>(); //this list collect the helpers to be destoyed later
    /// <summary>
    /// Created to see if we are colliding with a Teeraa Spawner
    /// </summary>
    void SetCurrentBuildingTerraSpawn(string myIdP)
    {
        if (Program.gameScene.controllerMain.TerraSpawnController.AllRandomObjList.Contains(myIdP))
        {
            TerrainRamdonSpawner t = Program.gameScene.controllerMain.TerraSpawnController.AllRandomObjList[myIdP];

            CreateIfInADiffPos(t);
        }
    }
Exemplo n.º 6
0
 public static List <StillElement> UpdateAList(List <StillElement> list, TerrainRamdonSpawner newObj)
 {
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].IndexAllVertex == newObj.IndexAllVertex)
         {
             list[i] = newObj as StillElement;
         }
     }
     return(list);
 }
Exemplo n.º 7
0
    /// <summary>
    /// The action of getting a new Swaped in tree ready
    /// </summary>
    /// <param name="oldTree"></param>
    internal void SwapIn(TerrainRamdonSpawner oldTree)
    {
        var oldP = oldTree.transform.position;

        MyId = oldTree.MyId;
        name = oldTree.name;

        //hiding in deep into terrain
        transform.position = new Vector3(oldP.x, oldP.y - howDeepInY, oldP.z);
        transform.rotation = oldTree.transform.rotation;
        IndexAllVertex     = oldTree.IndexAllVertex;
        SeedDate           = Program.gameScene.GameTime1.CurrentDate();
        ReplantedTree      = true;
    }
Exemplo n.º 8
0
    public static List <StoneRock> UpdateAList(List <StoneRock> list, TerrainRamdonSpawner newObj)
    {
        //print(list.Count+" count");
        //print(newObj.name+" name");

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].IndexAllVertex == newObj.IndexAllVertex)
            {
                list[i] = newObj as StoneRock;
            }
        }
        return(list);
    }
Exemplo n.º 9
0
 //updates local list, AllRandomObjList, AllSpawnedDataList, and all individuals lists
 public void UpdateLocalLists(TerrainRamdonSpawner newObj)
 {
     if (AllRandomObjList.Count == 0)
     {
         return;
     }
     for (int i = 0; i < AllRandomObjList.Count; i++)
     {
         if (AllRandomObjList[i].IndexAllVertex == newObj.IndexAllVertex)
         {
             AllRandomObjList[i] = newObj;
         }
     }
     CreateOrUpdateSpecificsList(newObj.HType, newObj, H.Update);
 }
Exemplo n.º 10
0
    public TerrainRamdonSpawner RetTerraSpawn(Vector3 origen, Vector3 rotation,
                                              int indexAllVertex, H hType,
                                              string name    = "", Transform container = null, bool replantedTree = false,
                                              float height   = 0, MDate seedDate       = null, float maxHeight    = 0,
                                              Quaternion rot = new Quaternion())
    {
        TerrainRamdonSpawner obj = OneByType(hType);

        if (obj == null)
        {
            //Debug.Log("needed on Pool: " + hType);
            return(obj);
        }

        var still = (StillElement)obj;

        still.enabled = true;
        obj.enabled   = true;

        if (name != "")
        {
            obj.name = name;
        }
        obj.IndexAllVertex = indexAllVertex;
        obj.HType          = hType;
        obj.Category       = obj.DefineCategory(hType);
        obj.MyId           = obj.Rename(name, obj.Id, obj.HType);
        obj.transform.name = obj.MyId;

        //here to avoid rotating object after spwaned
        //for loading
        obj.transform.rotation = rot;
        //for new obj
        obj.transform.Rotate(rotation);
        obj.transform.position = origen;

        obj.ReplantedTree = replantedTree;
        obj.Height        = height;
        obj.SeedDate      = seedDate;

        if (container != null)
        {
            obj.transform.SetParent(container);
        }

        return(obj);
    }
Exemplo n.º 11
0
    static public TerrainRamdonSpawner CreateTerraSpawn(string root, Vector3 origen, Vector3 rotation,
                                                        int indexAllVertex, H hType,
                                                        string name    = "", Transform container = null, bool replantedTree = false,
                                                        float height   = 0, MDate seedDate       = null, float maxHeight    = 0,
                                                        Quaternion rot = new Quaternion())
    {
        WAKEUP = true;
        TerrainRamdonSpawner obj = null;

        obj = (TerrainRamdonSpawner)Resources.Load(root, typeof(TerrainRamdonSpawner));

        if (obj == null)
        {
            Debug.Log("null:" + root);
        }

        obj = (TerrainRamdonSpawner)Instantiate(obj, origen, Quaternion.identity);
        if (name != "")
        {
            obj.name = name;
        }
        if (container != null)
        {
            obj.transform.SetParent(container);
        }
        obj.IndexAllVertex = indexAllVertex;
        obj.HType          = hType;
        obj.Category       = obj.DefineCategory(hType);
        obj.MyId           = obj.Rename(name, obj.Id, obj.HType);
        obj.transform.name = obj.MyId;

        //here to avoid rotating object after spwaned
        //for loading
        obj.transform.rotation = rot;
        //for new obj
        obj.transform.Rotate(rotation);

        obj.ReplantedTree = replantedTree;
        obj.Height        = height;
        obj.SeedDate      = seedDate;
        return(obj);
    }
Exemplo n.º 12
0
    SpawnedData CreateApropData(TerrainRamdonSpawner ele)
    {
        SpawnedData sData = null;

        if (ele.HType == H.Tree)
        {
            var still = (StillElement)ele;

            sData = new SpawnedData(ele.transform.position, ele.transform.rotation, ele.HType,
                                    ele.RootToSpawnIndex, ele.IndexAllVertex, still.Height, still.SeedDate, still.MaxHeight,
                                    still.TreeFall, still.Weight, ele.Region);
        }
        else
        {
            sData = new SpawnedData(ele.transform.position, ele.transform.rotation, ele.HType,
                                    ele.RootToSpawnIndex, ele.IndexAllVertex, ele.Region);
        }

        return(sData);
    }
Exemplo n.º 13
0
Arquivo: Router.cs Projeto: Cdrix/SM
    void CreateIfInADiffPos(TerrainRamdonSpawner t)
    {
        //var isNull = currBuilding == null;
        //var samePos = false;

        //if (!isNull)
        //{
        //    samePos = t.transform.position == currBuilding.transform.position;
        //}

        /////if is null or
        ///// is not null and the position is not the same as the current building
        //if (isNull || (!isNull && !samePos))
        //{
        currBuilding = Building.CreateBuild(Root.dummyBuild, new Vector3(), H.Dummy);
        currBuilding.transform.position = t.transform.position;

        currBuilding.PositionFixed = true;

        AddBoxColliderToCurrent(t);

        helperBuilds.Add(currBuilding);
        //}
    }
Exemplo n.º 14
0
    //create or updates specific lists
    void CreateOrUpdateSpecificsList(H typePass, TerrainRamdonSpawner temp, H action)
    {
        //print(typePass + " " + action);

        if (typePass == H.Tree)
        {
            if (action == H.Create)
            {
                treeList.Add((TreeVeget)temp);
            }
            else if (action == H.Update)
            {
                treeList = UList.UpdateAList(treeList, temp);
            }
        }
        else if (typePass == H.Stone)
        {
            if (action == H.Create)
            {
                stoneList.Add(temp as StoneRock);
            }
            else if (action == H.Update)
            {
                stoneList = UList.UpdateAList(stoneList, temp);
            }
        }
        else if (typePass == H.Iron)
        {
            if (action == H.Create)
            {
                ironList.Add(temp as IronRock);
            }
            else if (action == H.Update)
            {
                ironList = UList.UpdateAList(ironList, temp);
            }
        }
        else if (typePass == H.Ornament)
        {
            if (action == H.Create)
            {
                ornaList.Add((StillElement)temp);
            }
            else if (action == H.Update)
            {
                ornaList = UList.UpdateAList(ornaList, temp);
            }
        }
        else if (typePass == H.Grass)
        {
            if (action == H.Create)
            {
                grassList.Add((StillElement)temp);
            }
            else if (action == H.Update)
            {
                grassList = UList.UpdateAList(grassList, temp);
            }
        }
        else if (typePass == H.Marine)
        {
            if (action == H.Create)
            {
                marineList.Add((StillElement)temp);
            }
            else if (action == H.Update)
            {
                marineList = UList.UpdateAList(marineList, temp);
            }
        }
        else if (typePass == H.Mountain)
        {
            if (action == H.Create)
            {
                mountainList.Add((StillElement)temp);
            }
            else if (action == H.Update)
            {
                mountainList = UList.UpdateAList(mountainList, temp);
            }
        }
    }
Exemplo n.º 15
0
    //Creates the main type of objects and add them to AllRandomObjList, at the end if IsToSave is true will save it on
    //SaveOnListData
    public void CreateObjAndAddToMainList(H typePass, Vector3 pos,
                                          int rootToSpawnIndex, int index, Quaternion rot = new Quaternion(), bool replantedTree = false,
                                          float treeHeight = 0, MDate seedDate = null, float maxHeight = 0, bool treeFall = false, float weight = 0,
                                          string oldTreeID = "")
    {
        var region = MeshController.CrystalManager1.ReturnMyRegion(pos);

        string root = ReturnRoot(typePass, rootToSpawnIndex);
        TerrainRamdonSpawner temp = null;

        if (IsToSave)
        {
            temp = TerrainRamdonSpawner.CreateTerraSpawn(root, pos, new Vector3(0, rand.Next(0, 360), 0),
                                                         index, typePass, typePass.ToString(),
                                                         transform, replantedTree, treeHeight, seedDate, maxHeight);
            usedVertexPos[index] = true;

            //Debug.Log("Obj Spwned:"+temp.MyId);
        }
        else if (IsToLoadFromFile)
        {
            temp = _spawnPool.RetTerraSpawn(pos, new Vector3(),
                                            index, typePass, typePass.ToString(),
                                            transform, replantedTree, treeHeight, seedDate, maxHeight, rot);

            //pool emptied
            if (temp == null)
            {
                temp = TerrainRamdonSpawner.CreateTerraSpawn(root, pos, new Vector3(),
                                                             index, typePass, typePass.ToString(),
                                                             transform, replantedTree, treeHeight, seedDate, maxHeight, rot);
            }

            if (typePass == H.Tree)
            {
                var st = (StillElement)temp;
                st.Weight   = weight;
                st.TreeFall = treeFall;
            }
        }
        temp.Region = region;

        //if is replant tree we want to place it first so when loading is faster
        if (replantedTree)
        {
            temp.MyId = oldTreeID;
            temp.name = oldTreeID;
            AllRandomObjList.Insert(0, temp);
        }
        else
        {
            if (typePass != H.Grass)
            {
                Program.gameScene.BatchAdd(temp);
            }
            AllRandomObjList.Add(temp);
        }

        if (IsToSave)
        {
            SaveOnListData(temp, typePass, rootToSpawnIndex, index, replantedTree, region);
        }
        else
        {
            var a = 1;
        }

        StillElement still = (StillElement)temp;

        if (still != null)
        {
            still.Start();
        }
    }