Esempio n. 1
0
    public void CheckSameColorAndAdd(CellCtrl g, int offRow, int offCol, List <CellCtrl> curList)
    {
        int curRow = g.Row;
        int curCol = g.Col;


        while (true)
        {
            int nextRow = curRow + offRow;
            int nextCol = curCol + offCol;

            if (!IsInBorder(nextRow, nextCol))
            {
                return;
            }
            var nextCell = this[nextRow, nextCol];
            curRow = nextRow;
            curCol = nextCol;
            if (g.IsMatchColor(nextCell) && nextCell.Unit.bombType != BombType.Coloring)
            {
                curList.Add(nextCell);
            }
            else
            {
                return;
            }
        }
    }
Esempio n. 2
0
 public MatchReaction GetMatchReaction(CellCtrl curCell)
 {
     Reset();
     _curCell = curCell;
     CalculateMatch();
     return(CheckReactionType());
 }
Esempio n. 3
0
//	public static void TweenPosition(this Transform transform, float duration, Vector3 position)
//	{
//		Tweener tweener = transform.GetComponent<Tweener>() ?? transform.gameObject.AddComponent<Tweener>();
//		tweener.TweenPosition(duration, position);
//	}

    //Checks if an item is next to another one, either horizontally or vertically
    public static bool AreVerticalOrHorizontalNeighbors(this CellCtrl item1, CellCtrl item2)
    {
        return
            ((item1.Col == item2.Col || item1.Row == item2.Row) &&
             Mathf.Abs(item1.Col - item2.Col) <= 1 &&
             Mathf.Abs(item1.Row - item2.Row) <= 1);
    }
Esempio n. 4
0
    public void SwapUnit(CellCtrl curCell)
    {
        UnitCtrl temp = Unit;

        Unit         = curCell.Unit;
        curCell.Unit = temp;
    }
Esempio n. 5
0
 //    public static void TweenPosition(this Transform transform, float duration, Vector3 position)
 //    {
 //        Tweener tweener = transform.GetComponent<Tweener>() ?? transform.gameObject.AddComponent<Tweener>();
 //        tweener.TweenPosition(duration, position);
 //    }
 //Checks if an item is next to another one, either horizontally or vertically
 public static bool AreVerticalOrHorizontalNeighbors( this CellCtrl item1, CellCtrl item2)
 {
     return
         (item1.Col == item2.Col || item1.Row == item2.Row) &&
             Mathf.Abs(item1.Col - item2.Col) <= 1 &&
             Mathf.Abs(item1.Row - item2.Row) <= 1;
 }
Esempio n. 6
0
 public bool IsSameColor(CellCtrl lCell, CellCtrl rCell)
 {
     if (lCell == null || rCell == null)
     {
         return(false);
     }
     return(lCell.IsMatchColor(rCell));
 }
Esempio n. 7
0
    public BombInfo(CellCtrl triggerModel, float delay,int row,int col,BombCmd bombCmd = BombCmd.None,UnitType curType = UnitType.None,int curSubType = 0,UnitColor curColor = UnitColor.None)
    {
        _triggerModel = triggerModel;
        _row = row;
        _col = col;
        _delayTime = delay;
        _bombCmd = bombCmd;

        _formType = curType;
        _subType = curSubType;
        _formColor = curColor;
    }
Esempio n. 8
0
 public bool IsMatchColor(CellCtrl oth)
 {
     if (IsEmpty || oth.IsEmpty)
     {
         return(false);
     }
     if (Unit.unitColor == oth.Unit.unitColor)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 9
0
    public BombInfo(CellCtrl triggerModel, float delay, int row, int col, BombCmd bombCmd = BombCmd.None, UnitType curType = UnitType.None, int curSubType = 0, UnitColor curColor = UnitColor.None)
    {
        _triggerModel = triggerModel;
        _row          = row;
        _col          = col;
        _delayTime    = delay;
        _bombCmd      = bombCmd;


        _formType  = curType;
        _subType   = curSubType;
        _formColor = curColor;
    }
Esempio n. 10
0
    void Update()
    {
        if (needDrop == true)
        {
            Droping();
        }

        switch (_state)
        {
        case (SwapState.Default):
        {
            if (Input.GetMouseButton(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null)
                {
                    _activeCell = hit.collider.GetComponent <CellCtrl> ();
                    _state      = SwapState.Swiping;
                }
            }
            break;
        }

        case (SwapState.Swiping):
        {
            if (Input.GetMouseButton(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null && _activeCell.gameObject != hit.collider.gameObject)
                {
                    _passiveCell = hit.collider.GetComponent <CellCtrl> ();
                    if (!_activeCell.AreVerticalOrHorizontalNeighbors(_passiveCell))
                    {
                        _state = SwapState.Default;
                        Restore();
                    }
                    else
                    {
                        _state = SwapState.Updating;

                        StartCoroutine(Swaping());
                    }
                }
            }
            break;
        }
        }
    }
Esempio n. 11
0
    public BombResult(CellCtrl curModel)
    {
        _triggerModel = curModel;

        _elimInfoList = new List<BombInfo>();

        _minCol = LevelCtrl.Current.ActiveMinCol;
        _maxCol = LevelCtrl.Current.ActiveMaxRow;

        _minRow = LevelCtrl.Current.ActiveMinRow;
        _maxRow = LevelCtrl.Current.ActiveMaxRow;

         _curRow = _triggerModel.Row;
         _curCol = _triggerModel.Col;

        CaulcElimList ();
    }
Esempio n. 12
0
    public BombResult(CellCtrl curModel)
    {
        _triggerModel = curModel;

        _elimInfoList = new List <BombInfo>();

        _minCol = LevelCtrl.Current.ActiveMinCol;
        _maxCol = LevelCtrl.Current.ActiveMaxRow;

        _minRow = LevelCtrl.Current.ActiveMinRow;
        _maxRow = LevelCtrl.Current.ActiveMaxRow;

        _curRow = _triggerModel.Row;
        _curCol = _triggerModel.Col;

        CaulcElimList();
    }
Esempio n. 13
0
    void Reset()
    {
        _curCell = null;
        _leftList.Clear();
        _rightList.Clear();
        _upList.Clear();
        _downList.Clear();

        _IsMatchLeftUp    = false;
        _IsMatchUpRight   = false;
        _IsMatchRightDown = false;
        _IsMatchDownLeft  = false;

        _leftUpCell    = null;
        _upRightCell   = null;
        _rightDownCell = null;
        _downLeftCell  = null;
    }
Esempio n. 14
0
    protected override void CaulcElimList()
    {
        float colorDelay = GameConfig.Instance.GetTime(TimeConf.colorDelay);
        var   curLvCtrl  = LevelCtrl.Current;

        for (int curRow = _minRow; curRow < _maxRow; curRow++)
        {
            for (int curCol = _minCol; curCol < _maxCol; curCol++)
            {
                CellCtrl curCell = curLvCtrl[curRow, curCol];
                if (curCell != null && curCell != _triggerModel && curCell.IsEliminateable && curCell.MatchEliminateColor(_elimColor))
                {
                    var curInfo = new BombInfo(_triggerModel, colorDelay, curRow, curCol, BombCmd.Elim);
                    _elimInfoList.Add(curInfo);
                }
            }
        }
    }
Esempio n. 15
0
    protected override void CaulcElimList()
    {
        float dyeDelay  = GameConfig.Instance.GetTime(TimeConf.dyeDelay);
        var   dyeList   = new List <BombInfo> ();
        var   curLvCtrl = LevelCtrl.Current;

        for (int curRow = _minRow; curRow < _maxRow; curRow++)
        {
            for (int curCol = _minCol; curCol < _maxCol; curCol++)
            {
                CellCtrl curCell = curLvCtrl[curRow, curCol];
                if (curCell != null && curCell != _triggerModel && curCell.IsEliminateable && !curCell.MatchEliminateColor(_dyeColor))
                {
                    var curInfo = new BombInfo(_triggerModel, dyeDelay, curRow, curCol, BombCmd.Dye);
                    curInfo._formColor = _dyeColor;
                    dyeList.Add(curInfo);
                }
            }
        }
    }
Esempio n. 16
0
    protected void FindMvpCells()
    {
        var curGrid = LevelCtrl.Current;

        for (int curRow = _minRow; curRow < _maxRow; ++curRow)
        {
            for (int curCol = _minCol; curCol < _maxCol; ++curCol)
            {
                CellCtrl curCell = curGrid[curRow, curCol];
                if (curCell != null && curCell.IsBombable)
                {
                    _mvpCellList.Add(curCell);
                }
            }
        }

        if (_mvpCellList.Count > 0)
        {
            _mvpCellList.Sort();
        }
    }
Esempio n. 17
0
    void CalculateMatch()
    {
        var curLv = LevelCtrl.Current;

        curLv.CheckSameColorAndAdd(_curCell, 0, -1, _leftList);
        curLv.CheckSameColorAndAdd(_curCell, 0, 1, _rightList);
        curLv.CheckSameColorAndAdd(_curCell, 1, 0, _upList);
        curLv.CheckSameColorAndAdd(_curCell, -1, 0, _downList);

        var curRow = _curCell.Row;
        var curCol = _curCell.Col;

        _leftUpCell    = curLv[curRow + 1, curCol - 1];
        _upRightCell   = curLv[curRow + 1, curCol + 1];
        _rightDownCell = curLv[curRow - 1, curCol + 1];
        _downLeftCell  = curLv[curRow - 1, curCol - 1];

        _IsMatchLeftUp    = curLv.IsSameColor(_curCell, _leftUpCell);
        _IsMatchUpRight   = curLv.IsSameColor(_curCell, _upRightCell);
        _IsMatchRightDown = curLv.IsSameColor(_curCell, _rightDownCell);
        _IsMatchDownLeft  = curLv.IsSameColor(_curCell, _downLeftCell);
    }
Esempio n. 18
0
    public MatchReaction(MatchHandler curHandler)
    {
        _leftList = curHandler._leftList;
        _rightList = curHandler._rightList;
        _upList = curHandler._upList;
        _downList = curHandler._downList;

        _curCell = curHandler._curCell;
        _leftUpCell = curHandler._leftUpCell;
        _upRightCell = curHandler._upRightCell;
        _rightDownCell = curHandler._rightDownCell;
        _downLeftCell = curHandler._downLeftCell;

        _horCount  = _leftList.Count + _rightList.Count + 1;
        _verCount  = _upList.Count + _downList.Count + 1;

        _IsMatchLeftUp    = curHandler._IsMatchLeftUp;
        _IsMatchRightUp   = curHandler._IsMatchUpRight;
        _IsMatchRightDown = curHandler._IsMatchRightDown;
        _IsMatchLeftDown  = curHandler._IsMatchDownLeft;

        CheckReaction ();
    }
Esempio n. 19
0
    public MatchReaction(MatchHandler curHandler)
    {
        _leftList  = curHandler._leftList;
        _rightList = curHandler._rightList;
        _upList    = curHandler._upList;
        _downList  = curHandler._downList;

        _curCell       = curHandler._curCell;
        _leftUpCell    = curHandler._leftUpCell;
        _upRightCell   = curHandler._upRightCell;
        _rightDownCell = curHandler._rightDownCell;
        _downLeftCell  = curHandler._downLeftCell;


        _horCount = _leftList.Count + _rightList.Count + 1;
        _verCount = _upList.Count + _downList.Count + 1;

        _IsMatchLeftUp    = curHandler._IsMatchLeftUp;
        _IsMatchRightUp   = curHandler._IsMatchUpRight;
        _IsMatchRightDown = curHandler._IsMatchRightDown;
        _IsMatchLeftDown  = curHandler._IsMatchDownLeft;

        CheckReaction();
    }
Esempio n. 20
0
 public VerticalResult(CellCtrl curModel) : base(curModel)
 {
 }
Esempio n. 21
0
 public DyeResult(CellCtrl curModel,UnitColor curColor)
     : base(curModel)
 {
     _dyeColor = curColor;
 }
Esempio n. 22
0
 public CrossResult(CellCtrl curModel)
     : base(curModel)
 {
 }
Esempio n. 23
0
    void Update()
    {
        if (needDrop == true) {
            Droping();
        }

        switch (_state) {
        case (SwapState.Default):
        {
            if (Input.GetMouseButton (0)) {
                var hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
                if (hit.collider != null) {
                    _activeCell = hit.collider.GetComponent<CellCtrl> ();
                    _state = SwapState.Swiping;
                }
            }
            break;
        }
        case(SwapState.Swiping):
        {
            if (Input.GetMouseButton (0)) {
                var hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
                if (hit.collider != null && _activeCell.gameObject != hit.collider.gameObject) {
                    _passiveCell = hit.collider.GetComponent<CellCtrl> ();
                    if (!_activeCell.AreVerticalOrHorizontalNeighbors(_passiveCell))
                    {
                        _state = SwapState.Default;
                        Restore();
                    }
                    else
                    {
                        _state = SwapState.Updating;

                        StartCoroutine(Swaping());
                    }
                }
            }
            break;

        }
        }
    }
Esempio n. 24
0
 public FishResult(CellCtrl curModel) : base(curModel)
 {
 }
Esempio n. 25
0
 void Restore()
 {
     _state       = SwapState.Default;
     _activeCell  = null;
     _passiveCell = null;
 }
Esempio n. 26
0
 public HorizontalResult(CellCtrl curModel) : base(curModel)
 {
 }
Esempio n. 27
0
    public void CheckSameColorAndAdd(CellCtrl g, int offRow, int offCol, List<CellCtrl> curList)
    {
        int curRow = g.Row;
        int curCol = g.Col;

        while (true) {

            int nextRow = curRow + offRow;
            int nextCol = curCol + offCol;

            if(!IsInBorder(nextRow,nextCol))
            {
                return;
            }
            var nextCell = this[nextRow,nextCol];
            curRow = nextRow;
            curCol = nextCol;
            if(g.IsMatchColor(nextCell) && nextCell.Unit.bombType != BombType.Coloring)
            {
                curList.Add(nextCell);

            }else
            {
                return;
            }
        }
    }
Esempio n. 28
0
 public bool IsSameColor(CellCtrl lCell, CellCtrl rCell)
 {
     if (lCell == null || rCell == null)
         return false;
     return lCell.IsMatchColor (rCell);
 }
Esempio n. 29
0
 public ColorResult(CellCtrl curModel, UnitColor curColor) : base(curModel)
 {
     _elimColor = curColor;
 }
Esempio n. 30
0
 public void SwapUnit(CellCtrl curCell)
 {
     UnitCtrl temp = Unit;
     Unit = curCell.Unit;
     curCell.Unit = temp;
 }
Esempio n. 31
0
 public bool IsMatchColor(CellCtrl oth)
 {
     if (IsEmpty || oth.IsEmpty)
         return false;
     if (Unit.unitColor == oth.Unit.unitColor)
         return true;
     return false;
 }
Esempio n. 32
0
 public CrossResult(CellCtrl curModel) : base(curModel)
 {
 }
Esempio n. 33
0
 public FishOneResult(CellCtrl curModel)
     : base(curModel)
 {
 }
Esempio n. 34
0
 public HorizontalResult(CellCtrl curModel)
     : base(curModel)
 {
 }
Esempio n. 35
0
 public DyeResult(CellCtrl curModel, UnitColor curColor) : base(curModel)
 {
     _dyeColor = curColor;
 }
Esempio n. 36
0
 public SquareResult(CellCtrl curModel)
     : base(curModel)
 {
 }
Esempio n. 37
0
 public FishMutipleResult(CellCtrl curModel, int num) : base(curModel)
 {
     _fishNum = num;
 }
Esempio n. 38
0
 public VerticalResult(CellCtrl curModel)
     : base(curModel)
 {
 }
Esempio n. 39
0
 public FishMutipleResult(CellCtrl curModel,int num)
     : base(curModel)
 {
     _fishNum = num;
 }
Esempio n. 40
0
 void Restore()
 {
     _state = SwapState.Default;
     _activeCell = null;
     _passiveCell = null;
 }
Esempio n. 41
0
 public ColorResult(CellCtrl curModel,UnitColor curColor)
     : base(curModel)
 {
     _elimColor = curColor;
 }
Esempio n. 42
0
 public SquareResult(CellCtrl curModel) : base(curModel)
 {
 }