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; } } }
public MatchReaction GetMatchReaction(CellCtrl curCell) { Reset(); _curCell = curCell; CalculateMatch(); return(CheckReactionType()); }
// 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); }
public void SwapUnit(CellCtrl curCell) { UnitCtrl temp = Unit; Unit = curCell.Unit; curCell.Unit = temp; }
// 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; }
public bool IsSameColor(CellCtrl lCell, CellCtrl rCell) { if (lCell == null || rCell == null) { return(false); } return(lCell.IsMatchColor(rCell)); }
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; }
public bool IsMatchColor(CellCtrl oth) { if (IsEmpty || oth.IsEmpty) { return(false); } if (Unit.unitColor == oth.Unit.unitColor) { return(true); } return(false); }
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; }
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; } } }
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 (); }
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(); }
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; }
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); } } } }
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); } } } }
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(); } }
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); }
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 (); }
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(); }
public VerticalResult(CellCtrl curModel) : base(curModel) { }
public DyeResult(CellCtrl curModel,UnitColor curColor) : base(curModel) { _dyeColor = curColor; }
public CrossResult(CellCtrl curModel) : base(curModel) { }
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; } } }
public FishResult(CellCtrl curModel) : base(curModel) { }
void Restore() { _state = SwapState.Default; _activeCell = null; _passiveCell = null; }
public HorizontalResult(CellCtrl curModel) : base(curModel) { }
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; } } }
public bool IsSameColor(CellCtrl lCell, CellCtrl rCell) { if (lCell == null || rCell == null) return false; return lCell.IsMatchColor (rCell); }
public ColorResult(CellCtrl curModel, UnitColor curColor) : base(curModel) { _elimColor = curColor; }
public bool IsMatchColor(CellCtrl oth) { if (IsEmpty || oth.IsEmpty) return false; if (Unit.unitColor == oth.Unit.unitColor) return true; return false; }
public FishOneResult(CellCtrl curModel) : base(curModel) { }
public DyeResult(CellCtrl curModel, UnitColor curColor) : base(curModel) { _dyeColor = curColor; }
public SquareResult(CellCtrl curModel) : base(curModel) { }
public FishMutipleResult(CellCtrl curModel, int num) : base(curModel) { _fishNum = num; }
public FishMutipleResult(CellCtrl curModel,int num) : base(curModel) { _fishNum = num; }
public ColorResult(CellCtrl curModel,UnitColor curColor) : base(curModel) { _elimColor = curColor; }