コード例 #1
0
 public void OnHexOver(HexField hex)
 {
     foreach (HexListenerInterface listener in listenerList)
     {
         listener.OnHexOver(hex);
     }
 }
コード例 #2
0
 public void OnBuildStart(HexField patternHex, int colNumber, int rowNumber, Vector2 hexSize, bool isEven, bool symmetricHorizontal)
 {
     foreach (BuilderListenerInterface listener in listenerList)
     {
         listener.OnBuildStart(patternHex, colNumber, rowNumber, hexSize, isEven, symmetricHorizontal);
     }
 }
コード例 #3
0
        public void AddHex(string groupName, HexField hex)
        {
            Group group;

            if (groupList.TryGetValue(groupName, out group))               //znaczy że dana grupa już istnieje
            {
                bool isNew = true;
                foreach (string actualHexGroupName in hex.groupListNames)
                {
                    if (actualHexGroupName == groupName)
                    {
                        isNew = false;
                        break;
                    }
                }
                if (isNew == true)                //dany hex nie jest w tej grupie
                {
                    group.list.Add(hex);
                    hex.groupListNames.Add(groupName);
                }
            }
            else                 // trzeba utworzyć grupę
            {
                group      = new Group();
                group.name = groupName;
                group.list.Add(hex);
                groupList.Add(groupName, group);
                hex.groupListNames.Add(groupName);
            }
        }
コード例 #4
0
//		private int colMinCoordinate, rowMinCoordinate, colMaxCoordinate, rowMaxCoordinate;
        public void Add(Vector3 coordinates, HexField hex)
        {
//			Vector2 offsetCoordinates;
//			if (isEven) {
//				offsetCoordinates = HexMath.ConvertCubeToEvenROffsetCoordinate ((int)coordinates.x, (int)coordinates.y, (int)coordinates.z);
//			} else {
//				offsetCoordinates = HexMath.ConvertCubeToOddROffsetCoordinate ((int)coordinates.x, (int)coordinates.y, (int)coordinates.z);
//			}
//			if (this.hexList.Count == 0) {
//				colMinCoordinate = (int)offsetCoordinates.x;
//				colMaxCoordinate = (int)offsetCoordinates.x;
//				rowMinCoordinate = (int)offsetCoordinates.y;
//				rowMaxCoordinate = (int)offsetCoordinates.y;
//			}
//			if (offsetCoordinates.x < colMinCoordinate) {
//				colMinCoordinate = (int)offsetCoordinates.x;
//			} else if (offsetCoordinates.x > colMaxCoordinate) {
//				colMaxCoordinate = (int)offsetCoordinates.x;
//			}
//			if (offsetCoordinates.y < rowMinCoordinate) {
//				rowMinCoordinate = (int)offsetCoordinates.y;
//			} else if (offsetCoordinates.y > rowMaxCoordinate) {
//				rowMaxCoordinate = (int)offsetCoordinates.y;
//			}
            hex.SetCoordinates(coordinates);
            this.hexList.Add(coordinates, hex);
            hex.SetListenerList(this.listenerList);
        }
コード例 #5
0
 public void OnHexBoardUp(HexField hex)
 {
     foreach (BoardListenerInterface listener in listenerList)
     {
         listener.OnHexBoardUp(hex);
     }
 }
コード例 #6
0
        /**
         * jeśli jest jakikolwiek false to przerwie budowę hexa ale odpyta wszystkie listenery
         */
//		public bool OnCreateHexStart(Vector3 coordinates){
//			bool allResult = true;
//			foreach (BuilderListenerInterface listener in listenerList) {
//				bool result = listener.OnCreateHexStart(coordinates);
//				if(result == false){
//					Debug.Log ("MAMY FALSE");
//					allResult = false;
//				}
//			}
//			return allResult;
//		}
        public void OnCreateHexEnd(HexField hex)
        {
            foreach (BuilderListenerInterface listener in listenerList)
            {
                listener.OnCreateHexEnd(hex);
            }
        }
コード例 #7
0
 //        private int colMinCoordinate, rowMinCoordinate, colMaxCoordinate, rowMaxCoordinate;
 public void Add(Vector3 coordinates, HexField hex)
 {
     //			Vector2 offsetCoordinates;
     //			if (isEven) {
     //				offsetCoordinates = HexMath.ConvertCubeToEvenROffsetCoordinate ((int)coordinates.x, (int)coordinates.y, (int)coordinates.z);
     //			} else {
     //				offsetCoordinates = HexMath.ConvertCubeToOddROffsetCoordinate ((int)coordinates.x, (int)coordinates.y, (int)coordinates.z);
     //			}
     //			if (this.hexList.Count == 0) {
     //				colMinCoordinate = (int)offsetCoordinates.x;
     //				colMaxCoordinate = (int)offsetCoordinates.x;
     //				rowMinCoordinate = (int)offsetCoordinates.y;
     //				rowMaxCoordinate = (int)offsetCoordinates.y;
     //			}
     //			if (offsetCoordinates.x < colMinCoordinate) {
     //				colMinCoordinate = (int)offsetCoordinates.x;
     //			} else if (offsetCoordinates.x > colMaxCoordinate) {
     //				colMaxCoordinate = (int)offsetCoordinates.x;
     //			}
     //			if (offsetCoordinates.y < rowMinCoordinate) {
     //				rowMinCoordinate = (int)offsetCoordinates.y;
     //			} else if (offsetCoordinates.y > rowMaxCoordinate) {
     //				rowMaxCoordinate = (int)offsetCoordinates.y;
     //			}
     hex.SetCoordinates(coordinates);
     this.hexList.Add(coordinates , hex);
     hex.SetListenerList(this.listenerList);
 }
コード例 #8
0
 public void AnimationGoToHex(HexField hex, float animationSpeed = 5, bool animationEventBlock = false)
 {
     isAnimation              = true;
     this.animationSpeed      = animationSpeed;
     this.animationEventBlock = animationEventBlock;
     animationTarget          = CalculateBoardNewPosition(-hex.transform.localPosition);
 }
コード例 #9
0
 public void AnimationGoToHex(HexField hex, float animationSpeed = 5, bool animationEventBlock = false)
 {
     isAnimation = true;
     this.animationSpeed = animationSpeed;
     this.animationEventBlock = animationEventBlock;
     animationTarget = CalculateBoardNewPosition(-hex.transform.localPosition);
 }
コード例 #10
0
 /**
  * usuwamy hexa z danej groupy
  */
 public void RemoveHexFromGroup(string groupName, HexField hex)
 {
     Group group;
     if (groupList.TryGetValue (groupName, out group)) {//znaczy że dana grupa już istnieje
         group.list.Remove(hex);
         hex.groupListNames.Remove(groupName);
     } else { // dana grupa nie istnieje więc hex w niej też nie istnieje
     }
 }
コード例 #11
0
 public void OnHexDown(HexField hex)
 {
     if (isAnimation && animationEventBlock)
     {
         return;                                               //jeśli animacja zablokowała eventy
     }
     if (enabledClickEvents)
     {
         this.listenerList.OnHexBoardDown(hex);
     }
 }
コード例 #12
0
        /**
         * usuwamy hexa z danej groupy
         */
        public void RemoveHexFromGroup(string groupName, HexField hex)
        {
            Group group;

            if (groupList.TryGetValue(groupName, out group))               //znaczy że dana grupa już istnieje
            {
                group.list.Remove(hex);
                hex.groupListNames.Remove(groupName);
            }
            else                 // dana grupa nie istnieje więc hex w niej też nie istnieje
            {
            }
        }
コード例 #13
0
        /**
         * zwraca listę sąsiednich hexów, gdy range 1 to zwraca tylko pierwsze sąsiedztwo, gdy range 2, to kolejny pierścien dodatkowo
         */
        public List <HexField> GetNeighbors(Vector3 centerCoordinates, int range = 1)
        {
            List <HexField> list            = new List <HexField>();
            List <Vector3>  coordinatesList = HexMath.GetRange(centerCoordinates, range, 0);           //by pominąć kliknięty hex i zwrócić sąsiedztwo

            foreach (Vector3 neigborCoordinates in coordinatesList)
            {
                HexField hex = this.GetHex(neigborCoordinates);
                if (hex != null)
                {
                    list.Add(hex);
                }
            }
            return(list);
        }
コード例 #14
0
 public void OnHexUp(HexField hex)
 {
     if (isInputDrag)              //jeśli jest drag to zatrzymuje informacje o hexUp
     {
         return;
     }
     if (isAnimation && animationEventBlock)
     {
         return;                                               //jeśli animacja zablokowała eventy
     }
     if (enabledClickEvents)
     {
         this.listenerList.OnHexBoardUp(hex);
     }
 }
コード例 #15
0
 public void AddHex(string groupName, HexField hex)
 {
     Group group;
     if (groupList.TryGetValue (groupName, out group)) {//znaczy że dana grupa już istnieje
         bool isNew = true;
         foreach(string actualHexGroupName in hex.groupListNames){
             if(actualHexGroupName == groupName){
                 isNew = false;
                 break;
             }
         }
         if(isNew == true){//dany hex nie jest w tej grupie
             group.list.Add(hex);
             hex.groupListNames.Add(groupName);
         }
     } else { // trzeba utworzyć grupę
         group= new Group();
         group.name = groupName;
         group.list.Add(hex);
         groupList.Add(groupName, group);
         hex.groupListNames.Add(groupName);
     }
 }
コード例 #16
0
 /**
  *  ustawia centrum planszy w pozycji danego hexa
  */
 public void GoToHex(HexField hex)
 {
     isAnimation = false;
     this.board.transform.position = CalculateBoardNewPosition(-hex.transform.localPosition);
 }
コード例 #17
0
 /**
  * ustawia centrum planszy w pozycji danego hexa w sposób animowany
  * animationEventBlock jeśli true to blokuje dotyk i ręczne przesuwanie mapy
  * w przeciwnym razie gracz może próbować wymusić inny ruch
  */
 public void AnimationGoToHex(HexField hex, float animationSpeed = 3, bool animationEventBlock = false)
 {
     boardController.AnimationGoToHex (hex, animationSpeed, animationEventBlock);
 }
コード例 #18
0
 public void OnHexUp(HexField hex)
 {
     foreach (HexListenerInterface listener in listenerList) {
         listener.OnHexUp(hex);
     }
 }
コード例 #19
0
 /**
  *  ustawia centrum planszy w pozycji danego hexa
  */
 public void GoToHex(HexField hex)
 {
     boardController.GoToHex (hex);
 }
コード例 #20
0
 public void OnHexDown(HexField hex)
 {
     if (isAnimation && animationEventBlock)return;//jeśli animacja zablokowała eventy
     if (enabledClickEvents) {
         this.listenerList.OnHexBoardDown (hex);
     }
 }
コード例 #21
0
 /**
  *  ustawia centrum planszy w pozycji danego hexa
  */
 public void GoToHex(HexField hex)
 {
     isAnimation = false;
     this.board.transform.position = CalculateBoardNewPosition(-hex.transform.localPosition);
 }
コード例 #22
0
 public void OnHexBoardDown(HexField hex)
 {
     foreach (BoardListenerInterface listener in listenerList) {
         listener.OnHexBoardDown(hex);
     }
 }
コード例 #23
0
 /**
  * ustawia centrum planszy w pozycji danego hexa w sposób animowany
  * animationEventBlock jeśli true to blokuje dotyk i ręczne przesuwanie mapy
  * w przeciwnym razie gracz może próbować wymusić inny ruch
  */
 public void AnimationGoToHex(HexField hex, float animationSpeed = 3, bool animationEventBlock = false)
 {
     boardController.AnimationGoToHex(hex, animationSpeed, animationEventBlock);
 }
コード例 #24
0
 public void OnCreateHexEnd(HexField hex)
 {
 }
コード例 #25
0
 public void OnBuildStart(HexField patternHex, int colNumber, int rowNumber, Vector2 hexSize, bool isEven, bool symmetricHorizontal)
 {
 }
コード例 #26
0
 /**
  * pozwala dodać hex do grupy
  */
 public void AddHexToGroup(string groupName, HexField hex)
 {
     groupController.AddHex (groupName, hex);
 }
コード例 #27
0
 public void OnHexUp(HexField hex)
 {
     if (isInputDrag) {//jeśli jest drag to zatrzymuje informacje o hexUp
         return;
     }
     if (isAnimation && animationEventBlock)return;//jeśli animacja zablokowała eventy
     if (enabledClickEvents) {
         this.listenerList.OnHexBoardUp (hex);
     }
 }
コード例 #28
0
 public void OnBuildStart(HexField patternHex, int colNumber, int rowNumber, Vector2 hexSize, bool isEven, bool symmetricHorizontal)
 {
     foreach (BuilderListenerInterface listener in listenerList) {
         listener.OnBuildStart(patternHex, colNumber, rowNumber, hexSize, isEven, symmetricHorizontal);
     }
 }
コード例 #29
0
 public void OnBuildStart(HexField patternHex, int colNumber, int rowNumber, Vector2 hexSize, bool isEven, bool symmetricHorizontal)
 {
 }
コード例 #30
0
 /**
  *  ustawia centrum planszy w pozycji danego hexa
  */
 public void GoToHex(HexField hex)
 {
     boardController.GoToHex(hex);
 }
コード例 #31
0
 public void OnCreateHexEnd(HexField hex)
 {
 }
コード例 #32
0
 /**
  * pozwala dodać hex do grupy
  */
 public void AddHexToGroup(string groupName, HexField hex)
 {
     groupController.AddHex(groupName, hex);
 }
コード例 #33
0
 public void OnHexOver(HexField hex)
 {
 }
コード例 #34
0
 /**
  * jeśli jest jakikolwiek false to przerwie budowę hexa ale odpyta wszystkie listenery
  */
 //        public bool OnCreateHexStart(Vector3 coordinates){
 //            bool allResult = true;
 //            foreach (BuilderListenerInterface listener in listenerList) {
 //                bool result = listener.OnCreateHexStart(coordinates);
 //                if(result == false){
 //                    Debug.Log ("MAMY FALSE");
 //                    allResult = false;
 //                }
 //            }
 //            return allResult;
 //        }
 public void OnCreateHexEnd(HexField hex)
 {
     foreach (BuilderListenerInterface listener in listenerList) {
         listener.OnCreateHexEnd(hex);
     }
 }
コード例 #35
0
 public void OnHexOver(HexField hex)
 {
 }
コード例 #36
0
        /**
         * do rzeczywistej budowy potrzebujemy rozmiar  hexa i ilość hexów, nie potrzebujemy rozmiaru mapy
         */
        private BoardHex BuildCalc()
        {
            if (board.IsReady() == true)               //znaczy że ta plansza jest już zbudowana
            {
                return(board);
            }
            hexPattern.gameObject.SetActive(false);
            float calcHeigh  = HexMath.CalculateColumnHeight(recommendHexHeight, rowNumber);
            float halfHeight = calcHeigh / 2;            //rowNumber / 2;
            float halfWidth  = 0;

            if (rowNumber > 1 && symmetricHorizontal == false)             // jak symmetricHorizontal true to nie ma przesunięcia wynikającego z połowy hexa na szerokość
            {
                halfWidth = HexMath.CalculateMultiRowWidth(hexWidth, colNumber) / 2;
            }
            else
            {
                halfWidth = HexMath.CalculateRowWidth(hexWidth, colNumber) / 2;
            }
            Transform hexObject;

            board.Config(colNumber, rowNumber, new Vector2(hexWidth, recommendHexHeight), isEven, symmetricHorizontal);
            this.listenerList.OnBuildStart(hexPattern, colNumber, rowNumber, new Vector2(hexWidth, recommendHexHeight), isEven, symmetricHorizontal);
            int inverse = 0;             //ponieważ inverse nie jest hexem o y = 0 tylko jest zależny od rowNumber musimy mieć inną wartość inverse

            if (isEven == true && rowNumber % 2 == 1)
            {
                inverse = 0;
            }
            else if (isEven == true && rowNumber % 2 == 0)
            {
                inverse = 1;
            }
            else if (isEven == false && rowNumber % 2 == 1)
            {
                inverse = 1;
            }
            else if (isEven == false && rowNumber % 2 == 0)
            {
                inverse = 0;
            }
            for (int y = rowNumber - 1; y >= 0; y--)
            {
                for (int x = 0; x < colNumber; x++)
                {
                    if (symmetricHorizontal && x == colNumber - 1 && inverse == 0)
                    {
                        break;
                    }
                    Vector3 newCoordinates;
                    if (isEven)
                    {
                        newCoordinates = HexMath.ConvertEvenROffsetToCubeCoordinate(x, y);
                    }
                    else
                    {
                        newCoordinates = HexMath.ConvertOddROffsetToCubeCoordinate(x, y);
                    }
                    bool listenerResult = this.listenerList.OnCreateHexStart(newCoordinates, new Vector2(x, y), (inverse == 1)?true:false);
                    if (listenerResult == false)
                    {
                        continue;
                    }
                    hexObject = (Transform)Instantiate(hexPattern.transform, new Vector3(0, 0, 0), Quaternion.identity);
                    hexObject.gameObject.SetActive(true);
                    hexObject.transform.parent = board.transform;
                    HexField hexComponent = hexObject.GetComponent <HexField> ();
                    hexComponent.Init();
                    hexComponent.SetPosition(new Vector3(hexWidth * x + hexWidth - inverse * 0.5f * hexWidth - halfWidth, -3 * (y) * recommendHexHeight / 4 + halfHeight - recommendHexHeight / 2, 0));
                    hexComponent.SetSize(new Vector2(hexWidth, recommendHexHeight));
                    board.Add(newCoordinates, hexComponent);
                    hexObject.name = "Hex " + hexComponent.GetCoordinates().ToString() + " " + x + " " + y;
                    this.listenerList.OnCreateHexEnd(hexComponent);
                }
                inverse = (inverse == 1)?0:1;              //na wysokość co drugi wiersz ma przesunięcie - w ten sposób to oznaczamy
            }

//			board.SetHexNumber (colNumber, rowNumber);
            board.Recalculate();
            board.SetReady();
            this.listenerList.OnBuildEnd();
            return(board);
        }