public BoardPosition GetPositionForGO(GameObject go) { BoardPosition position = default(BoardPosition); foreach (KeyValuePair<BoardPosition, GameObject> tile in board) { if (go.Equals(tile.Value)) { position = tile.Key; break; } Renderer r = tile.Value.GetComponent<Renderer>(); if (r != null) { Bounds b = r.bounds; if (go.transform.position.x >= b.min.x && go.transform.position.x <= b.max.x && go.transform.position.y >= b.min.y && go.transform.position.y <= b.max.y) { position = tile.Key; break; } } } return position; }
void OnParticleCollision( GameObject other) { if ( other.Equals( GameObject.FindWithTag( "Player" ) ) ) { mm.increaseMovementSpeedTemporarily(); } }
void OnDied(GameObject enemy) { if (enemy.Equals (gameObject)) { innerRotate.StopSmooth(); outterRotate.StopSmooth(); if(dropMinionsOnDeath) { foreach(Transform t in transform.FindChild("Minions")) { t.parent = transform.parent; foreach(EnemyMovement enemyMovement in t.GetComponents<EnemyMovement>()) { if(enemyMovement.GetType() == typeof(RandomMovement)) enemyMovement.enabled = true; else enemyMovement.enabled = false; } //collider was disabled when parent changed t.GetComponentInChildren<Collider2D>().enabled = true; if(OnMinionReleased != null) OnMinionReleased(t.gameObject); } } else { RemoveMinions(); } } }
public void leavePoop(GameObject collectable) { if (collectable.Equals (currentCollectable)) { onPoop = false; currentCollectable = null; } }
void OnDestroyChild(GameObject target) { if (target.Equals(maxCautionEnemy)) { maxCautionEnemy = null; if(ui)ui.BroadcastMessage("OnUpdateCaution", 0, SendMessageOptions.DontRequireReceiver); } }
public void updateSelector(GameObject newText) { // Gets called from the text itself to tell this script a mouse is pointing at it. for (int i = 0; i < selectedArray.Length; i++) { if ( newText.Equals (selectedArray[i])) { selectNum = i; changeSelector (); } } }
public override void otherCollisionEnter(GameObject enemy,Vector3 point) { if(enemy.GetComponent<HydraPlatform>()!=null){ enemy.GetComponent<HydraPlatform>().hasBeenTouched(); if(iaParent.platformDestroyed !=null && !enemy.Equals(iaParent.platformDestroyed)){ iaParent.platformDestroyed.GetComponent<HydraPlatform>().repositionPlatform(); } iaParent.platformDestroyed = enemy; } }
public bool hasConnectingPath(GameObject node) { foreach (GameObject path in connectedPaths) { if (node.Equals(path)) { return true; } } return false; }
public GameObject GetRandomDestination(GameObject current) { bool foundDest = false; GameObject go = null; while(!foundDest){ int i = Random.Range (0, navPoints.Length); go = navPoints[i]; foundDest = (go.GetComponent<NavpointScript>().isDestination && !current.Equals (go)); } return go; }
public bool isItemTouchingInventory(GameObject itemToCheck) { foreach(GameObject item in itemInInventoryTrigger) { if(itemToCheck.Equals(item)) { return true; } } return false; }
public bool isItemStoredInInventory(GameObject itemToCheck) { foreach(ItemParentSave item in itemInInventory) { if(itemToCheck.Equals(item.ItemGameObject)) { return true; } } return false; }
public Transform getParentFromItem(GameObject itemToCheck) { foreach(ItemParentSave item in itemInInventory) { if(itemToCheck.Equals(item.ItemGameObject)) { return item.parent; } } return null; }
public void ShootTarget(GameObject target) { if(!target.Equals(targetCharacter)) { if(OnBeginAttacking != null) OnBeginAttacking(target); StopCoroutine("castShot"); targetCharacter = target; StartCoroutine("castShot"); } }
public void Bounce(GameObject bounce) { if (bounce.Equals(bouncePointer1)) { bouncePointer2.SetActive(true); bouncePointer1.SetActive(false); realDeepThroat.destination = bouncePointer2.transform.position; } else { bouncePointer1.SetActive(true); bouncePointer2.SetActive(false); realDeepThroat.destination = bouncePointer1.transform.position; } }
public void MoveToward(GameObject targetCharacter) { if(!targetCharacter.Equals(moveTarget)) { moveTarget = targetCharacter; MoveTo(targetCharacter.transform.position); } else { moveTargetPosition = targetCharacter.transform.position; //moveTargetPosition.z = 0; } }
// Update is called once per frame void Update() { RaycastHit hitPos; Ray click = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(click, out hitPos)) { if(hitPos.transform.tag == "Agent" && Input.GetMouseButtonDown(0)) { unit = hitPos.transform.gameObject; //check to see if unit already selected for(int a = 0; a <= selCount; a++) { if (unit.Equals(unitArr[a])) checker = true; } //adds unit to array, "selects" it if (!checker) { unit.SendMessage("Select", 1); Debug.Log(selCount); unitArr[selCount] = unit; selCount++; checker = false; } } //use right-click to move! if(Input.GetMouseButtonDown(1)) { for (int a = 0; a < selCount; a++) { unitArr[a].SendMessage("Destination", hitPos.point); //if double-click same point, run! if (lastHit.point == hitPos.point) { unitArr[a].SendMessage("RunDude", 1); } } lastHit.point = hitPos.point; } //If L-click anything but an agent, deselects ALL agents if(hitPos.transform.tag != "Agent" && Input.GetMouseButtonDown(0)) { if(unitArr[0] != null) for (int a = 0; a < selCount; a++) unitArr[a].SendMessage("Deselect", 1); System.Array.Clear(unitArr, 0, selCount); selCount = 0; } } }
bool CheckKeyMatching(GameObject a) { if (!GetOn()) return false; bool _match = false; foreach (GameObject item in Key) { if (a.Equals(item)) { _match = true; break; } } return _match; }
IEnumerator MoveDown(GameObject uiElement) { float smoothing = 8f; Vector2 target = new Vector2(0, 0); while(Vector2.Distance(uiElement.transform.localPosition, target) > 0.05f) { uiElement.transform.localPosition = Vector2.Lerp(uiElement.transform.localPosition, target, smoothing * Time.deltaTime); yield return null; } yield return new WaitForSeconds(.1f); if (uiElement.Equals (instructions)) { GameObject.Find ("Player").GetComponent<PlayerController>().CanInput = true; } }
/* * Remove the provided enemy object from the player's list of enemies to track. */ public void ForgetEnemy(GameObject enemy) { if (enemies.Contains (enemy)) { bool sameAsTarget = enemy.Equals (fighter.target); enemies.Remove (enemy); if (sameAsTarget) { bool didRetarget = TargetNearest (); if (!didRetarget) { fighter.LoseTarget (); } } } else { Debug.LogWarning ("Tried to remove enemy from list in which it doesn't exist."); } }
public void destroyed(GameObject o) { if (gameobjects.Contains(o)) { if (o.Equals(player)) { player = null; } if (o.name.ToLower().Contains("enemy")) { EnemyCount--; } gameobjects.Remove(o); } }
void OnDied(GameObject enemy) { if (enemy.Equals (gameObject)) { StartCoroutine (StopSpinning (EnemyLife.deathTime)); if(dropMinionsOnDeath) { foreach(Transform t in transform.FindChild("Minions")) { t.parent = transform.parent; t.GetComponent<RandomMovement>().enabled = true; if(OnMinionReleased != null) OnMinionReleased(t.gameObject); } } } }
/** * Make object visible within range * * Arguments * - GameObject hiddenObject - The object to make visible */ void makeVisibleWithinRange(GameObject hiddenObject) { int distance; // The distance if (hiddenObject.Equals(gameObject)) return; // Skip over ourselves distance = MovementController.TileDistance( Player.MyPlayer.transform.position, hiddenObject.transform.position, Player.MyPlayer.GetComponent<MovementController>().GetBlockedTiles() ); if (distance <= Range) { // Within range if (hiddenObject.GetComponent<Stealth>().enabled) { hiddenObject.GetComponent<Stealth>().enabled = false; hiddenObject.GetComponentInChildren<MeshRenderer>().enabled = true; } } else { // Not within range if (!hiddenObject.GetComponent<Stealth>().enabled) hiddenObject.GetComponent<Stealth>().enabled = true; } }
public Stack ShortestPath(GameObject start, GameObject end) { InitializeNodesForShortestPath(); start.GetComponent<NavpointScript>().SetDist(0f); SortedList nodes = new SortedList(); nodes.Add (0f, start); while(nodes.Count > 0){ if(end.Equals ((GameObject)nodes.GetByIndex (0))){ break; } NavpointScript u = ((GameObject)nodes.GetByIndex (0)).GetComponent<NavpointScript>(); nodes.RemoveAt (0); u.SetVisited(); GameObject[] adj = u.GetAdjacentNodes(); for(int i = 0; i < adj.Length; i++){ NavpointScript v = adj[i].GetComponent<NavpointScript>(); float alt = u.GetDistByIndex (i) + u.GetDist (); if(alt < v.GetDist () && !v.Visited ()){ v.SetDist(alt); v.SetPrev(u.gameObject); if(nodes.ContainsValue (v)) nodes.RemoveAt (nodes.IndexOfValue (v)); nodes.Add (alt, v.gameObject); } } } Stack s = new Stack(); GameObject node = end; while(node != null){ s.Push(node); node = node.GetComponent<NavpointScript>().GetPrev(); } return s; }
public void DisplayValue(GameObject updateEnemy, int newValue) { //Debug.Log(updateEnemy.name + ".cation=" + newValue); int maxValue = 0; if (!updateEnemy.Equals(maxCautionEnemy)) { // 同一でないなら現状のMax値を持つ敵の現在の値と比較 maxValue = GetCautionValue(maxCautionEnemy); if (newValue > maxValue) { maxValue = newValue; maxCautionEnemy = updateEnemy; } } else { // 同一ならそのまま更新 maxValue = newValue; } // 最大値を表示用に通知 if(ui)ui.BroadcastMessage("OnUpdateCaution", maxValue, SendMessageOptions.DontRequireReceiver); }
public void CheckSequence(GameObject nextObject) { if(nextObject.Equals(sequence[currIndex])){ gm.GiveNotice(1f, "Correct!"); currIndex++; //if end of sequence if(currIndex==sequenceLength){ gm.GiveNotice(1f, "Found the Key!"); currIndex=0; Instantiate(Key_door1); keyAud.Play(); CanCheckSequence=false; } }else{ gm.GiveNotice(4f, "Incorrect! Enemies will spawn soon."); currIndex=0; int rand = Mathf.RoundToInt(Random.Range(0, possibleEnemies.Length-1)); GameObject enemy = possibleEnemies[rand]; StartCoroutine(SpawnMonsters(enemy)); } }
void OnDied(GameObject enemy) { if(enemy.Equals(gameObject)) { myRigidbody2D.velocity = Vector2.zero; StartCoroutine(StopSpinning(EnemyLife.deathTime)); } }
public int GetCubeTileIndex(GameObject cube) { for (int i = 0; i < Tiles.Length; i++) { Tile tile = Tiles[i]; if (cube.Equals(tile.Go)) { return tile.Id; } } Debug.LogError("Could not find Cube in Tiles."); return -1; }
public void DisplayDiscription(GameObject card, bool display) { Card cardScript = card.GetComponent<Card>(); if (display) { if (GameObject.Find("Card Hover") != null) { Destroy(GameObject.Find("Card Hover")); } GameObject hover = Instantiate((GameObject)Resources.Load("Prefabs/Card Hover")); hover.transform.SetParent(GameObject.Find("Canvas").transform); hover.transform.position = new Vector2(640,427); hover.transform.FindChild("Card").FindChild("Splash Image").GetComponent<Image>().sprite = card.transform.FindChild("Splash Image").GetComponent<Image>().sprite; hover.transform.FindChild("Card").FindChild("Card Frame").GetComponent<Image>().sprite = card.transform.FindChild("Card Frame").GetComponent<Image>().sprite; hover.transform.FindChild("Card").FindChild("Description").GetComponent<Text>().text = card.transform.FindChild("Description").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Title").GetComponent<Text>().text = card.transform.FindChild("Title").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Cost").GetComponent<Text>().text = card.transform.FindChild("Cost").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Attack").GetComponent<Text>().text = card.transform.FindChild("Attack").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Health").GetComponent<Text>().text = card.transform.FindChild("Health").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Defense").GetComponent<Text>().text = card.transform.FindChild("Defense").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Health").GetComponent<Text>().text = card.transform.FindChild("Health").GetComponent<Text>().text; hover.transform.FindChild("Card").FindChild("Range").GetComponent<Text>().text = card.transform.FindChild("Range").GetComponent<Text>().text; hover.name = "Card Hover"; foreach (GameObject c in GameObject.FindGameObjectsWithTag("Card")) { if (c.GetComponent<isDraggable>().displayZoomedView == true && !card.Equals(c)) { c.GetComponent<isDraggable>().displayZoomedView = false; Debug.Log("Display closed for " + c.name); } } } else if (!display && GameObject.Find("Card Hover") != null) { Destroy(GameObject.Find("Card Hover")); } }
public override void onCharacterDie( GameObject character ) { if (character.Equals(player)){ isGameOver = true; } }
public static Stack<GameObject> Dijkstra(GameObject start, GameObject end) { //Debug.Log (start.GetComponent<Node>().getConnections()); if(start.Equals(end)) { Stack<GameObject> temp = new Stack<GameObject>(); temp.Push(end); return temp; } List<GameObject> connections = new List<GameObject>(); GameObject endNode = start; float endNodeCost = 0; NodeRecord endNodeRecord = new NodeRecord(); NodeRecord startRecord = new NodeRecord(start, 0); List<NodeRecord> openList = new List<NodeRecord>(); List<NodeRecord> closedList = new List<NodeRecord>(); openList.Add(startRecord); NodeRecord current = startRecord; //Debug.Log (current); while(openList.Count > 0) { Debug.Log ("going through openlist"); current = getSmallestElement(openList); //Debug.Log (current); if(current.node.Equals(end)) { //Debug.Log ("Found goal"); break; } //Debug.Log("End not found contining"); connections = current.node.GetComponent<Node>().getConnections(); //Debug.Log ("Connections" + connections); foreach(GameObject connection in connections) { //Debug.Log(connection); endNode = connection.GetComponent<Connection>().toNode; endNodeCost = current.CostSoFar + connection.GetComponent<Connection>().cost + endNode.GetComponent<Node>().cost; if(isInList(endNode ,closedList)) { continue; } else if(isInList(endNode, openList)) { endNodeRecord = findNodeInList(endNode, openList); if(endNodeRecord.CostSoFar <= endNodeCost) { continue; } } else { endNodeRecord = new NodeRecord(endNode); } endNodeRecord.connection = connection; endNodeRecord.CostSoFar = endNodeCost; if(!(isInList (endNode, openList))) { openList.Add(endNodeRecord); } } openList.Remove(current); closedList.Add(current); } if(current.node != end) { return null; } else { Stack<GameObject> path = new Stack<GameObject>(); while(current.node != start) { path.Push(current.node); current = findNodeInList(current.connection.GetComponent<Connection>().fromNode, closedList); } return path; } }