public void UnselectAsTarget(int playerIndex) ///this is player index (not owner index) { if (IsSelectedAsTarget(playerIndex)) { m_targetSelection &= ~(1ul << playerIndex); if (m_renderer != null) { if (m_targetSelectionOutlines != null) { cakeslice.Outline outline = m_targetSelectionOutlines.Where(o => o.layerMask == GameConstants.PlayerLayerMasks[playerIndex - 1]).FirstOrDefault(); if (outline != null) { Destroy(outline); } m_targetSelectionOutlines = null; } } else { Debug.LogError("MeshRenderer is null"); } } }
public void SelectAsTarget(int playerIndex) //this is player index (not owner index) { if (!IsSelectedAsTarget(playerIndex)) { m_targetSelection |= (1ul << playerIndex); if (m_renderer != null) { if (m_targetSelectionOutlines == null) { m_targetSelectionOutlines = new List <cakeslice.Outline>(); } cakeslice.Outline outline = m_renderer.gameObject.AddComponent <cakeslice.Outline>(); m_targetSelectionOutlines.Add(outline); outline.layerMask = GameConstants.PlayerLayerMasks[playerIndex - 1]; outline.color = 1; } else { Debug.LogError("MeshRenderer is null"); } } }
void Awake() { outline = gameObject.AddComponent <cakeslice.Outline>(); // outline.eraseRenderer = true; outline.enabled = false; lr.material.SetFloat("_RepeatCount", numBalls); defaultLineWidth = lr.widthMultiplier; }
public void Unselect(int playerIndex) ///this is player index (not owner index) { if (IsSelected(playerIndex)) { m_selection &= ~(1ul << playerIndex); if (m_selectionOutlines != null) { if (m_gameState == null) { m_gameState = Dependencies.GameState; } if (m_gameState.IsLocalPlayer(playerIndex)) { int localPlayerIndex = m_gameState.PlayerToLocalIndex(playerIndex); cakeslice.Outline outline = m_selectionOutlines.Where(o => o.layerMask == GameConstants.PlayerLayerMasks[localPlayerIndex]).FirstOrDefault(); if (outline != null) { Destroy(outline); } } m_selectionOutlines = null; } if (m_ui != null) { if (m_gameState == null) { m_gameState = Dependencies.GameState; } if (m_gameState.IsLocalPlayer(playerIndex)) { int localPlayerIndex = m_gameState.PlayerToLocalIndex(playerIndex); VoxelUI ui = m_ui.Where(o => o.gameObject.layer == GameConstants.PlayerLayers[localPlayerIndex]).FirstOrDefault(); if (ui != null) { Destroy(ui.gameObject); } } m_ui = null; } OnUnselect(playerIndex); } }
public void SetShape(GameObject shape) { Assert.IsNotNull(shape, "shape is null"); Assert.IsNotNull(shape.GetComponentInChildren <Renderer>(), "shape has no renderer"); shapeObject = shape; shapeRenderer = shape.GetComponentInChildren <Renderer>(); if (shapeRenderer.GetComponent <cakeslice.Outline>() == null) { outline = shapeRenderer.gameObject.AddComponent <cakeslice.Outline>(); } // drop it in at the point at shapeObject's position transform.position = shapeObject.transform.position; shapeObject.transform.SetParent(transform, false); shapeObject.transform.localPosition = Vector3.zero; shapeObject.transform.localRotation = Quaternion.identity; }
private void OnEnable() { m_viewport = Dependencies.GameView.GetViewport(LocalPlayerIndex); foreach (SpriteRenderer sr in m_progress.GetComponentsInChildren <SpriteRenderer>(true)) { cakeslice.Outline outline = sr.gameObject.AddComponent <cakeslice.Outline>(); outline.eraseRenderer = true; outline.layerMask = GameConstants.PlayerLayerMasks[LocalPlayerIndex]; } foreach (Transform trans in gameObject.GetComponentsInChildren <Transform>(true)) { trans.gameObject.layer = gameObject.layer; } Transform cameraTransform = m_viewport.Camera.transform; m_pivot.LookAt( transform.position + cameraTransform.rotation * Vector3.forward, cameraTransform.rotation * Vector3.up); }
public static void outlineRecursive(Transform root, bool add) { cakeslice.Outline outline = root.gameObject.GetComponent <cakeslice.Outline>(); if (add) { if (outline == null) { root.gameObject.AddComponent <cakeslice.Outline>().color = 0; } } else { if (root.gameObject.GetComponent <cakeslice.Outline>() != null) { Destroy(outline); } } foreach (Transform child in root) { outlineRecursive(child, add); } }
public void Select(int playerIndex) //this is player index (not owner index) { if (!IsSelected(playerIndex)) { m_selection |= (1ul << playerIndex); // Dependencies.GameView.GetViewport(m_gameState.PlayerToLocalIndex(pla)) if (m_gameState == null) { m_gameState = Dependencies.GameState; } if (m_gameState.IsLocalPlayer(playerIndex)) { if (m_renderer != null) { if (m_selectionOutlines == null) { m_selectionOutlines = new List <cakeslice.Outline>(); } cakeslice.Outline outline = m_renderer.gameObject.AddComponent <cakeslice.Outline>(); m_selectionOutlines.Add(outline); int localPlayerIndex = m_gameState.PlayerToLocalIndex(playerIndex); outline.layerMask = GameConstants.PlayerLayerMasks[localPlayerIndex]; if (Owner == playerIndex) { outline.color = 0; } else { if (Owner != 0) { outline.color = 1; } else { outline.color = 2; } } } if (m_uiPrefab != null) { VoxelUI ui = Instantiate(m_uiPrefab, transform, false); int localPlayerIndex = m_gameState.PlayerToLocalIndex(playerIndex); foreach (Transform t in ui.GetComponentsInChildren <Transform>(true)) { t.gameObject.layer = GameConstants.PlayerLayers[localPlayerIndex]; } ui.LocalPlayerIndex = localPlayerIndex; if (m_ui == null) { m_ui = new List <VoxelUI>(); } m_ui.Add(ui); UpdateUIVisibility(); } } OnSelect(playerIndex); } }