void OnCollisionEnter2D(Collision2D collision) { if (position == null) { position = collision.gameObject.GetComponent <ArenaTile>(); } }
public void BeginAttack(Pawn caster, ArenaTile target) { m_CurrentCaster = caster; m_CurrentTarget = target; m_CurrentCasterAnim = caster.GetComponent <PawnAnimator>(); m_CurrentState = AnimationState.Setup; }
void OnCollisionEnter2D(Collision2D obj) { if (obj.transform.tag == "Game_arenaTile") { arenaTile = obj.gameObject.GetComponent <ArenaTile>(); } }
public void moveToPosition(ArenaTile tile) { Vector3 pos = tile.transform.position; NavMeshPath path = new NavMeshPath(); navMesh.CalculatePath(pos, path); if (path.status == NavMeshPathStatus.PathComplete) { navMesh.SetPath(path); if (currentTile != null) { currentTile.tile = null; } currentTile = tile; tile.tile = this; movement = true; } else { Debug.Log("Cannot reach destination.", gameObject); selected = false; } }
public void turn(Tetromino.TurnDirection dir, bool withPositionChange = false) { position.unlockTile(); position = arena.tile[position.x + (int)dir, position.y]; if (withPositionChange) { transform.position = position.transform.position; } position.lockTile(this); }
private void Event_OnTileSelected(ArenaTile tile) { if (m_RecentCoordinator != null) { if (m_RecentCoordinator.PreviousKnownState == TurnState.Attacking) { CloseMenu(m_RecentCoordinator, false); } } }
public void fallDownOnce(bool withPositionChange = false) { position.unlockTile(); position = arena.tile[position.x, position.y + 1]; if (withPositionChange) { transform.position = position.transform.position; } position.lockTile(this); }
public void initialize(ArenaTile arTile, Color col) { transform.position = arTile.transform.position; color = col; currentTile = arTile; arTile.tile = this; anim = GetComponent <Animation>(); transform.localScale = new Vector3(0, transform.localScale.y, 0); //Set scale to 0 before start animation anim.Play("Tile New"); }
private void Event_OnTileHover(ArenaTile tile) { if (tile.HasContent && tile.Content.TryGetComponent(out Pawn pawn)) { pawn.ShowInfoPanel(); } else { InfoPanelManager.Instance.Close(); } }
private void Start() { m_Tile = GetComponent <ArenaTile>(); if (s_DudTile == null) { var obj = new GameObject(); obj.SetActive(false); obj.name = "Tile dud"; s_DudTile = obj.AddComponent <ArenaTile>(); } }
private ArenaTile GetTileByIndex(Vector2 index) { ArenaTile arenaTile = null; foreach (ArenaTile tile in tiles) { if (tile.Index.Index == index) { arenaTile = tile; break; } } return(arenaTile); }
private tilesCompareState compareTiles(ArenaTile A, ArenaTile B) { if (A.empty || B.empty) { return(tilesCompareState.EMPTY); } else if (A.tile.color == B.tile.color) { return(tilesCompareState.SAME); } else { return(tilesCompareState.DIFFERENT); } }
void Awake() { maxTileX = transform.GetChild(0).childCount; maxTileY = transform.childCount; tile = new ArenaTile[maxTileX, maxTileY]; game = Camera.main.GetComponent <Game>(); rowsToCheck = new Queue <int>(); for (int y = 0; y < maxTileY; ++y) { for (int x = 0; x < maxTileX; ++x) { tile[x, y] = transform.GetChild(y).GetChild(x).GetComponent <ArenaTile>(); } } StartCoroutine(checkRowCoroutine()); }
private void checkRotation(Collision2D collision) { tile = collision.gameObject.GetComponent <ArenaTile>(); if (tile.empty) { canRotate = true; } else { if (tile.tile.transform.parent == transform.parent.parent) { canRotate = true; } else { tile = null; canRotate = false; } } }
public void spawn() { List <ArenaTile> possibleTiles = arena.getEmptyTiles(); if (possibleTiles.Count < 6) { game.gameLost(); } else { foreach (var ti in tiles) { ArenaTile pos = possibleTiles[Random.Range(0, possibleTiles.Count)]; possibleTiles.Remove(pos); Tile obj = Instantiate(tilePrefab, tileParent).GetComponent <Tile>(); obj.initialize(pos, ti.color); Debug.Log("Spawned new tile.", pos); } randNewTiles(); arena.checkPoints(true); } }
void OnCollisionExit2D(Collision2D collision) { canRotate = false; tile = null; }
public abstract bool ChooseAttackAction(AICoordinator coordinator, Pawn caster, out AttackAction attack, out ArenaTile target);
private void Event_OnTileHover(ArenaTile tile) { m_HealthDefaultShow = (m_Pawn.CurrentTile == tile); }
private int CalcMoveDistance(ArenaTile a, ArenaTile b) { Vector2Int delta = a.Coord - b.Coord; return(Mathf.Max(Mathf.Abs(delta.x), Mathf.Abs(delta.y))); }
public BattleArena(int size) { ArenaSize = size; arenaTiles = new ArenaTile[size, size]; arenaObjects = new ArenaObject[size, size]; }
private void Update() { if (m_CurrentState != AnimationState.None) { AnimationState prevState; do { prevState = m_CurrentState; switch (m_CurrentState) { case AnimationState.Setup: { if (m_MoveToTarget && m_CurrentCasterAnim) { m_CurrentCasterAnim.StartWalkAnimation(m_CurrentTarget.transform.position + m_CurrentCaster.FacingDir * -m_MoveTargetOffset, m_MoveSpeedScale); } m_StallTimer = 0.0f; m_CurrentState = AnimationState.MoveToTarget; break; } case AnimationState.MoveToTarget: { if (!m_CurrentCaster.InBlockingAnimating) { m_CurrentState = AnimationState.Animation; } break; } case AnimationState.Animation: { m_StallTimer += Time.deltaTime; if (m_StallTimer >= m_AnimWaitStall) { break; } //TODO - Anim hookup if (!m_CurrentCaster.InBlockingAnimating) { m_Action.ApplyCurrentAttack(); if (m_MoveToTarget && m_CurrentCasterAnim) { m_CurrentCasterAnim.StartWalkAnimation(m_CurrentCaster.CurrentTile.transform.position, m_MoveSpeedScale); } m_CurrentState = AnimationState.MoveBack; } break; } case AnimationState.MoveBack: { if (!m_CurrentCaster.InBlockingAnimating) { m_CurrentState = AnimationState.Finish; } break; } case AnimationState.Finish: { m_CurrentState = AnimationState.None; m_CurrentCaster = null; m_CurrentTarget = null; m_CurrentCasterAnim = null; return; } } }while (m_CurrentState != prevState); } }
public void Update(ArenaTile desiredResult) { this.Coordinate = desiredResult.Coordinate; this.TileState = desiredResult.TileState; }
public void rotate(TetrominoRotationTile rot) { position.unlockTile(); position = rot.tile; position.lockTile(this); }
private bool canSpawn() { ArenaTile tl = startPosition.GetComponent <ArenaTile>(); return(tl.empty); }
public override bool ChooseAttackAction(AICoordinator coordinator, Pawn caster, out AttackAction attack, out ArenaTile target) { AttackAction[] actions = caster.AttackActions.ToArray(); int rand = Random.Range(0, actions.Length - 1); attack = actions[rand]; var tiles = attack.GatherConsideredTiles(caster).Where((t) => t.HasContent).ToArray(); if (tiles.Any()) { rand = Random.Range(0, tiles.Length - 1); target = tiles[rand]; } else { target = null; return(false); } return(true); }