public void startElementLayer(Vector3 pos, Vector3 size) { GameObject gotileElementLayer = new GameObject("TileElementLayer"); gotileElementLayer.GetComponent <Transform> ().SetParent(this.transform); tileElementLayerBack = gotileElementLayer.AddComponent <SpriteRenderer> (); tileElementLayerBack.gameObject.transform.position = pos; tileElementLayerBack.gameObject.transform.localScale = new Vector2(1f, 1f); tileElementLayerBack.sortingLayerName = "TileElement"; tileElementLayerBack.sortingOrder = (int)(1000 - data.GetRealWorldPosition().y *5); tileElementLayerBack.color = new Color(1f, 1f, 1f, 1f); GameObject gotileElementLayer2 = new GameObject("TileElementLayer2"); gotileElementLayer2.GetComponent <Transform> ().SetParent(this.transform); tileElementLayerFront = gotileElementLayer2.AddComponent <SpriteRenderer> (); tileElementLayerFront.gameObject.transform.position = pos; tileElementLayerFront.gameObject.transform.localScale = new Vector2(1f, 1f); tileElementLayerFront.sortingLayerName = "TileElement"; tileElementLayerFront.color = new Color(1f, 1f, 1f, 1f); tileElementLayerFront.sortingOrder = (int)(1000 - data.GetRealWorldPosition().y *5 + 4); switch (Random.Range(1, 5)) { //Fire case case 1: elementType = ElementType.FIRE; tileElementLayerBack.gameObject.transform.position = pos + new Vector3(0.0f, +0.5f); tileElementLayerFront.gameObject.transform.position = pos + new Vector3(0.0f, -0.25f); //Animations frontAnimation = new SpriteAnimation(tileElementLayerFront); frontAnimation.LoadSprites("Tiles/Fire/front", 6); frontAnimation.RandomStart(); frontAnimation.playAnimation(); backAnimation = new SpriteAnimation(tileElementLayerBack); backAnimation.LoadSprites("Tiles/Fire/back", 6); backAnimation.RandomStart(); backAnimation.playAnimation(); //Shader int baseOffset = Random.Range(0, 20); if (GameObject.Find("Main Camera").GetComponent <GameController> () != null) { Material mat = GameObject.Find("Main Camera").GetComponent <GameController> ().fire; //tileElementLayerFront.material = mat; //tileElementLayerFront.material.SetFloat ("_RandomStart",Mathf.PI+baseOffset); } if (GameObject.Find("Main Camera").GetComponent <GameController> () != null) { Material mat = GameObject.Find("Main Camera").GetComponent <GameController> ().fire; //tileElementLayerBack.material = mat; //tileElementLayerBack.material.SetFloat ("_RandomStart",2*Mathf.PI+baseOffset); } break; //Water case case 2: elementType = ElementType.WATER; tileElementLayerFront.gameObject.transform.position = pos + new Vector3(0.0f, 0.0f); //Animations frontAnimation = new SpriteAnimation(tileElementLayerFront); frontAnimation.LoadSprites("Tiles/Water/tile_water_", 10, 26); frontAnimation.RandomStart(); frontAnimation.mode = SpriteAnimationMode.BOUNCE; frontAnimation.playAnimation(); tileElementLayerBack.gameObject.transform.position = pos + new Vector3(1.2f, 0.7f); backAnimation = new SpriteAnimation(tileElementLayerBack); backAnimation.LoadSprites("Tiles/Water/tile_water_", 10, 26); backAnimation.RandomStart(); backAnimation.mode = SpriteAnimationMode.BOUNCE; backAnimation.playAnimation(); break; //Earth case case 3: elementType = ElementType.EARTH; tileElementLayerFront.gameObject.transform.position = pos + new Vector3(0.75f, -0.25f); tileElementLayerBack.gameObject.transform.position = pos + new Vector3(-0.5f, +0.55f); tileElementLayerFront.gameObject.transform.localScale = new Vector2(0.6f, 1f); tileElementLayerBack.gameObject.transform.localScale = new Vector2(0.85f, 1.2f); //Animations frontAnimation = new SpriteAnimation(tileElementLayerFront); frontAnimation.LoadSprites("Tiles/Earth/tile_earth_", 16); frontAnimation.RandomStart(); frontAnimation.mode = SpriteAnimationMode.LOOP; frontAnimation.playAnimation(); backAnimation = new SpriteAnimation(tileElementLayerBack); backAnimation.LoadSprites("Tiles/Earth/tile_earth_", 16); backAnimation.RandomStart(); backAnimation.mode = SpriteAnimationMode.LOOP; backAnimation.playAnimation(); break; default: elementType = ElementType.NONE; break; } }
public void ChangeElement(ElementType newElement) { if (elementType == ElementType.NONE) { elementType = newElement; element = StatsFactory.GetStat(elementType); canimation = new SpriteAnimation(gameObject.GetComponent <SpriteRenderer> ()); canimation.LoadSprites(element.picDirection, element.picCount); canimation.SetMode(SpriteAnimationMode.BOUNCE); canimation.playAnimation(); changeScaleSlime(); } if (elementType == ElementType.FIRE || elementType == ElementType.WATER || elementType == ElementType.EARTH) { switch (newElement) { case ElementType.EARTH: if (elementType == ElementType.FIRE) { elementType = ElementType.LAVA; } else if (elementType == ElementType.WATER) { elementType = ElementType.MUD; } break; case ElementType.FIRE: if (elementType == ElementType.EARTH) { elementType = ElementType.LAVA; } else if (elementType == ElementType.WATER) { elementType = ElementType.STEAM; } break; case ElementType.WATER: if (elementType == ElementType.FIRE) { elementType = ElementType.STEAM; } else if (elementType == ElementType.EARTH) { elementType = ElementType.MUD; } break; default: break; } element = StatsFactory.GetStat(elementType); canimation = new SpriteAnimation(gameObject.GetComponent <SpriteRenderer> ()); canimation.LoadSprites(element.picDirection, element.picCount); canimation.playAnimation(); canimation.SetMode(SpriteAnimationMode.LOOP); changeScaleSlime(); } CenterFace(); }
public void Setup() { _spriteAnimation.LoadSprites(ref _sprites); _onAnimationEnd.Setup(); }