private void SpawnUnit(UnitData entry, int spawnIndex, Unit unit) { SpawnPointScript spawn = null; for (int i = 0; i < _spawnPoints.Count; i++) { SpawnPointScript spawnPoint = _spawnPoints[i]; if (!spawnPoint.IsOccupied) { spawn = spawnPoint; break; } } if (spawn == null) { return; } GameObject obj = Instantiate(entry.UnitPrefab, spawn.transform); UnitScript unitScript = obj.GetComponent <UnitScript>(); _unitsOnField.Add(unitScript); _playerFrame.AddUnitFrame(_game, unit, entry.UnitFrame); unitScript.Ready(spawn, this, unit); }
public void Ready(SpawnPointScript spawnPoint, PlayerScript player, Unit unit) { _targetingData = new UnitTarget(); _hoveredState = HoveredState.NotHovered; _unitAction = UnitAction.Idle; _unit = unit; _playerScript = player; _spawnPointScript = spawnPoint; transform.localPosition = Vector3.zero; _unitSprite.flipX = !_playerScript.IsMe; _spawnPointScript.SetOccupied(); _selectorArrows = new GameObject[_arrowInstanceCount]; for (int i = 0; i < _arrowInstanceCount; i++) { _selectorArrows[i] = Instantiate(_selectorArrow, transform); _selectorArrows[i].GetComponentInChildren <SpriteRenderer>().enabled = false; if (i != _arrowInstanceCount - 1) { _selectorArrows[i].transform.localScale *= 0.7f; } } _sleepEffect.SetActive(true); UpdateTexts(); ReadyEvents(); }
void CheckDead() { GameObject SP = GameObject.Find("SpawnPoint"); SpawnPointScript SPScript = SP.GetComponent <SpawnPointScript>(); if (transform.name.Contains("XWingAlly")) { SPScript.XallyCount += 1; SPScript.XcanSpawn = true; } else if (transform.name.Contains("YWingAlly")) { SPScript.YallyCount += 1; SPScript.YcanSpawn = true; } else if (transform.name.Contains("AWingAlly")) { SPScript.AallyCount += 1; SPScript.AcanSpawn = true; } if (GameObject.Find("TPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("TPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("XPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("XPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("APlayer") != null) { PlayerControls PlayerScript = GameObject.Find("APlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("YPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("YPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("FPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("FPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("SPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("FPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } else if (GameObject.Find("NPlayer") != null) { PlayerControls PlayerScript = GameObject.Find("FPlayer").GetComponent <PlayerControls>(); PlayerScript.impScore += 1; } Destroy(gameObject); }
void OnTriggerExit(Collider other) { if (other.gameObject.GetComponent <SpawnPointScript>()) { SpawnPointScript spawnScript = other.gameObject.GetComponent <SpawnPointScript>(); spawnScript.PlayerExit(); } }
void OnCollisionEnter(Collision col) { if (this.transform.gameObject.tag == "ingredient" & col.gameObject.tag != "ingredient" & !SpawnPointScript.gameOver) { // play sound if it is enabled if (MenuScript.SoundOn == true) { source.Play(); } this.transform.gameObject.tag = "GroundedSlice"; // adding gameobject to the list of grounded slices to calculate highest point of the sanwich SpawnPointScript.slicesInPile.Add(this.transform.gameObject); // disable on the fly boolean. User input is available again SpawnPointScript.sliceOntheFly = false; // spawning new slice on after collision with the base SpawnPointScript spw = FindObjectOfType <SpawnPointScript>(); GameObject spawnP = GameObject.Find("Spawn_point"); // Using the x coordinate of the slice to spawn next one Vector3 SpawnCoord = new Vector3(this.transform.position.x, spawnP.transform.position.y, spawnP.transform.position.z); if (gameObject.name != "Free(Clone)") { spw.SpawnSlice(SpawnCoord, true); MenuScript.scoreValue += 1; } else { // seperate spawn technique for the bunch of free SpawnPointScript.numPotatoesCollided++; if (SpawnPointScript.numPotatoesCollided == 6) { Debug.Log("Request to spawn fries sent - onCollision"); spw.SpawnSlice(SpawnCoord, true); SpawnPointScript.numPotatoesCollided = 0; //--- Free spawn DISABLED MenuScript.scoreValue0 += 1; } } // stability assist feature FreezeLowerSlices(); SimplifiedCollisionDetector(); } }
private void OnTriggerStay(Collider other) { if (other.gameObject.GetComponent <SpawnPointScript>() && !possessed) { SpawnPointScript spScript = other.gameObject.GetComponent <SpawnPointScript>(); if (spScript.areThereGhosts) { inCircle = true; } else { inCircle = false; } } }
// Use this for initialization void Start() { action = 0; movingSpeed = 1.0f; direction = 1; nextWaypoint = transform.position; waypoint = GameObject.Find("Spawn Points"); waypointsList = waypoint.GetComponent <SpawnPointScript> (); anim = GetComponent <Animator> (); if (waypoint == null) { Debug.Log("Spawn points not found"); } RandomIdleTime(); }
void OnTriggerEnter(Collider other) { if (other.CompareTag("GhostProj")) { Destroy(other.gameObject); health -= 1; } if (other.gameObject.GetComponent <SpawnPointScript>()) { SpawnPointScript spawnScript = other.gameObject.GetComponent <SpawnPointScript>(); spawnScript.PlayerEnter(); } if (other.CompareTag("Exit") && hudScript.ghostcount == 0) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }
private void ReadySpawnPoints() { string prefix = _isMe ? "Blue_" : "Red_"; _spawnPoints = new List <SpawnPointScript>(); _spawnPoints.Add(GameObject.FindGameObjectWithTag(prefix + "BossSpawn") .GetComponent <SpawnPointScript>()); for (int i = 1; i <= 6; i++) { SpawnPointScript spawnPointScript = GameObject .FindGameObjectWithTag(prefix + "Spawn " + i) .GetComponent <SpawnPointScript>(); _spawnPoints.Add(spawnPointScript); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.GetComponent <SpawnPointScript>() && !possessed) { SpawnPointScript spScript = other.gameObject.GetComponent <SpawnPointScript>(); if (spScript.areThereGhosts) { audioSource.PlayOneShot(audioClips[clipNum]); inCircle = true; } else { inCircle = false; } } if (other.gameObject.GetComponent <Ghost_Possessor>()) { other.gameObject.GetComponent <MeshRenderer>().enabled = false; possessed = true; } }
private void Start() { if (!photonView.IsMine && PhotonNetwork.IsConnected) { if (gameObject.GetComponent <AudioListener>()) { gameObject.GetComponent <AudioListener>().enabled = false; } return; } minimapCam = GameObject.Find("MinimapCam"); minimapCam.GetComponent <Minimap>().Initiate(gameObject.transform); spawnParent = GameObject.FindWithTag("GameManager"); pointer = GameObject.Find("Pointer"); promptText = GameObject.Find("Prompt").GetComponent <TextMeshProUGUI>(); missionTimeUI = GameObject.Find("MissionTimeText").GetComponent <TextMeshProUGUI>(); cashUI = GameObject.Find("CashText").GetComponent <TextMeshProUGUI>(); missionStatus = GameObject.Find("MissionStatus").GetComponent <TextMeshProUGUI>(); int spawn = GameObject.FindWithTag("SpawnMan").GetComponent <SpawnManScript>().spawns[PhotonNetwork.NickName]; transform.position = spawnParent.transform.GetChild(spawn).position; SpawnPointScript spawnMats = spawnParent.transform.GetChild(spawn).gameObject.GetComponent <SpawnPointScript>(); // Set frame, shirt and helmet mat + icon Material[] mats = meshRender.materials; meshRender.enabled = true; mats[2] = mats[4] = spawnMats.bikeMat; // frame & fork mats[6] = spawnMats.shirtMat; // shirt mats[9] = spawnMats.helmetMat; // helmet meshRender.materials = mats; iconRender.material = spawnMats.bikeMat; if (GameObject.Find("Loading")) { GameObject.Find("Loading").SetActive(false); } missionTimeUI.text = ""; cashUI.text = "0 $"; cash = 0; hasJob = false; job = null; _dropZone = null; musicMan = musicManGo.GetComponent <MusicManager>(); missionStatusTimer = 3f; missionStatusCountdown = false; missionStatus.text = ""; EndPrompt(); leaderBoard = PhotonNetwork .Instantiate("LeaderBoard", new Vector3(0f, 0f, 0f), new Quaternion(0f, 0f, 0f, 0f)); leaderBoard.transform.SetParent(GameObject.Find("HUD").transform); leaderBoard.GetComponent <RectTransform>().anchoredPosition = new Vector2(210, -80); pointer.GetComponent <RectTransform>().anchoredPosition = new Vector2(-100, -100); pointerText = pointer.GetComponentInChildren <TextMeshProUGUI>(); }
public void Restart() { nextButton.SetActive(false); //unhiding back the resume button resBut.GetComponent <Image>().color = new Color(255, 255, 255, 255f); resBut.GetComponentInChildren <Text>().text = "Resume"; // zeroing the values SpawnPointScript.currentSlice = 0; // resetting the values in scripts DestroyAllObjects(); scoreValue0 = 0; scoreValue = 0; scoreValue1 = 0; Time.timeScale = 1f; levelProgress = 0; ProgressBar.fillRatio = 0.05f; // reseting the infill ofthe progress bar accuracy1 = 0; // resetting the accuracy accuracy2 = 0; accuracy3 = 0; nextLevelOpen = false; // getting the new values for in-level score value scoreLimit = SpawnPointScript.FoodSequenceFull[currentLevel].Length - 2; // removing all menus and switches mainMenu.SetActive(false); MenuUI.SetActive(false); SpawnPointScript.gameOver = false; PausePressed = false; colliderBase.resultUploaded = false; // instantiate box and glass SpawnItemsOnPlate(); //GameObject obj1 = Instantiate(box, new Vector3(-0.68f, -7.9f,-1.04f), Quaternion.Euler(0f, 0, 0f)) as GameObject; //GameObject obj2 = Instantiate(glass, new Vector3(2.22f, -8f, -1.29f), Quaternion.Euler(0f, 0, 0f)) as GameObject; //GameObject obj3 = Instantiate(fluidLevel, new Vector3(2.22f, -8.06f, -1.32f), Quaternion.Euler(0f, 0, 0f)) as GameObject; //spawning the first slice at all spawn points SpawnPointScript spw = FindObjectOfType <SpawnPointScript>(); spw.SpawnSlice(new Vector3(spw.transform.position.x + 0f, spw.transform.position.y, spw.transform.position.z + 0.5f), true); // resetting the camera and spawn position to initial -- DISABLED --- spw.ResetCameraAndSpawnPos(); // clearing the lists of gameobjects used for height calculations SpawnPointScript.slicesInPile.Clear(); numRestarts++; /* * if(Monetization.IsReady("video") & numRestarts%3 ==0) * { * ShowAdPlacementContent ad = null; * ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent; * * if(ad !=null){ * ad.Show(); * } else { * Debug.Log("ad =null"); * } * } */ }
public void SetSpawnPoint(SpawnPointScript spawn) { spawnPoint = spawn; }
public void RegisterSpawnPoint(SpawnPointScript spawnPoint) { spawnPoints.Add(spawnPoint); }