private CombinationScript InsertCombination(float x, float z, CombinationDirection direction, int length, string playerId) { var combination = new Vector3(x, (byte)direction, z); if (dictCombinations.ContainsKey(combination)) { return(dictCombinations[combination]); } var obj = Instantiate(combinationPrefab); obj.name = "combination " + combination; obj.gameField = this; obj.UpdatePosition(x, z, direction, length); var playerSign = gameFieldUI.dictGameFieldPlayers[playerId].playerSign; var combColor = gameFieldUI.playerSignsColors[playerSign]; combColor.r *= 0.5f; combColor.g *= 0.5f; combColor.b *= 0.5f; obj.SetColor(combColor); dictCombinations.Add(combination, obj); return(obj); }
public void SubscribeKey(KeyCombination keyCombination, CombinationDirection keyargDirection, Action action) { var keyArgActionPair = new KeyArgActionPair { KeyCombination = keyCombination, Action = action }; if ((keyargDirection & CombinationDirection.Up) == CombinationDirection.Up) { _keyArgUpPairs.Add(keyArgActionPair); } if ((keyargDirection & CombinationDirection.Down) == CombinationDirection.Down) { _keyArgDownPairs.Add(keyArgActionPair); } GenerateLookups(); }
public void SubscribeKey(KeyCombination keyCombination, CombinationDirection keyargDirection, Action action) { var keyArgActionPair = new KeyArgActionPair { KeyCombination = keyCombination, Action = action }; if ((keyargDirection & CombinationDirection.Up) == CombinationDirection.Up) { _keyArgUpPairs.Add(keyArgActionPair); } if ((keyargDirection & CombinationDirection.Down) == CombinationDirection.Down) { _keyArgDownPairs.Add(keyArgActionPair); } GenerateLookups(); }
public void UpdatePosition(float x, float y, CombinationDirection direction, int length) { Vector3 position = new Vector3(x, transform.position.y, y); Quaternion rotation; Vector3 scale = transform.localScale; scale.x = length * 2 - 1; float offset = length - 1; switch (direction) { case CombinationDirection.Horizontal: rotation = Quaternion.identity; position.x -= offset; break; case CombinationDirection.Vertical: rotation = Quaternion.Euler(0, 90, 0); position.z -= offset; break; case CombinationDirection.DownUpDiagonal: rotation = Quaternion.Euler(0, 45, 0); scale.x *= SQRT2; position.x -= offset; position.z += offset; break; case CombinationDirection.UpDownDiagonal: rotation = Quaternion.Euler(0, 135, 0); scale.x *= SQRT2; position.x -= offset; position.z -= offset; break; case CombinationDirection.Undefined: default: throw new System.NotSupportedException(); } transform.SetPositionAndRotation(position, rotation); transform.localScale = scale; }