Example #1
0
        //single action - showo r hide object
        private bool LoaderOneAction()
        {
            bool doneSth = false;

            //1. something to hide?
            if (_hideObjects.Count > 0)
            {
                MapObjectInfo obj = _hideObjects[0];
                if (obj.SceneObject != null)
                {
                    PrefabPool.Instance.ReleasePrefab(obj.SceneObject);
                    obj.SceneObject = null;
                }
                _hideObjects.RemoveAt(0);
                doneSth = true;
            }
            else if (_showObjects.Count > 0)
            {
                MapObjectInfo obj = _showObjects[0];
                InstantiateMapObject(obj);
                _showObjects.RemoveAt(0);
                doneSth = true;
            }
            return(doneSth);
        }
Example #2
0
 private void InstantiateMapObject(MapObjectInfo moi)
 {
     //Debug.Log("InstantiateMapObject " + moi.ObjectName);
     if (moi.SceneObject == null)
     {
         PrefabTemplate templ = PrefabPool.Instance.ShowTemplate(moi.ObjectName).GetComponent <PrefabTemplate>();
         if (templ != null && templ.isActive)
         {
             if (ShouldSpawnActiveObject(moi))
             {
                 GameObject createdObject = ActiveObjectsManager.Instance.CreateAvtiveObject(moi.ObjectName, moi.ObjectPosition + EndlessWorldModuleManager.Instance.GetBiomPosition(moi.TheBiom));
                 createdObject.SetActive(true);
             }
             moi.MyGroup.ObjectList.Remove(moi);
         }
         else
         {
             moi.SceneObject = PrefabPool.Instance.GetPrefab(moi.ObjectName);
             moi.SceneObject.transform.parent        = moi.TheBiom.TheMainGO.transform;
             moi.SceneObject.transform.localPosition = moi.ObjectPosition;
             moi.SceneObject.transform.localRotation = moi.ObjectRotation;
             moi.SceneObject.transform.localScale    = moi.ObjectScale;
             moi.SceneObject.SetActive(true);
         }
     }
 }
Example #3
0
        //returns true if ao was never spawned yet (during whole game) and thus it should be spawned or returns false if it was spawned and shouldn't be spawned again
        private bool ShouldSpawnActiveObject(MapObjectInfo moi)
        {
            string unique_id = moi.ObjectName + "_" + moi.TheBiom.BiomX + "_" + moi.TheBiom.BiomZ + "_" + moi.ObjectPosition.x.ToString() + "_" + moi.ObjectPosition.z.ToString();

            if (!GameManager.Instance.TheGameState.KeyExists("genid_" + unique_id))
            {
                GameManager.Instance.TheGameState.SetKey("genid_" + unique_id, true);
                return(true);
            }
            return(false);
        }
Example #4
0
        private void ReadSingleBiomFromMap(byte[] data, ref int readIndex, int biomX, int biomZ)
        {
            int objsCount = ReadIntFromBytes(data, ref readIndex);
            List <MapObjectInfo> objList = new List <MapObjectInfo>();

            for (int gIndex = 0; gIndex < objsCount; gIndex++)
            {
                MapObjectInfo moi = new MapObjectInfo();
                moi.ObjectName     = ReadStringFromBytes(data, ref readIndex);
                moi.ObjectPosition = ReadVector3FromBytes(data, ref readIndex);
                moi.ObjectRotation = ReadQuaternionFromBytes(data, ref readIndex);
                moi.ObjectScale    = ReadVector3FromBytes(data, ref readIndex);
                moi.MaxLOD         = ReadIntFromBytes(data, ref readIndex);
                objList.Add(moi);
            }
            SetBiomMapObjectsData(biomX, biomZ, objList);
        }