Beispiel #1
0
    public void ApplySandiness()
    {
        CalculateSandiness();

        if (sandiness == 1 && !name.StartsWith("S"))
        {
            GameObject newBlock = Instantiate(sandBlock);
            newBlock.transform.parent   = transform.parent;
            newBlock.transform.position = new Vector3(transform.position.x, 0.875f, transform.position.z);
            newBlock.name = "S | " + (transform.position.x + 0.5) + ", " + (transform.position.z + 0.5);
            LandBlock newBlockTerrain = newBlock.GetComponent <LandBlock>();
            newBlockTerrain.baseLandMaterial = baseLandMaterial;
            newBlockTerrain.sandLandMaterial = sandLandMaterial;
            newBlockTerrain.sandBlock        = sandBlock;
            newBlockTerrain.ApplySandiness();
            DestroyImmediate(gameObject);
            return;
        }

        Material rendererMaterial = new Material(GetComponent <Renderer>().sharedMaterial);

        rendererMaterial.EnableKeyword("_EmissionColor");
        Color baseColor         = baseLandMaterial.color;
        Color sandColor         = sandLandMaterial.color;
        Color baseEmissionColor = baseLandMaterial.GetColor("_EmissionColor");
        Color sandEmissionColor = sandLandMaterial.GetColor("_EmissionColor");

        rendererMaterial.color = Color.Lerp(baseColor, sandColor, sandiness);
        rendererMaterial.SetColor("_EmissionColor", Color.Lerp(baseEmissionColor, sandEmissionColor, sandiness));
        GetComponent <Renderer>().sharedMaterial = rendererMaterial;
    }
Beispiel #2
0
    private void AddLandBlock(int x, int y)
    {
        var landBlockPrefab = GetLandBlocksPrefabs();
        var landBlock       = LandBlock.LandBlockFactory(landBlockPrefab, x, y, LandBlocksHolder);

        _allCreatedLandBlock.Add(landBlock);
        _dictionaryPositionToLandBlock[y][x] = landBlock;
    }
Beispiel #3
0
 void Start()
 {
     _currentTimeToNextLine = GetTimeToNextLine();
     start = _allCreatedLandBlock.FirstOrDefault();
     InitializePlayer();
 }
Beispiel #4
0
 private void RemoveBlock(LandBlock block)
 {
     _dictionaryPositionToLandBlock[block.Y].Remove(block.X);
     _allCreatedLandBlock.Remove(block);
     LandBlock.DestroyLand(block);
 }