public void Highlight(int tx, int ty, int tz, byte whosTurn) { if (previewX == tx && previewY == ty && previewZ == tz) { return; } previewX = tx; previewY = ty; previewZ = tz; int sizex = stones.GetLength(0); int sizey = stones.GetLength(1); int sizez = stones.GetLength(2); for (int x = 0; x < sizex; x++) { for (int y = 0; y < sizey; y++) { for (int z = 0; z < sizez; z++) { StoneController stone = stones[x, y, z]; if (stone.value > 0) { continue; } stone.gameObject.SetActive(tz == z); bool isHover = (tx == x && ty == y && tz == z); if (isHover) { stones[x, y, z].SetPreviewState(whosTurn); } stones[x, y, z].SetPreviewShow(isHover); } } } }
public void AddNeighbor(StoneController stone) { if (!neighbors.Contains(stone)) { neighbors.Add(stone); } }
void MakeBuddies(StoneController stone1, StoneController stone2, StoneController stone3) { stone1.AddNeighbor(stone2); stone1.AddNeighbor(stone3); stone2.AddNeighbor(stone1); stone2.AddNeighbor(stone3); stone3.AddNeighbor(stone1); stone3.AddNeighbor(stone2); }
private void RealPut(int x, int y, int color) { Vector3 position = BasePoint.position + new Vector3(x, 0.05f, y); Stones[x, y] = GameObject.Instantiate(stone, position, Quaternion.Euler(0, 0, 0)) as GameObject; StoneController script = Stones[x, y].GetComponent <StoneController>(); script.SetColor(color); }
/// <summary> /// This method sends out raycasts that look for collisions with the stone's colliders. /// </summary> private void MeshUpdate(Ray ray) { RaycastHit hit; Debug.DrawRay(ray.origin, ray.direction * 10); if (Physics.Raycast(ray, out hit, float.PositiveInfinity)) { StoneController stone = hit.collider.GetComponent <StoneController>(); if (stone.value == 0) { if (Input.GetButtonDown("Fire1")) { stone.SetGameState(1); } } } }
void ApplyDamage(GameObject other) { if (other.tag == "PigTag") { Pigscript = (PigController)other.GetComponent(typeof(PigController)); Pigscript.HpController(power); } if (other.tag == "TreeTag") { Treescript = (TreeController)other.GetComponent(typeof(TreeController)); Treescript.HpController(power); } if (other.tag == "StoneTag") { Stonescript = (StoneController)other.GetComponent(typeof(StoneController)); Stonescript.HpController(power); } }
void Start() { mesh = GetComponentInChildren <MeshFilter>(); IndexPairs[] edges = GetEdges(); float closest = 1; foreach (IndexPairs pair in edges) { Vector3 a = mesh.mesh.vertices[pair.a]; Vector3 b = mesh.mesh.vertices[pair.b]; float d = (a - b).sqrMagnitude; if (d < closest) { closest = d; } } float separation = minimumSeparation / Mathf.Sqrt(closest); mesh.transform.localScale = Vector3.one * separation; StoneController[] stones = new StoneController[mesh.mesh.vertices.Length]; for (int i = 0; i < mesh.mesh.vertices.Length; i++) { Vector3 v = mesh.mesh.vertices[i] * separation; Quaternion rot = Quaternion.FromToRotation(Vector3.up, mesh.mesh.normals[i]); StoneController stone = Instantiate(stonePrefab, v, rot, transform); stone.SetGameState(0); stones[i] = stone; } foreach (IndexPairs pair in edges) { StoneController a = stones[pair.a]; StoneController b = stones[pair.b]; a.AddNeighbor(b); b.AddNeighbor(a); } }
public void registerClick(StoneController unit) { attackTarget = unit; Move(); }