private void Awake() { gameOverPanel.SetActive(false); PlayerMeta player = BaseSaver.GetPlayer(); background1.SetActive(false); background2.SetActive(false); background3.SetActive(false); background4.SetActive(false); switch (player.world) { case GameMeta.World.nile: background1.SetActive(true); break; case GameMeta.World.mountain: background2.SetActive(true); break; case GameMeta.World.pyramid: background3.SetActive(true); break; case GameMeta.World.candy: background4.SetActive(true); break; } boardMeta = BaseSaver.GetBoard(); width = boardMeta.width; height = boardMeta.height; tileMap = GetComponentInChildren <Tilemap>(); instance = this; //tiles = new TileProxy[width, height]; grid = GetComponent <Grid>(); }
private void Awake() { gameOverPanel.SetActive(false); boardMeta = BaseSaver.GetBoard(); width = boardMeta.width; height = boardMeta.height; tileMap = GetComponentInChildren <Tilemap>(); instance = this; tiles = new TileProxy[width, height]; grid = GetComponent <Grid>(); }
public virtual IEnumerator LerpToTile(TileProxy tile, float time) { Vector3 start = transform.position; Vector3 end = BoardProxy.GetWorldPosition(tile.GetPosition()); float timer = 0f; while (timer < time) { // Debug.Log(transform.position); transform.position = Vector3.Lerp(start, end, timer / time); timer += Time.deltaTime; yield return(0f); } data.SetPosition(tile.GetPosition()); }
public virtual void SnapToCurrentPosition() { transform.position = BoardProxy.GetWorldPosition(data.GetPosition()); }
public virtual IEnumerator LerpToTile(TileProxy tile, float time, bool firstTile = false) { Vector3 start = transform.position; Vector3 end = BoardProxy.GetWorldPosition(tile.GetPosition()); /* * Right here is where the animation needs to be set */ Animator anim = transform.GetChild(0).GetComponent <Animator>(); if (anim != null) { Vector3 theScale = transform.localScale; Vector3Int animStart = GetPosition(); Vector3Int animEnd = tile.GetPosition(); Vector3 diff = animEnd - animStart; if (diff.x > 0) { Debug.Log("right"); theScale.x = -1; anim.SetBool("IDLE_FRONT_LEFT", false); while (anim.GetBool("IDLE_FRONT_LEFT")) { } anim.SetBool("MV_BACK_LEFT", true); anim.SetBool("MV_FRONT_LEFT", false); } else if (diff.x < 0) { Debug.Log("left"); theScale.x = 1; anim.SetBool("IDLE_FRONT_LEFT", true); while (!anim.GetBool("IDLE_FRONT_LEFT")) { } anim.SetBool("MV_BACK_LEFT", false); anim.SetBool("MV_FRONT_LEFT", true); } else { //Defender is right below or above attacker if (diff.y > 0) { Debug.Log("up"); theScale.x = 1; anim.SetBool("IDLE_FRONT_LEFT", false); while (anim.GetBool("IDLE_FRONT_LEFT")) { } anim.SetBool("MV_BACK_LEFT", true); anim.SetBool("MV_FRONT_LEFT", false); } else if (diff.y < 0) { Debug.Log("down"); theScale.x = -1; anim.SetBool("IDLE_FRONT_LEFT", true); while (!anim.GetBool("IDLE_FRONT_LEFT")) { } anim.SetBool("MV_BACK_LEFT", false); anim.SetBool("MV_FRONT_LEFT", true); } } transform.localScale = theScale; } float timer = 0f; while (timer < time) { // Debug.Log(transform.position); transform.position = Vector3.Lerp(start, end, timer / time); timer += Time.deltaTime; yield return(0f); } data.SetPosition(tile.GetPosition()); if (!GetData().IsDead()) { tile.CreateAnimation(Glossary.fx.smoke1); } if (tile.OnFire() && !firstTile) { if (IsAttackedEnvironment(1)) { transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false; transform.GetChild(0).GetComponent <Animator>().enabled = false; //ConditionTracker.instance.EvalDeath(this); } } //AnimationInteractionController.InteractionAnimationGameobject( //BoardProxy.instance.glossary.GetComponent<Glossary>().skull, BoardProxy.instance.GetTileAtPosition(GetPosition()).gameObject, AnimationInteractionController.NO_WAIT, true); }