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; }
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; }
void Start() { _currentTimeToNextLine = GetTimeToNextLine(); start = _allCreatedLandBlock.FirstOrDefault(); InitializePlayer(); }
private void RemoveBlock(LandBlock block) { _dictionaryPositionToLandBlock[block.Y].Remove(block.X); _allCreatedLandBlock.Remove(block); LandBlock.DestroyLand(block); }