Esempio n. 1
0
    private void Setup()
    {
        _dataReferences = SceneManager.Instance.DataReferences;

        _data = _dataReferences.FindElement <DropManagerData>(_id);
        if (_data == null)
        {
            _data = _dataReferences.AddElement <DropManagerData>(_id);
            return;
        }

        LoadDrops();
    }
Esempio n. 2
0
    private void PlaceBuilding()
    {
        if (_dataReferences != null)
        {
            _dataReferences.AddElement <BuildingInfo>(_buildingInfoID);
        }

        RaycastHit t_hit;
        Ray        t_ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(t_ray, out t_hit) && Time.timeScale == 1)
        {
            BuildingInfo t_buildingInfoArray = null;
            if (_dataReferences != null)
            {
                t_buildingInfoArray = _dataReferences.FindElement <BuildingInfo>(_buildingInfoID);
            }

            if (!t_hit.collider.CompareTag("Tree") && !t_hit.collider.CompareTag("Tower") && !t_hit.collider.CompareTag("Tree"))
            {
                if (UIManager.Instance != null && !UIManager.Instance.MenuOpened)
                {
                    GenerationManager.Instance.Buildings.Add(Instantiate(prefab, t_hit.point, Quaternion.identity));

                    Building t_obj = new Building(t_hit.point, Quaternion.identity, prefab);

                    if (t_buildingInfoArray != null)
                    {
                        t_buildingInfoArray.Buildings.Add(t_obj);
                        t_buildingInfoArray.Save();
                    }
                }
                else if (UIManager.Instance == null)
                {
                    GenerationManager.Instance.Buildings.Add(Instantiate(prefab, t_hit.point, Quaternion.identity));

                    Building t_obj = new Building(t_hit.point, Quaternion.identity, prefab);

                    if (t_buildingInfoArray != null)
                    {
                        t_buildingInfoArray.Buildings.Add(t_obj);
                        t_buildingInfoArray.Save();
                    }
                }
            }
        }
    }
Esempio n. 3
0
    public void Setup(string p_id)
    {
        if (p_id == "none")
        {
            return;
        }

        _id = p_id;

        _dataReferences = SceneManager.Instance.DataReferences;

        _data = _dataReferences.FindElement <ItemData>(p_id);
        if (_data == null)
        {
            _data = _dataReferences.AddElement <ItemData>(p_id);
            return;
        }

        LoadAlife();
    }
Esempio n. 4
0
    private void Start()
    {
        _sceneManager   = SceneManager.Instance;
        _dataReferences = _sceneManager.DataReferences;

        if (_dataReferences != null)
        {
            _resourceInfo = _dataReferences.FindElement <ResourceInfo>(_resourceInfoID);
        }
        if (_resourceInfo == null && _dataReferences != null)
        {
            _dataReferences.AddElement <ResourceInfo>(_resourceInfoID);
            _resourceInfo = _dataReferences.FindElement <ResourceInfo>(_resourceInfoID);
        }
        else
        {
            _wood = _resourceInfo.Wood;
            _rock = _resourceInfo.Rock;
        }
    }
    private void Update()
    {
        Ray        t_ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit t_hit;

        if (Physics.Raycast(t_ray, out t_hit))
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                for (uint i = 0; i < _collonists.Length; i++)
                {
                    transform.position = t_hit.point;
                    _collonists[i].SetActive(true);
                    _collonists[i].transform.parent = _collonists[i].transform.parent.parent;
                    Destroy(gameObject);

                    _collonists[i].GetComponent <CollonistController>().enabled = true;
                    _collonists[i].GetComponent <GravityHandler>().enabled      = true;

                    _text.enabled = false;

                    CollonistInfo t_collonistInfoArray = null;
                    if (_dataReferences != null)
                    {
                        t_collonistInfoArray = _dataReferences.FindElement <CollonistInfo>(_collonistDataArrayID);
                    }
                    if (t_collonistInfoArray == null && _dataReferences != null)
                    {
                        _dataReferences.AddElement <CollonistInfo>(_collonistDataArrayID);
                        t_collonistInfoArray = _dataReferences.FindElement <CollonistInfo>(_collonistDataArrayID);
                    }
                    if (_dataReferences.FindElement <CollonistInfo>(_collonistDataArrayID) != null)
                    {
                        _dataReferences.FindElement <CollonistInfo>(_collonistDataArrayID).Collonists.Add(new Collonist(_collonists[i].transform.position, Quaternion.identity, _prefab));
                    }

                    t_collonistInfoArray.Save();
                }
            }
        }
    }
Esempio n. 6
0
    public bool Setup(string p_id)
    {
        if (_id == "none")
        {
            return(false);
        }

        _id = p_id;

        StartCoroutine(ContinuousSave());

        _dataReferences = SceneManager.Instance.DataReferences;

        _data = _dataReferences.FindElement <ExampleData>(_id);
        if (_data == null)
        {
            _data = _dataReferences.AddElement <ExampleData>(_id);
            return(false);
        }

        LoadText();

        return(true);
    }
Esempio n. 7
0
    private void Setup()
    {
        _dataReferences = SceneManager.Instance.DataReferences;

        _data = _dataReferences.FindElement <PlayerData>(_id);
        if (_data == null)
        {
            _data = _dataReferences.AddElement <PlayerData>(_id);
            StartCoroutine(SavePlayer());
            return;
        }

        if (_data.Inventory.Count != 0)
        {
            LoadInventory();
        }

        if (_data.Position != null && _data.Rotation != null)
        {
            LoadPlayer();
        }

        StartCoroutine(SavePlayer());
    }
    private IEnumerator PlaceRocks(Orientation p_orientation, Transform p_position)
    {
        LoadingscreenManager t_loadingscreenManager = LoadingscreenManager.Instance;
        UIManager            t_uiManager            = UIManager.Instance;
        RockInfo             t_rockInfoArray        = null;

        if (_dataReferences != null)
        {
            t_rockInfoArray = _dataReferences.FindElement <RockInfo>(_rockDataArrayID);
        }
        if (t_rockInfoArray == null && _dataReferences != null)
        {
            _dataReferences.AddElement <RockInfo>(_rockDataArrayID);
            t_rockInfoArray = _dataReferences.FindElement <RockInfo>(_rockDataArrayID);
        }

        if (t_loadingscreenManager != null)
        {
            t_loadingscreenManager.OpenLoadingscreen("Generating World.");
        }

        for (int i = 0; i < _rockGen.amount; i++)
        {
            if (i % (_rockGen.amount / 25) == 0 && i != 0)
            {
                yield return(new WaitForSecondsRealtime(0.01f));
            }

            if (t_loadingscreenManager != null)
            {
                t_uiManager.LoadingBar.value = t_uiManager.LoadingBar.maxValue * i / _rockGen.amount;
            }

            GameObject t_tree       = _rockGen.obj[UnityEngine.Random.Range(0, _rockGen.obj.Length)];
            Vector2    t_spawnPosV2 = UnityEngine.Random.insideUnitCircle * _rockGen.radius;
            Vector3    t_spawnPos   = new Vector3(t_spawnPosV2.x, 0, t_spawnPosV2.y);
            Vector3    t_offset     = p_position.position + t_spawnPos;

            Vector3 t_axis = new Vector3();
            if (p_orientation == Orientation.Up)
            {
                t_axis = Vector3.up;
            }
            if (p_orientation == Orientation.Down)
            {
                t_axis = Vector3.down;
            }

            RaycastHit t_hit;
            if (Physics.Raycast(t_offset, t_axis, out t_hit))
            {
                Vector3 t_finalSpawnPos = t_hit.point;
                if (!t_hit.collider.CompareTag("Tree") && !t_hit.collider.CompareTag("Rock"))
                {
                    _rocks.Add(Instantiate(t_tree, t_finalSpawnPos, Quaternion.identity));
                    if (t_rockInfoArray != null)
                    {
                        t_rockInfoArray.Rocks.Add(new Rock(t_finalSpawnPos, Quaternion.identity, t_tree));
                    }
                }
            }
        }

        if (t_rockInfoArray != null)
        {
            t_rockInfoArray.Save();
        }
        if (t_loadingscreenManager != null)
        {
            t_loadingscreenManager.CloseLoadingscreen();
        }
        yield return(null);
    }