// Called on every start of game private void Start() { //Check if there is already an instance of SpawnObjects if (instance == null) { //if not, set it to this. instance = this; } //If instance already exists: else if (instance != this) { //Destroy this, this enforces our singleton pattern so there can only be one instance of SpawnObjects. Destroy(gameObject); } //Initialize prefabs nextObstacleCountdown = 0; nextObstacleInterval = (float)rnd.Next((int)obstacleMinFrequency, (int)obstacleMaxFrequency); nextFoodCountdown = 0; nextFoodInterval = (float)rnd.Next((int)foodMinFrequency, (int)foodMaxFrequency); foodAllowedToSpawn = true; obstacles = new GameObject[obstaclePoolSize]; doubleObstacles = new GameObject[doubleObstaclePoolSize]; foods = new GameObject[foodPoolSize]; }
private void OnEnable() { spawnObjects = (SpawnObjects)target; tileTypeProp = serializedObject.FindProperty("tileType"); objectTypeProp = serializedObject.FindProperty("objectType"); roomLayoutProp = serializedObject.FindProperty("roomLayout"); }
// Update is called once per frame void Update() { // Pause all spawners if (!paused && transform.position.y < stopLine) { paused = true; transform.position = new Vector2(0, stopLine); GameObject[] objs = GameObject.FindGameObjectsWithTag("Spawner"); foreach (GameObject obj in objs) { SpawnObjects spawner = obj.GetComponent <SpawnObjects> (); if (spawner != null) { spawner.StopMovement(); } else { BossScroller boss = obj.GetComponent <BossScroller> (); if (boss != null) { boss.StopMovement(); } } } DestroyAllEnemies(); BossActivate(); } //TODO: Remove this if (paused && Input.GetKeyDown(KeyCode.G)) { BossDeactivate(); } }
SpawnObjects getSpawnObjects() { GameObject player = GameObject.FindGameObjectWithTag("Tile Map"); SpawnObjects spawner = player.GetComponent("SpawnObjects") as SpawnObjects; return(spawner); }
private void Awake() { _playerShipScript = _playerShip.GetComponent <PlayerShip>(); _spawnObjects = GetComponent <SpawnObjects>(); _gameAudio = GetComponent <GameAudio>(); _uiController = FindObjectOfType <UIController>(); }
private void Start() { objectSpawner = Camera.main.GetComponent <SpawnObjects>(); if (objectSpawner == null) { Debug.LogError("Main camera has no SpawnObjects script attached."); } }
protected virtual void Start() { CurrentHealth = MaxHealth; mAudioSource = GetComponent <AudioSource>(); mSpawnObjects = GetComponent <SpawnObjects>(); mParticleHit = transform.Find("HitEffect").GetComponent <ParticleSystem>(); }
void Start() { spawnObjects = Camera.main.GetComponent <SpawnObjects>(); if (spawnObjects == null) { Debug.LogError("Main camera must contain a SpawnObjects script."); } }
private void Start() { if (TuTorialHandler.tutorial_online) { countdownTime = 100; } So = FindObjectOfType <SpawnObjects>(); StartCoroutine(CountdownStartGather()); }
private void Start() { CurrentHealth = MaxHealth; mInvulnerableTimer = 0f; mAudioSource = GetComponent <AudioSource>(); mPlayerController = GetComponent <PlayerController>(); mSpawnObjects = GetComponent <SpawnObjects>(); }
// Variable #region Variable #endregion // Property #region Property #endregion // MonoBehaviour #region MonoBehaviour #endregion // Private Method #region Private Method #endregion // Public Method #region Public Method public override void Instantiate(GameObject _GameObject, Vector3 _StandardPos, int _row, int _Cloum, Transform _ParentTransform) { var player = Instantiate <GameObject>(_GameObject, new Vector3(_StandardPos.x + (0.16f * _row), _StandardPos.y + (0.16f * _Cloum), 0), Quaternion.identity, _ParentTransform); GameCamera.Instance.SetActiveCamera(GameCamera.CameraKind.PlayerCamera); GameCamera.Instance.GetCameraObjectComponent <PlayerCamera>(GameCamera.CameraKind.PlayerCamera).SetPlayer(player.transform); player.name = Common.PlayerName; SpawnObjects.Add(player); }
// Simply gets the needed references. private void ManagerSetProperties() { mg = GetComponent <MapGenerator>(); drawer = GetComponent <MapDrawer>(); playerSpawner = GetComponent <SpawnPlayer>(); dfs = GetComponent <SpaceDFS>(); spawner = GetComponent <SpawnObjects>(); scaler = statScaler.GetComponent <Scaler>(); }
public bool AddSpawnObject(SpawnObject so) { if (m_SpawnObjects.FirstOrDefault(s => ParseType(s.SpawnName.ToLower()) == ParseType(so.SpawnName.ToLower())) == null && m_SpawnObjects.Count < SpawnerGump.MaxEntries) { SpawnObjects.Add(so); return(true); } return(false); }
private void Awake() { _rb = GetComponent <Rigidbody>(); _gameAudio = FindObjectOfType <GameAudio>(); _uiController = FindObjectOfType <UIController>(); _spawnObjects = FindObjectOfType <SpawnObjects>(); _trailLeft.enabled = false; _trailRight.enabled = false; _currentHeath = _maxHealth; }
// Variable #region Variable #endregion // Property #region Property #endregion // MonoBehaviour #region MonoBehaviour #endregion // Private Method #region Private Method #endregion // Public Method #region Public Method public override void Instantiate(GameObject _GameObject, Vector3 _StandardPos, int _row, int _Cloum, Transform _ParentTransform) { GameObject f_gameObject = Instantiate <GameObject>(_GameObject, new Vector3(_StandardPos.x + (0.16f * _row), _StandardPos.y + (0.16f * _Cloum), 0), Quaternion.identity, _ParentTransform); Enemy f_Enemy = f_gameObject.GetComponent <Enemy>(); EnemyDirection(f_Enemy, _row, _Cloum); f_Enemy.Property_SpriteRenderer.enabled = false; f_Enemy.enabled = false; SpawnObjects.Add(f_gameObject); }
// Use this for initialization void Start() { objectSpawner = GetComponent <SpawnObjects> (); ContinueUI = GameObject.FindWithTag("ContinueUI").gameObject; FirstRow = ContinueUI.transform.GetChild(0).GetComponent <Text>(); SecondRow = ContinueUI.transform.GetChild(1).GetComponent <Text>(); inputButtons = GameObject.FindWithTag("InputButtons").GetComponentsInChildren <Image> (); radars = new int[] { 1, 2, 3 }; tutorialRadarOrder = new int[] { 1, 1, 1, 2, 3 }; // Shuffle radar order radars = randomizeRadarOrder(radars); currentRadar = tutorialRadarOrder[0]; GameObject radarRootObject = GameObject.Find("Radars"); RadarObjects = new Dictionary <int, GameObject>(); RadarObjects.Add(1, radarRootObject.transform.GetChild(0).gameObject); RadarObjects.Add(2, radarRootObject.transform.GetChild(1).gameObject); RadarObjects.Add(3, radarRootObject.transform.GetChild(2).gameObject); RadarObjects[currentRadar].SetActive(true); objectSpawner.setLabelCamera(RadarObjects[currentRadar].GetComponentInChildren <Camera>()); tutorials = new List <List <Marker> >(); scenarios = new List <List <Marker> >(); original_scenarios = new List <List <Marker> >(); tutorials.Add(tutorial1Markers); tutorials.Add(tutorial2Markers); tutorials.Add(tutorial3Markers); tutorials.Add(tutorial4Markers); tutorials.Add(tutorial5Markers); original_scenarios.Add(scenario1Markers); original_scenarios.Add(scenario2Markers); original_scenarios.Add(scenario3Markers); original_scenarios.Add(scenario4Markers); original_scenarios.Add(scenario5Markers); original_scenarios.Add(scenario6Markers); original_scenarios.Add(scenario7Markers); original_scenarios.Add(scenario8Markers); original_scenarios.Add(scenario9Markers); original_scenarios.Add(scenario10Markers); scenarios = randomizeScenarioOrder(original_scenarios); csvFileName = Application.dataPath + "/participantData.csv"; playerId = generateID(); Debug.Log("Player Id is: " + playerId); }
// Powerup functionality private void ActivatePowerup() { powerupTimer = powerupDuration; powerupOn = true; animator.SetBool("powerupOn", true); //Debug.Log("Powerup activated"); //Prevents pizzas from spanwning while in superball mode. SpawnObjects.SetCanSpawnFood(false); GetComponent <SpriteRenderer> ().sprite = powerupSprite; GetComponent <CircleCollider2D> ().radius = powerupColliderRadius; SoundManager.instance.backgroudMusic.Pause(); SoundManager.instance.superMode.Play(); }
public void DespawnObject(SpawnObjects so) { if (spawnObjects.Contains(so)) { int objectsIndex = spawnObjects.IndexOf(so); int sceneIndex = SceneManager.GetActiveScene().buildIndex; AreaDespawn areaDespawn = new AreaDespawn(); areaDespawn.SceneIndex = sceneIndex; areaDespawn.SpawnObjectIndex = objectsIndex; ObjectsDestroyed.Add(areaDespawn); } }
// unitys start function void Start() { levelsNumber = 1f; maxProjectiles = 3f; timerCheckEnemies = 4f; clockTime = 0f; try { minProjectiles = 0f; } catch (MissingReferenceException) { } _spawnObjectsScript = GetComponentInParent <SpawnObjects>(); }
private void DeactivatePowerup() { animator.SetBool("powerupOn", false); //Debug.Log("Powerup deactivated"); //Pizzas can spawn again. SpawnObjects.SetCanSpawnFood(true); GetComponent <SpriteRenderer> ().sprite = basicSprite; GetComponent <CircleCollider2D>().radius = baseColliderRadius; //Stop supermode music and resume background music SoundManager.instance.superMode.Stop(); SoundManager.instance.backgroudMusic.Play(); doubleJumpCount = 0; Bounce(); //Exit's rolling with a bounce powerupOn = false; GameControl.instance.eatFood(0); }
// Public Method #region Public Method /// <summary> /// ObjectTile를 생성시 작업 /// Isntantiate를 통해서 자신의 객층구조상 위치(부모의 Transform)에 객체를 생성하며, /// 생성시 Renderer를 끄고, 필요한 기본정보를 작성 해줌 /// </summary> /// <param name="_GameObject">만들 객체</param> /// <param name="_StandardPos">타일의 0,0값</param> /// <param name="_row">행</param> /// <param name="_Cloum">렬</param> /// <param name="_ParentTransform">부모의 Transform</param> override public void Instantiate(GameObject _GameObject, Vector3 _StandardPos, int _row, int _Cloum, Transform _ParentTransform) { GameObject f_Object = Instantiate <GameObject>(_GameObject, new Vector3(_StandardPos.x + (0.16f * _row), _StandardPos.y + (0.16f * _Cloum), 0), Quaternion.identity, _ParentTransform); TileObject f_TileObject = f_Object.GetComponent <TileObject>(); f_TileObject.Renderer.enabled = false; if (f_TileObject != null) { f_TileObject.Initialized(_row, _Cloum); SetObjectPoket(f_TileObject, _row, _Cloum); } SpawnObjects.Add(f_Object); }
public BreakableObjectPropertiesViewModel( TreeViewViewModel treeParent, CompoundObjectViewModel parentVm, MainViewModel mainVm, BreakableObjectProperties modelObject, bool enabled = true) : base(treeParent, parentVm, mainVm, enabled) { ModelObject = modelObject; foreach (SpawnObject so in ModelObject.SpawnObjects) { SpawnObjectViewModel sovm = new SpawnObjectViewModel(this, parentVm, mainVm, so); SpawnObjects.Add(sovm); } }
public void CheckAllDeaths() { bool anyoneAlive = false; foreach (Player player in playerObjList) { if (player.deathState != DeathState.FINISHED) { anyoneAlive = true; break; } } if (!anyoneAlive) { if (easyModeOn) { foreach (Player player in playerObjList) { player.Respawn(); } } else { // Show retry modal retryPanel.enabled = true; // Pause all spawners GameObject[] objs = GameObject.FindGameObjectsWithTag("Spawner"); foreach (GameObject obj in objs) { SpawnObjects spawner = obj.GetComponent <SpawnObjects> (); if (spawner != null) { spawner.StopMovement(); } else { BossScroller boss = obj.GetComponent <BossScroller> (); if (boss != null) { boss.StopMovement(); } } } } } }
// Called from Boss script when hp < 0 public void BossDeactivate() { GameObject[] objs = GameObject.FindGameObjectsWithTag("Spawner"); foreach (GameObject obj in objs) { SpawnObjects spawner = obj.GetComponent <SpawnObjects> (); if (spawner != null) { if (spawner.transform.position.y < 6) { Destroy(spawner.gameObject); continue; } spawner.ResumeMovement(); } else { BossScroller boss = obj.GetComponent <BossScroller> (); if (boss != null) { boss.ResumeMovement(); } } } switch (name) { case "BossFightGenie": gameMgr.GotoSection(2); break; case "BossFightSphinx": gameMgr.GotoSection(4); break; case "BossFightAladdin": gameMgr.GotoSection(6); break; } Destroy(gameObject); }
// Start is called before the first frame update void Start() { movementScript = GameObject.Find("Cube").GetComponent <Movement>(); spawnObjectsScript = GameObject.Find("Manager").GetComponent <SpawnObjects>(); audioScript = GameObject.Find("Main Camera").GetComponent <AudioSettings>(); canvas = GameObject.Find("Canvas"); score = GameObject.Find("Score"); restartButtonObject = canvas.transform.Find("RestartButton").gameObject; restartButton = restartButtonObject.GetComponent <Button>(); restartButton.onClick.AddListener(restartOnClick); resumeButtonObject = canvas.transform.Find("ResumeButton").gameObject; resumeButton = resumeButtonObject.GetComponent <Button>(); resumeButton.onClick.AddListener(resumeOnClick); mainMenuButtonObject = canvas.transform.Find("MainMenuButton").gameObject; mainMenuButton = mainMenuButtonObject.GetComponent <Button>(); mainMenuButton.onClick.AddListener(mainMenuOnClick); localHealth = movementScript.health; resumeOnClick(); }
void Start() { sp = camera.GetComponent<SpawnObjects>(); canSpawnPyro = true; canSpawnFreezer = true; canSpawnElectronite = true; FilledBarPyro = GameObject.Find("FilledBarPyro"); ebPyro = FilledBarPyro.GetComponent<EnergyBar>(); ebPyro.valueMax = 30; FilledBarFreezer = GameObject.Find("FilledBarFreezer"); ebFreezer = FilledBarFreezer.GetComponent<EnergyBar>(); ebFreezer.valueMax = 10; FilledBarElectronite = GameObject.Find("FilledBarElectronite"); ebElectronite = FilledBarElectronite.GetComponent<EnergyBar>(); ebElectronite.valueMax = 20; }
public ObjectFactoryPropertiesViewModel( TreeViewViewModel treeParent, CompoundObjectViewModel parentVm, MainViewModel mainVm, ObjectFactoryProperties modelObject, CoSystemViewModel systemViewModel) : base(treeParent, parentVm, mainVm, systemViewModel) { _modelObject = modelObject; if (_modelObject != null) { _bodyObject = ParentVm.FindBodyObject(_modelObject.Body); } foreach (SpawnObject so in LocalModelObject.SpawnObjects) { SpawnObjectViewModel sovm = new SpawnObjectViewModel(this, parentVm, mainVm, this, so); SpawnObjects.Add(sovm); } UpdateCornerPoints(); }
private void buyStat(string name) { int cost = MockStats.getCost(name); if (this.canUpgradeStatWithCost(cost)) { PlayerAI ai = this.getPlayerAI(); ai.points -= cost; ++ai.numberOfUpgrades; SpawnObjects spawner = this.getSpawnObjects(); MeatBehaviour.SightDistance *= 1.08f; MeatBehaviour.Speed *= 1.1f; MeatBehaviour.Strength *= 1.3f; if (name.Equals("fangs")) { ai.meatDesire += 1; spawner.plantSpawnFactor -= 0.008f; MeatBehaviour.Points += 30; PlantBehaviour.Points -= 4; MeatBehaviour.Food += 20; MockStats.fangs++; kielSprite.sprite = Resources.Load <Sprite>("Player/kiel" + MockStats.fangs); } else if (name.Equals("incisors")) { ai.plantDesire += 1; spawner.meatSpawnFactor -= 0.008f; PlantBehaviour.Points += 20; MeatBehaviour.Points -= 4; PlantBehaviour.Food += 14; MockStats.incisors++; siekaczSprite.sprite = Resources.Load <Sprite>("Player/siekacz" + MockStats.incisors); } else if (name.Equals("hands")) { ai.maxHealth += 80; ai.health += 80; ai.strength += 2; ai.speed -= 0.3f; MockStats.hands++; handSprite.sprite = Resources.Load <Sprite>("Player/hand" + MockStats.hands); } else if (name.Equals("legs")) { ai.maxHealth += 80; ai.health += 80; ai.strength -= 0.2f; ai.speed += 1.0f; MockStats.legs++; legsSprite.sprite = Resources.Load <Sprite>("Player/legs" + MockStats.legs); } else if (name.Equals("brain")) { ai.maxHealth += 120; ai.health += 120; spawner.meatSpawnFactor += 0.02f; spawner.plantSpawnFactor += 0.02f; MockStats.brain++; brainSprite.sprite = Resources.Load <Sprite>("Player/brain" + MockStats.brain); } else if (name.Equals("eyes")) { ai.maxHealth += 40; ai.health += 40; ai.meatDistance += 7; ai.plantDesire -= 0.2f; MockStats.eyes++; eyesSprite.sprite = Resources.Load <Sprite>("Player/eyes" + MockStats.eyes); } else if (name.Equals("nose")) { ai.maxHealth += 40; ai.health += 40; ai.plantDistance += 7; ai.meatDesire -= 0.2f; MockStats.nose++; noseSprite.sprite = Resources.Load <Sprite>("Player/nose" + MockStats.nose); } else if (name.Equals("liver")) { ai.maxHealth += 40; ai.health += 40; ai.plantDistance -= 3.5f; ai.meatDistance -= 3.5f; ai.alcoholTolerance += 30; ai.alcoholDesire += 2.0f; MockStats.liver++; watrobaSprite.sprite = Resources.Load <Sprite>("Player/watroba" + MockStats.liver); } updateHealth(ai.health); print("Stat: " + MockStats.getStat(name)); } }
// Variable #region Variable #endregion // Property #region Property #endregion // MonoBehaviour #region MonoBehaviour #endregion // Private Method #region Private Method #endregion // Public Method #region Public Method override public void Instantiate(Tile _Tile, Vector3 _StandardPos, int _row, int _Cloum, Tilemap _Tilemap) { _Tilemap.SetTile(new Vector3Int(_row, _Cloum, 0), _Tile); SpawnObjects.Add(_Tile); }
// Use this for initialization void Start() { #region initialize Player _initialSpeed = 5f; _speed = _initialSpeed; _runningSpeed = 10f; _playerController = GetComponent <CharacterController>(); //Obtener el Controlador _currentJumps = 0; _StartPosition = transform.position; totalClientsToAttend = 10; _isTriggeredHelper = false; #endregion _modelAnim = GetComponentInChildren <Animator>(); #region initialize Camera _zoom = -5f; _playerCamera.transform.localPosition = new Vector3(0, 0, _zoom); _playerCamera.LookAt(_focusPoint); #endregion #region initialize UI foodNumber = 0; moneyEarned = 0; lifeRemaining = 3; attendedClients = 0; ShowScore(); _WinLoseText.gameObject.SetActive(false); _BackgroundImage.enabled = false; #endregion #region Get Reset Scene Script _ResetButtonScript = _ResetButton.GetComponent <Reset_Scene_Script>(); if (_ResetButtonScript == null) { Debug.LogError("Button Script Missing"); } #endregion #region Puntaje _maxPuntaje = GameObject.FindGameObjectsWithTag("Food").Length; #endregion #region Audio _audio = FindObjectOfType <AudioAdmin>(); if (_audio == null) { Debug.LogError("Audio script could not be found."); } #endregion #region SpawnObjects enemiesSpawnObj = FindObjectOfType <SpawnObjects>(); if (enemiesSpawnObj == null) { Debug.LogError("'Enemies SpawnObjects' could not be found."); } clientsSpawnObj = FindObjectOfType <ClientSpawner>(); if (clientsSpawnObj == null) { Debug.LogError("'Clients SpawnObjects' could not be found"); } collectablesSpawnerObj = FindObjectsOfType <InfiniteSpawner>(); if (collectablesSpawnerObj == null) { Debug.LogError("'Infinite Spawners' could not be found"); } #endregion #region PlayerLife maxHealth = 100; health = maxHealth; healthBar.fillAmount = health / maxHealth; InvokeRepeating("EnergyLoss", 1, 1); #endregion }
private void SetPrefabs() { if (!prefabsSet) { prefabsSet = true; } spawnObjects = GetComponent <SpawnObjects>(); coinPrefab = spawnObjects.coinPrefab; ghostPrefab = spawnObjects.ghostPrefab; heartPrefab = spawnObjects.heartPrefab; starPrefab = spawnObjects.starPrefab; blueDiamondPrefab = spawnObjects.blueDiamondPrefab; greenDiamondPrefab = spawnObjects.greenDiamondPrefab; orangeDiamondPrefab = spawnObjects.orangeDiamondPrefab; barrierPrefab = spawnObjects.barrierPrefab; goalPrefab = spawnObjects.goalPrefab; snailPrefab = spawnObjects.snailPrefab; mushroomPrefab = spawnObjects.mushroomPrefab; objects = new ArrayList { // Level 0 new SpawnableObject[] { // beatNum, prefab, trackNum new SpawnableObject(0, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(2, coinPrefab, 1), new SpawnableObject(1, snailPrefab, 3), new SpawnableObject(1, coinPrefab, 0), new SpawnableObject(2, coinPrefab, 1), new SpawnableObject(2, coinPrefab, 2), new SpawnableObject(2, coinPrefab, 1), new SpawnableObject(2, coinPrefab, 0), new SpawnableObject(2, coinPrefab, 1), new SpawnableObject(2, coinPrefab, 2), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 0), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 2), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 0), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 2), new SpawnableObject(1, snailPrefab, 4), new SpawnableObject(1, ghostPrefab, 1), new SpawnableObject(4, ghostPrefab, 0), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 0), new SpawnableObject(2, ghostPrefab, 2), new SpawnableObject(2, heartPrefab, 1), new SpawnableObject(2, starPrefab, 1), new SpawnableObject(2, ghostPrefab, 1), new SpawnableObject(1, ghostPrefab, 0), new SpawnableObject(2, blueDiamondPrefab, 1), new SpawnableObject(2, greenDiamondPrefab, 2), new SpawnableObject(2, orangeDiamondPrefab, 0), new SpawnableObject(2, barrierPrefab, 1), new SpawnableObject(4, goalPrefab, 1) }, // Level 1 new SpawnableObject[] { // beatNum, prefab, trackNum new SpawnableObject(0, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1), new SpawnableObject(1, coinPrefab, 1) } }; spawnObjects.SetupList(); }