/// <summary> /// Used for non player match element input. /// First set board untouchable. Send null match element and get explode event. /// If there wont be any explosion then we can set board touchable and return. If there will be any explosion then set these explosions. /// </summary> public void SetMatchElement() { SetBoardUnuouchable?.Invoke(); MatchElement matchElement = new MatchElement(); ExplodeEvent explodeEvent = hexagonLogic.Explode(matchElement); if (!explodeEvent.IsActionValid) { SetBoardTouchable?.Invoke(); return; } SetExplosion(explodeEvent); }
/// <summary> /// Player match element input. /// Set boarch untouchable. create match element with selected coords and send it to the logic to see if match request is available or not. /// With return explode event set bomb texts. If any bomb explodes then game over. /// If action is valid turn hexagon gameobjects, explode them and deselect previous selected coords. /// If action is not valid, calculate the destinations of all hexagon gameobject to make it rotation move. /// </summary> /// <param name="isTurnClockWise"></param> public void SetMacthElement(bool isTurnClockWise) { if (selectedCoords == null) { return; } SetBoardUnuouchable?.Invoke(); MatchElement matchElement = new MatchElement(selectedCoords); ExplodeEvent explodeEvent = hexagonLogic.Explode(matchElement, isTurnClockwise: isTurnClockWise); SetBombTexts(explodeEvent); if (explodeEvent.bombEvent.isBombeExploded) { Debug.Log("Bomb exploded! Game Over!"); GameOver?.Invoke(); } if (explodeEvent.IsActionValid) { Debug.Log("Player action is valid. Explosion and fill events are starting."); ChangeElementsCoordsAndPosiitons(selectedCoords, explodeEvent.turnNo, isTurnClockWise); SetExplosion(explodeEvent); DeselectHexagons(); } else { Debug.Log("Player action is not valid. Turn selected coords and return to their coords."); List <List <Vector2> > destinations = TurnClockwise(selectedCoords, 3, isTurnClockWise); TurnGridComponents(destinations); StopAllCoroutines(); StartCoroutine(Move()); } }