예제 #1
0
 public void SetState(eTileState state)
 {
     if (_state != state)
     {
         _state = state;
         if (StateChangeCallback != null)
         {
             StateChangeCallback(this, _state);
         }
     }
 }
        public TileControl(string letter, int letterValue)
        {
            this.InitializeComponent();

            Letter      = letter;
            LetterValue = letterValue;
            GridX       = -1;
            GridY       = -1;
            TileStatus  = eTileState.InBag;

            TileLetterTextBlock.Text  = Letter;
            LetterValueTextBlock.Text = LetterValue.ToString();
        }
예제 #3
0
    void set_on(bool click = false)
    {
        SpriteRenderer item = this.gameObject.GetComponent <SpriteRenderer>();

        state       = eTileState.on;
        item.sprite = on;
        //item.color = Color.blue;

        if (click)
        {
            GameStateScript.tile_set_state = state;
        }
    }
예제 #4
0
    void set_empty(bool click = false, eTileState clear_state = eTileState.none)
    {
        SpriteRenderer item = this.gameObject.GetComponent <SpriteRenderer>();

        state       = eTileState.empty;
        item.sprite = empty;
        //item.color = Color.white;

        if (click)
        {
            GameStateScript.tile_set_state   = state;
            GameStateScript.tile_clear_state = clear_state;
        }
    }
예제 #5
0
    public bool AddTileState(int RowIndex, int ColumnIndex, eTileState TargetTileState)
    {
        if (RowIndex < 0 || RowIndex >= WIDTH || ColumnIndex < 0 || ColumnIndex >= HEIGH)
        {
            return(false);
        }
        else if ((mapData[ColumnIndex, RowIndex] & TargetTileState) == TargetTileState)
        {
            return(false);
        }

        mapData[ColumnIndex, RowIndex] += (int)TargetTileState;
        return(true);
    }
예제 #6
0
    public bool RemoveTileState(int Index1D, eTileState TargetTileState)
    {
        int ColumnIndex;
        int RowIndex;

        ConvertIndexTo2D(Index1D, out RowIndex, out ColumnIndex);

        if (RowIndex < 0 || RowIndex >= WIDTH || ColumnIndex < 0 || ColumnIndex >= HEIGH)
        {
            return(false);
        }
        mapData[ColumnIndex, RowIndex] -= (int)TargetTileState;

        return(true);
    }
예제 #7
0
 public bool CheckTileState(int Distance, eTileState TargetTileState, int RowIndex, int ColumnIndex)
 {
     for (int i = -Distance; i < Distance + 1; i++)
     {
         for (int j = -Distance; j < Distance + 1; j++)
         {
             if (ColumnIndex + i >= 0 && ColumnIndex + i < HEIGH && RowIndex + j >= 0 && RowIndex + j < WIDTH)
             {
                 if ((mapData[ColumnIndex + i, RowIndex + j] & TargetTileState) == TargetTileState)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
예제 #8
0
        public void Build(Tower tower, bool bLoad = true)
        {
            if (bLoad)
            {
                tower.Load();
            }

            m_Tower          = tower;
            m_Tower.Position = Position;
            m_Tower.Spawned  = true;
            m_Tower.Build(this);

            m_bInUse     = true;
            m_bBuildable = false;

            // When we build, move the tile up
            m_State = eTileState.Up;
        }
예제 #9
0
    private void TouchInGamePlay()
    {
        Event m_Event = Event.current;

        if (m_Event.type == EventType.MouseDrag)
        {
            isDrag = true;

            Vector2 MouseMovePositoin = m_Event.delta;

            MouseMovePositoin              = new Vector2(-MouseMovePositoin.x, MouseMovePositoin.y);
            MainCamera.transform.position += (Vector3)MouseMovePositoin * CameraMoveSpeed;
        }

        if (m_Event.type == EventType.MouseUp)
        {
            if (!isDrag)
            {
                Vector2 WorldPosition = MainCamera.ScreenToWorldPoint(Input.mousePosition);
                int     x;
                int     y;
                ConvertTouchPositionToIndexs(WorldPosition, out x, out y);
                eTileState tileState = MapManager.GetTileState(x, y);
                if (tileState != eTileState.None)
                {
                    if ((tileState & eTileState.Enemy) == eTileState.Enemy)
                    {
                        PlayerManager.Instance.PlayerAttack((EnemyClass)MapManager.GetMapObjects(x, y));
                        NowMode = eTouchMode.None;
                    }

                    if ((tileState & eTileState.Movable) == eTileState.Movable)
                    {
                        PlayerManager.Instance.PlayerMove(x, y);
                        NowMode = eTouchMode.None;
                    }
                }
            }
            else
            {
                isDrag = false;
            }
        }
    }
예제 #10
0
 private void SetMovableTile()
 {
     for (int i = -1; i < 2; i++)
     {
         for (int j = -1; j < 2; j++)
         {
             int        targetX    = localXPos + i;
             int        targetY    = localYPos + j;
             eTileState TargetTile = MapManager.Instance.GetTileState(targetX, targetY);
             if (TargetTile != eTileState.None)
             {
                 if ((TargetTile & eTileState.BasicTile) == eTileState.BasicTile)
                 {
                     MapManager.Instance.AddTileState(targetX, targetY, eTileState.Movable);
                 }
             }
         }
     }
 }
예제 #11
0
    public bool AddTileState(Vector2 TargetPosition, eTileState TargetTileState)
    {
        int RowIndex;
        int ColumnIndex;

        ConvertPositionToIndexs(TargetPosition, out RowIndex, out ColumnIndex);

        if (RowIndex < 0 || RowIndex >= WIDTH || ColumnIndex < 0 || ColumnIndex >= HEIGH)
        {
            return(false);
        }
        else if ((mapData[ColumnIndex, RowIndex] & TargetTileState) == TargetTileState)
        {
            return(false);
        }

        mapData[ColumnIndex, RowIndex] += (int)TargetTileState;
        return(true);
    }
예제 #12
0
 public void ClearTower(bool destroying = false)
 {
     m_Tower = null;
     m_bBuildable = true;
     // If the tower is being destroyed, move the tile back down
     if (destroying)
     {
         m_State = eTileState.Down;
     }
 }
예제 #13
0
        public void Build(Tower tower, bool bLoad = true)
        {
            if (bLoad)
            {
                tower.Load();
            }

            m_Tower = tower;
            m_Tower.Position = Position;
            m_Tower.Spawned = true;
            m_Tower.Build(this);

            m_bInUse = true;
            m_bBuildable = false;

            // When we build, move the tile up
            m_State = eTileState.Up;
        }