private void CalculateTargetPosition() { SquareManager squareManager = SquareManager.instance; float reserve = StickersController.TileSize / 3; if (StickersController.Horizontal) { float minX = squareManager.TilesPositions[0, 0].x - reserve; float maxX = squareManager.TilesPositions[0, squareManager.Side - 1].x + reserve; if (targetPosition.x < minX) { targetPosition.x = minX; } if (targetPosition.x > maxX) { targetPosition.x = maxX; } } else { float minY = squareManager.TilesPositions[squareManager.Side - 1, 0].y - reserve; float maxY = squareManager.TilesPositions[0, 0].y + reserve; if (targetPosition.y < minY) { targetPosition.y = minY; } if (targetPosition.y > maxY) { targetPosition.y = maxY; } } }
public virtual void Rotate() { int rotationNum = 50; for (int i = 0; i < rotationNum; i++) { int rotationVar = Side == 3 ? 4 : 6; // Number of possible rotations int rotation = Random.Range(1, rotationVar + 1); switch (rotation) { case 1: Clockwise(); break; case 2: AntiClockwise(); break; case 3: Row(); break; case 4: Column(); break; case 5: LargeClockwise(); break; case 6: LargeAntiClockwise(); break; } } SquareManager.Rotation(); }
public override void Rotate() { int rotationNum = 100; for (int i = 0; i < rotationNum; i++) { bool row = Random.Range(0, 2) == 1; int position = Random.Range(0, Side); // Num of row/column to rotate int offset = Random.Range(1, Side); bool emptyCenter = (SquareManager as EmptySquareManager).emptyCenter; if (emptyCenter) { if (position == Side / 2) // Can't rotate middle column and row { continue; } } else { if (position == 1 || position == Side - 2) { continue; } } RotateLine(row, position, offset); } SquareManager.Rotation(); }
void Awake() { squares = null; maxX = 0; maxY = 0; lg = GetComponent <LevelGenerator>(); instance = this; }
private void Start() { mainCam = MainCam.Instance; squareManager = SquareManager.Instance; // getting spray particle components. spray = transform.GetChild(0).gameObject; sprayParticles = spray.GetComponentsInChildren <ParticleSystem> (); }
void Start() { squareManager = SquareManager.instance; gameManager = GameManager.instance; HasAngle = false; AnimationRun = false; CanDrag = true; Paused = false; }
public override void OnInspectorGUI() { DrawDefaultInspector(); SquareManager squareManager = (SquareManager)target; if (GUILayout.Button("New Square")) { squareManager.NewSquare(); } }
void Awake() { if (instance == null) { instance = this; } else { if (instance != this) { Destroy(gameObject); } } }
public virtual void Rotate() { int rotationNum = 50; for (int i = 0; i < rotationNum; i++) { bool row = Random.Range(0, 2) == 1; int position = Random.Range(0, Side); int offset = Random.Range(1, Side); RotateLine(row, position, offset); } SquareManager.Rotation(); }
public void Cmd_RequestFood() { int x = 1; int y = 1; bool valid = false; while (!valid) { x = Random.Range(1, width - 2); y = Random.Range(1, height - 2); SquareManager sm = get_SM(x, y); valid = sm.isOpen() && x != 3; } SendFood(x, y); }
public CollisionManager() { sqrMan = new SquareManager(); entsqrs = new RecycleArray<EntitySquares>(EntitySquares.CopyMethod, EntitySquares.CreateCopyMethod); entsqrs.SetDataMode(false); addedEntSqrTemp = new EntitySquares(); addedECITemp = new EntityCollisionInfo(); collideAgainstEnts = new List<Entity>(); collideAgainstBlocks = new List<Block>(); collideEntsInfo = new RecycleArray<EntityCollisionInfo>(EntityCollisionInfo.CopyMethod, EntityCollisionInfo.CreateCopyMethod); collideEntsInfo.SetDataMode(false); collideBlocksInfo = new RecycleArray<EntityCollisionInfo>(EntityCollisionInfo.CopyMethod, EntityCollisionInfo.CreateCopyMethod); collideBlocksInfo.SetDataMode(false); colliderList = new List<Collider>(); }
void InitializeBoard() { BoardStateGO = new GameObject[BoardHeight, BoardWidth]; for (int y = 0; y < BoardHeight; y++) { for (int x = 0; x < BoardWidth; x++) { //reverse y during this so output matches map generator int yReverse = (BoardHeight - y) - 1; GameObject GridSquare = Instantiate(Prefabs[BoardState[yReverse, x]], new Vector3((-4.6f + x) / 2, (-5f + y) / 2, 0f), Quaternion.identity); //this eventually needs cleaned up for resizing to board size and resolution SquareManager state = GridSquare.GetComponent <SquareManager>(); state.GameState = BoardState[yReverse, x]; state.x = x; state.y = yReverse; BoardStateGO[yReverse, x] = GridSquare; } } }
public void Cmd_RequestClaim(int player, int x, int y) { Debug.Log("Player attempting claim " + x.ToString() + " " + y.ToString() + " for player " + player.ToString()); SquareManager sm = get_SM(x, y); PlayerManager pm = players[player].GetComponent <PlayerManager>(); if (sm.isDeath()) { Debug.Log("Killing player" + player.ToString()); Debug.Log("Death due to coordinate: " + x.ToString() + " " + y.ToString()); Debug.Log("Finished setup is: " + finishedSetup.ToString()); pm.Rpc_Die(); return; } if (sm.isFood()) { Debug.Log("Growing"); pm.Rpc_Grow(); Cmd_RequestFood(); } SendClaim(player, x, y); }
private void Awake() { Instance = this; squares = GetComponentsInChildren <Square> (); Init(); }
public void Rpc_ReceiveClaim(int player, Color c, int x, int y, int commandID) { SquareManager squareManager = get_SM(x, y); squareManager.makeClaim(player, c, commandID); }
public void Rpc_ReceiveFood(int x, int y, int commandID) { SquareManager squareManager = get_SM(x, y); squareManager.makeFood(commandID); }
// ==== HELPERS =========== private SquareManager get_SM(int x, int y) { SquareManager sm = squareData[x, y].square.GetComponent <SquareManager>(); return(sm); }