예제 #1
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (position == null)
     {
         position = collision.gameObject.GetComponent <ArenaTile>();
     }
 }
예제 #2
0
 public void BeginAttack(Pawn caster, ArenaTile target)
 {
     m_CurrentCaster     = caster;
     m_CurrentTarget     = target;
     m_CurrentCasterAnim = caster.GetComponent <PawnAnimator>();
     m_CurrentState      = AnimationState.Setup;
 }
예제 #3
0
 void OnCollisionEnter2D(Collision2D obj)
 {
     if (obj.transform.tag == "Game_arenaTile")
     {
         arenaTile = obj.gameObject.GetComponent <ArenaTile>();
     }
 }
예제 #4
0
    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;
        }
    }
예제 #5
0
 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);
 }
예제 #6
0
 private void Event_OnTileSelected(ArenaTile tile)
 {
     if (m_RecentCoordinator != null)
     {
         if (m_RecentCoordinator.PreviousKnownState == TurnState.Attacking)
         {
             CloseMenu(m_RecentCoordinator, false);
         }
     }
 }
예제 #7
0
 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);
 }
예제 #8
0
    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");
    }
예제 #9
0
 private void Event_OnTileHover(ArenaTile tile)
 {
     if (tile.HasContent && tile.Content.TryGetComponent(out Pawn pawn))
     {
         pawn.ShowInfoPanel();
     }
     else
     {
         InfoPanelManager.Instance.Close();
     }
 }
예제 #10
0
    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>();
        }
    }
예제 #11
0
    private ArenaTile GetTileByIndex(Vector2 index)
    {
        ArenaTile arenaTile = null;

        foreach (ArenaTile tile in tiles)
        {
            if (tile.Index.Index == index)
            {
                arenaTile = tile;
                break;
            }
        }
        return(arenaTile);
    }
예제 #12
0
 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);
     }
 }
예제 #13
0
파일: Arena.cs 프로젝트: hskim3000/Tetris
    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());
    }
예제 #14
0
    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;
            }
        }
    }
예제 #15
0
    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);
        }
    }
예제 #16
0
 void OnCollisionExit2D(Collision2D collision)
 {
     canRotate = false;
     tile      = null;
 }
예제 #17
0
 public abstract bool ChooseAttackAction(AICoordinator coordinator, Pawn caster, out AttackAction attack, out ArenaTile target);
예제 #18
0
 private void Event_OnTileHover(ArenaTile tile)
 {
     m_HealthDefaultShow = (m_Pawn.CurrentTile == tile);
 }
예제 #19
0
    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];
 }
예제 #21
0
    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);
        }
    }
예제 #22
0
 public void Update(ArenaTile desiredResult)
 {
     this.Coordinate = desiredResult.Coordinate;
     this.TileState  = desiredResult.TileState;
 }
예제 #23
0
 public void rotate(TetrominoRotationTile rot)
 {
     position.unlockTile();
     position = rot.tile;
     position.lockTile(this);
 }
예제 #24
0
    private bool canSpawn()
    {
        ArenaTile tl = startPosition.GetComponent <ArenaTile>();

        return(tl.empty);
    }
예제 #25
0
    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);
    }