private void doHit() { StasisBubble newStasis = Instantiate <GameObject>(stasisBubblePref, transform.position, transform.rotation).GetComponent <StasisBubble>(); LevelStateManager.addStasisBubble(newStasis); cleanUp(true); }
public void doNullify() { RaycastHit2D[] hits = Physics2D.CircleCastAll(transform.position, nullFieldRadius, Vector2.zero, 0f, nullLayers); for (int i = 0; i < hits.Length; i++) { RaycastHit2D losCheck; losCheck = Physics2D.Raycast( transform.position, hits[i].collider.transform.position - transform.position, Vector2.Distance(transform.position, hits[i].collider.transform.position), nullObstLayers.value); if (losCheck.collider != null) { continue; } Entity e = hits [i].collider.GetComponent <Entity> (); if (e != null && e.getFaction() == Entity.Faction.player) { e.addStatus(Status.get("Nullified", 0.1f)); } StasisBubble sb = hits [i].collider.GetComponent <StasisBubble> (); if (sb != null) { LevelStateManager.removeStasisBubble(sb); } } }
/// <summary> /// Removes a specific instance of a StasisBubble within the list of stasisBubble /// </summary> /// <returns><c>true</c>, if stasis bubble was removed, <c>false</c> otherwise.</returns> public static bool removeStasisBubble(StasisBubble bubble) { // Error cases: // No stasis bubbles in play, bubble is null, or the list does not contain the instance of bubble if (!canRemoveStasisBubble() || bubble == null || !stasisBubbles.Contains(bubble)) { // Remove stasis event (failure) if (inst.stasisRemoved != null) { inst.stasisRemoved(false); } return(false); } // Update stasis bubble indexes for bubbles after the one being removed bool foundBubble = false; for (int i = 0; i < stasisBubbles.Count; i++) { if (stasisBubbles[i] == null) { continue; } if (stasisBubbles[i] == bubble) { foundBubble = true; continue; } if (foundBubble) { stasisBubbles[i].stasisIndex--; } } // Decrement numStasis inst.m_numStasis -= 1; if (inst.stasisUIRemoveParticles != null) { inst.stasisUIRemoveParticles[inst.m_numStasis].Play(); } // Remove the bubble from the LevelStateManager's List stasisBubbles.Remove(bubble); // Call the bubble's custom destroy function bubble.DestroyBubble(); // Remove stasis event (success) if (inst.stasisRemoved != null) { inst.stasisRemoved(true); } return(true); }
void UpdateMouseIsOver() { mouseIsOver = false; if (GameManager.isPaused()) { return; } Vector2 mouseWorldPos = (Vector2)Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane)); if (bubbleCollider.bounds.Contains(mouseWorldPos)) { // Check for a stasis bubble overlapping another stasis bubble Collider2D[] hits = Physics2D.OverlapCircleAll(bubbleCollider.bounds.center, bubbleCollider.bounds.extents.x); for (int i = 0; i < hits.Length; i++) { if (hits[i].GetComponent <StasisBubble>() != null) { StasisBubble curBubble = hits[i].GetComponent <StasisBubble>(); if (curBubble.canRightClickDestroy) { // TODO- if this stasis bubble is below the hit stasis bubble, return false if (this.stasisIndex < curBubble.stasisIndex && curBubble.mouseIsOver) { return; } } } } mouseIsOver = true; } return; }
public static bool addStasisBubble(StasisBubble bubble) { // Error cases: // No more stasis bubbles left; bubble is null; or the list already contains an instance of bubble if (!canAddStasisBubble() || bubble == null || stasisBubbles.Contains(bubble)) { // Add stasis event (failure) if (inst.stasisAdded != null) { inst.stasisAdded(false); } return(false); } if (inst.stasisUICreateParticles != null) { inst.stasisUICreateParticles[inst.m_numStasis].Play(); } // Set the bubble's index property bubble.stasisIndex = inst.m_numStasis; // Increment numStasis inst.m_numStasis += 1; // Add the bubble to LevelStateManager's List stasisBubbles.Add(bubble); // Add stasis event (success) if (inst.stasisAdded != null) { inst.stasisAdded(true); } return(true); }
// Update is called once per frame void Update() { // Time tether if (Input.GetKeyDown(createPointKey)) { if (LevelStateManager.canCreateTetherPoint()) { Debug.Log("Create tether point"); LevelStateManager.createTetherPoint(); CreateTimeTetherIndicator(new Vector3(LevelStateManager.curState, 0, 0)); } else { Debug.Log("Can't create tether point right now"); } } if (Input.GetKeyDown(KeyCode.Alpha0)) { if (LevelStateManager.canLoadTetherPoint(0) && LevelStateManager.loadTetherPoint(0)) { Debug.Log("Successfully loaded state 0"); RemoveTimeTetherIndicator(0); } else { Debug.Log("Could not load state 0"); } } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (LevelStateManager.canLoadTetherPoint(1) && LevelStateManager.loadTetherPoint(1)) { Debug.Log("Successfully loaded state 1"); RemoveTimeTetherIndicator(1); } else { Debug.Log("Could not load state 1"); } } if (Input.GetKeyDown(KeyCode.Alpha2)) { if (LevelStateManager.canLoadTetherPoint(2) && LevelStateManager.loadTetherPoint(2)) { Debug.Log("Successfully loaded state 2"); RemoveTimeTetherIndicator(2); } else { Debug.Log("Could not load state 2"); } } if (Input.GetKeyDown(KeyCode.Alpha3)) { if (LevelStateManager.canLoadTetherPoint(3) && LevelStateManager.loadTetherPoint(3)) { Debug.Log("Successfully loaded state 3"); RemoveTimeTetherIndicator(3); } else { Debug.Log("Could not load state 3"); } } if (Input.GetKeyDown(KeyCode.Alpha4)) { if (LevelStateManager.canLoadTetherPoint(4) && LevelStateManager.loadTetherPoint(4)) { Debug.Log("Successfully loaded state 4"); RemoveTimeTetherIndicator(4); } else { Debug.Log("Could not load state 4"); } } if (Input.GetKeyDown(KeyCode.Alpha5)) { if (LevelStateManager.canLoadTetherPoint(5) && LevelStateManager.loadTetherPoint(5)) { Debug.Log("Successfully loaded state 5"); RemoveTimeTetherIndicator(5); } else { Debug.Log("Could not load state 5"); } } if (Input.GetKeyDown(KeyCode.Alpha6)) { if (LevelStateManager.canLoadTetherPoint(6) && LevelStateManager.loadTetherPoint(6)) { Debug.Log("Successfully loaded state 6"); RemoveTimeTetherIndicator(6); } else { Debug.Log("Could not load state 6"); } } if (Input.GetKeyDown(KeyCode.Alpha7)) { if (LevelStateManager.canLoadTetherPoint(7) && LevelStateManager.loadTetherPoint(7)) { Debug.Log("Successfully loaded state 7"); RemoveTimeTetherIndicator(7); } else { Debug.Log("Could not load state 7"); } } if (Input.GetKeyDown(KeyCode.Alpha8)) { if (LevelStateManager.canLoadTetherPoint(8) && LevelStateManager.loadTetherPoint(8)) { Debug.Log("Successfully loaded state 8"); RemoveTimeTetherIndicator(8); } else { Debug.Log("Could not load state 8"); } } if (Input.GetKeyDown(KeyCode.Alpha9)) { if (LevelStateManager.canLoadTetherPoint(9) && LevelStateManager.loadTetherPoint(9)) { Debug.Log("Successfully loaded state 9"); RemoveTimeTetherIndicator(9); } else { Debug.Log("Could not load state 9"); } } // Stasis Keys if (Input.GetKeyDown(createStasisKey) && LevelStateManager.canAddStasisBubble()) { Vector3 spawnPos = new Vector3(transform.position.x + Random.Range(-2.0f, 2.0f), transform.position.y + Random.Range(-2.0f, 2.0f), transform.position.z); StasisBubble newStasis = ((GameObject)Instantiate(stasisBubblePrefab, spawnPos, transform.rotation)).GetComponent <StasisBubble>(); LevelStateManager.addStasisBubble(newStasis); } if (Input.GetKeyDown(removeStasisKey) && LevelStateManager.canRemoveStasisBubble()) { LevelStateManager.removeLastStasisBubble(); } // Sample tether UI if (pointText != null) { pointText.text = LevelStateManager.curState + " / " + (LevelStateManager.maxNumStates - 1); } // Sample stasis UI if (stasisText != null) { stasisText.text = LevelStateManager.numStasisLeft + " / " + LevelStateManager.maxNumStasis; } }