IEnumerator DoFlipAnim(bool sideways) { yield return(new WaitForSeconds(incrementFlipDelay)); if (starGameManagerRef != null) { while (starGameManagerRef.GamePaused) { yield return(null); } } GameObject currentActiveBody = ActiveBodies[currentActiveBodyInt]; Animator currentAnimator = currentActiveBody.GetComponent <Animator>(); starEnemy currentStarEnemy = currentActiveBody.GetComponentInChildren <starEnemy>(); // IMPORTANT - do a check to make sure object is active, or it will crash // rma0109 if (ActiveBodies[currentActiveBodyInt].activeSelf) { if (sideways) { if (allAreSideways) { currentAnimator.SetTrigger("flipSideways"); } else { currentAnimator.SetTrigger("flip"); } } else { currentAnimator.SetBool("orientReverse", allAreFlipped); currentAnimator.SetTrigger("flip"); } currentActiveBody.GetComponentInChildren <AudioSource>().PlayOneShot(ReorientClip); } currentActiveBodyInt++; //should this be in above bracket? // should I do a range check and return if it's above ActiveBodies.count? if (currentActiveBodyInt < ActiveBodies.Count) { StartCoroutine(DoFlipAnim(sideways)); } }
public void MiniTanksFire() { for (int i = 0; i < ActiveBodies.Count; i++) { int randomFire = Random.Range(0, RandomFireChance); if (randomFire == 1 && ActiveBodies[i].activeSelf == true) { starEnemy currentStarEnemy = ActiveBodies[i].GetComponentInChildren <starEnemy>(); // currentStarEnemy.IncrementCurrentProjectileSpawnPointCounter(); currentStarEnemy.FireProjectileNoParent(); } } }
void InstantiateNodes(int i, GameObject [] dummyNodes, GameObject SourcePrefab, GameObject parentNode) { GameObject currentBody = Instantiate(SourcePrefab) as GameObject; currentBody.transform.parent = dummyNodes[i].transform.parent.transform; currentBody.transform.position = dummyNodes[i].transform.position; currentBody.transform.rotation = dummyNodes[i].transform.rotation; ActiveBodies.Add(currentBody); currentBody.name = ("" + dummyNodes[0].name + "" + i); starEnemy currentStarEnemy = currentBody.GetComponentInChildren <starEnemy>(); currentStarEnemy.parent = currentBody; currentStarEnemy.AlertControllerOnDisable = parentNode; currentBody.GetComponentInChildren <EnemyHealth>().CollideParentToMessage = parentNode; // currentBody.GetComponentInChildren<EnemyHealth>().cantTakeDamage = true; }
IEnumerator RandomDoorController() { ShuffleDoorTimes(); yield return(new WaitForSeconds(DelayBetweenDoorsOpenUse)); while (starGameManagerRef.GamePaused) { yield return(null); } List <GameObject> doorTypeList = GreenSpawnDoors; int selectDoorType = Random.Range(0, 3); if (selectDoorType == 0) { ArmDoorControl(); } else { if (selectDoorType == 1) { doorTypeList = PurpleSpawnDoors; } GameObject randomDoor = (doorTypeList[Random.Range(0, doorTypeList.Count)]); StartCoroutine(DoorOpening(randomDoor, "")); // tell it to spawn as well, either here or in it's sub-controller starEnemy currentStarEnemy = randomDoor.GetComponentInChildren <starEnemy>(); currentStarEnemy.ProjectileFiringEnabled = true; currentStarEnemy.fireProjectile(null); StartCoroutine(CloseDoorTimer(randomDoor)); } StartCoroutine(RandomDoorController()); }
void OnDisable() { if (starGameManagerRef == null) { return; } if (shadowObject != null) { shadowObject.SetActive(false); shadowObject = null; } // if (DropOnDeath != null) if (DropOnDeath != null && Extra != "") { if (!disableSpecialEffectOnDeath) { GameObject useObject = null; useObject = starGameManagerRef.SpawnedChecker(DropOnDeath); if (useObject == null) { return; } // useObject.transform.SetParent(prefabParent.transform, false); useObject.transform.position = currentProjectileSpawnPoint.transform.position; useObject.transform.rotation = currentProjectileSpawnPoint.transform.rotation; // useObject.transform.localScale = new Vector3(3, 3, 3); if (starGameManagerRef.Caboose != null) { useObject.transform.parent = starGameManagerRef.Caboose.transform; } // passes POW type to animator and value for gameManager starEnemy useObjectStarEnemy = useObject.GetComponentInChildren <starEnemy>(); useObjectStarEnemy.animPattern = Extra; useObjectStarEnemy.Extra = Extra; useObjectStarEnemy.forceShadowActiveAtStart = true; useObject.SetActive(true); useObject.transform.localScale = new Vector3(DropScale, DropScale, DropScale); if (starGameManagerRef.gameplayMode == StarGameManager.GameplayMode.Showcase) { useObjectStarEnemy.SetHomingModeNoRaycast(); } } } CharacterDestroyed(false); UnblockAllSensors(); if (gameObject.transform.parent != null) { if (!gameObject.transform.parent.gameObject.activeSelf) { disableSpecialEffectOnDeath = true; } } // this is where pickup effect occurs if (!disableSpecialEffectOnDeath) { /* * * // gets disabled before it can actually play, and plays on next appear * if (CollisionAudio != null && audioSource != null) * { * print("SHOULD PLAY PICKUP SOUND"); * PlayAudio(CollisionAudio); * } */ if (Extra == PowerupType.LevelUp.ToString()) { { // increasing POW level starGameManagerRef.IncreasePowLevel(); } } if (Extra == PowerupType.OneUp.ToString()) { { // increasing life by one starGameManagerRef.currentLives++; } } if (Extra == PowerupType.Bomb.ToString()) { { // deploying bomb starGameManagerRef.BombEnemies(); } } if (Extra == PowerupType.Starman.ToString()) { { // starman invincibile starGameManagerRef.SetHeroStarmanMode(); } } } disableSpecialEffectOnDeath = false; if (AlertControllerOnDisable != null && parent != null) { AlertControllerOnDisable.GetComponent <BossControllerGeneric>().AlertedSubObjectDisabled(parent); } } // end disable
public void CharacterDestroyed(bool killed) { if (killed) // so killed = false if don't want character to explode on death, i.e. // if this is being called to run when out-of-bounds/end of anim // RemoveFromAnimPauseList(); { if (deathPrefab != null) { // check if instantiated GameObject deathPrefabUse = null; // deathPrefabUse = PoolCheck(starGameManagerRef.explosionsPoolInactive, deathPrefab.name); // this may give an error if starEnemy is initialized at play deathPrefabUse = starGameManagerRef.SpawnedChecker(deathPrefab); // was sending TRUE /* * if (deathPrefabUse == null) * * { * deathPrefabUse = Instantiate(deathPrefab) as GameObject; * deathPrefabUse.name = deathPrefab.name; * deathPrefabUse.transform.SetParent(parent.transform.parent, false); * } */ // if (parent != null) if (!IsObstacle && deathPrefabUse != null) { deathPrefabUse.transform.SetParent(parent.transform.parent, false); } if (DeathPrefabSpawnpoint == null) { DeathPrefabSpawnpoint = gameObject; } if (deathPrefabUse != null) { deathPrefabUse.transform.position = DeathPrefabSpawnpoint.transform.position; deathPrefabUse.SetActive(true); } } /* * if (homing == Homing.WithRaycast || ZeroPosOnDeath) * { * transform.localPosition = Vector3.zero; * } */ } // end killed if (homing == Homing.WithRaycast || ZeroPosOnDeath) { transform.localPosition = Vector3.zero; } // moved this out of "killed check" so that enemy will reset to 0 no matter what.. // if (parent != null) if (!IsObstacle) { parent.SetActive(false); } if (leader) { if (followersList.Count != 0) { GameObject newLeader = followersList[0]; starEnemy newStarEnemy = newLeader.GetComponentInChildren <starEnemy>(); newStarEnemy.leader = true; newStarEnemy.leaderObject = null; newStarEnemy.BeginShootingCounter(); starGameManagerRef.leaderList.Add(newLeader); for (int i = 0; i < (followersList.Count); i++) { if (newLeader != followersList[i]) { newStarEnemy.followersList.Add(followersList[i]); } } followersList.Clear(); } // end followersList StopCoroutine(SpawnNextFollower()); starGameManagerRef.leaderList.Remove(parent); } // END LEADER ClearEnemyProperties(); }
private IEnumerator SpawnNextFollower() { for (int i = 0; i < (followers); i++) { yield return(new WaitForSeconds(delayFollowersSpawn)); while (starGameManagerRef.GamePaused) { yield return(null); } useFollowDistanceX = useFollowDistanceX + followerDistanceX; useFollowDistanceY = useFollowDistanceY + followerDistanceY; useFollowDistanceZ = useFollowDistanceZ + followerDistanceZ; if (parent != null) { GameObject useObject = null; useObject = starGameManagerRef.SpawnedChecker(parent); if (useObject == null) { break; } bool useGrandParent = false; if (parent.transform.parent) { useObject.transform.SetParent(parent.transform.parent, false); //problem here rma920 useGrandParent = true; } starEnemy useObjectStarEnemy = useObject.GetComponentInChildren <starEnemy>(); useObjectStarEnemy.leader = false; useObjectStarEnemy.leaderObject = this.gameObject; if (!useGrandParent) { useObject.transform.SetParent(newParent, false); } useObject.transform.localPosition = leaderBeginPos; // have to test w offset useObject.transform.localPosition = new Vector3(useObject.transform.localPosition.x + useFollowDistanceX, useObject.transform.localPosition.y + useFollowDistanceY, useObject.transform.localPosition.z + useFollowDistanceZ); followersList.Add(useObject); useObject.SetActive(true); string useAnimPattern = useObjectStarEnemy.animPattern; if (SpawnAnimTriggers.Length != 0) { useAnimPattern = SpawnAnimTriggers[0]; // very dirty don't like this // actually not currently using this technique } // TriggerAnimPattern(useObjectStarEnemy.animPattern, useObjectStarEnemy.animator); TriggerAnimPattern(useAnimPattern, useObjectStarEnemy.animator); } // END IF PARENT NULL } }
void DoProjectileFiring(GameObject prefabParent, GameObject currentSpawnPoint) { // this section is used to tell enemies to be projectiles, as in final level doors spitting out ships // print("doing proj fire from "+gameObject); GameObject useObject = null; useObject = starGameManagerRef.SpawnedChecker(projectile); if (ProjectileAudio != null && audioSource != null) { PlayAudio(ProjectileAudio); } if (useObject == null) { return; } useObject.transform.SetParent(prefabParent.transform, false); useObject.transform.position = currentSpawnPoint.transform.position; useObject.transform.rotation = currentSpawnPoint.transform.rotation; ProjectileEvent.Invoke(); if (!SimultaneousSpawns && projectileSpawnPoint.Length > 1 && AutoIterateSpawnPoints) { IncrementCurrentProjectileSpawnPointCounter(); } if (ShotDirection != ShotDirection.NA) { if (useObject.GetComponent <StarProjectileAnim>()) { useObject.GetComponent <StarProjectileAnim>().shotDirection = ShotDirection; } } if (SpawnOrientation != Vector3.zero) { useObject.transform.localEulerAngles = (SpawnOrientation); } useObject.SetActive(true); // this one works!!! ----------------------------------------------------------------------------------- starEnemy starEnemy = null; if (useObject.GetComponentInChildren <starEnemy>()) { starEnemy = useObject.GetComponentInChildren <starEnemy>(); } if (starEnemy != null) { starEnemy.leader = true; starEnemy.forceShadowActiveAtStart = true; } if (SpawnAnimTriggers.Length != 0) { if (useObject.GetComponentInChildren <Animator>()) { Animator spawnAnimator = useObject.GetComponentInChildren <Animator>(); foreach (string trigger in SpawnAnimTriggers) { spawnAnimator.SetTrigger(trigger); if (starEnemy != null) { starEnemy.animPattern = trigger; } // hopefully won't cause issues //rma2019_09_25 // useObject.GetComponentInChildren<starEnemy>().SpawnAnimTriggers = SpawnAnimTriggers; // "safer" but effect not as good } } } }
IEnumerator BeginSurroundBossProcess() { if (skipIntro) { InitialActivateDelay = 0; } yield return(new WaitForSeconds(InitialActivateDelay)); // MoveNearPlayer(); gameObject.transform.position = FollowObjectOverride.transform.position; normalFiringMode = false; fireNextNormal = true; for (int i = 0; i < BodyIterations; i++) { GameObject currentBody = Instantiate(BodySource) as GameObject; currentBody.transform.parent = SpinObject.transform; currentBody.transform.localEulerAngles = new Vector3(-90, 0, currentPlacementDegreeDistance); currentBody.transform.localPosition = Vector3.zero; currentPlacementDegreeDistance = currentPlacementDegreeDistance + DegreeDistance; body.Add(currentBody); currentBody.name = "boss_surround_body_" + i; starEnemy currentStarEnemy = currentBody.GetComponentInChildren <starEnemy>(); currentStarEnemy.parent = currentBody; currentStarEnemy.AlertControllerOnDisable = gameObject; currentBody.GetComponentInChildren <EnemyHealth>().cantTakeDamage = true; } foreach (GameObject picked in body) { ActiveBodies.Add(picked); initRotationQuaternion.Add(picked, picked.transform.rotation); } for (int i = 0; i < body.Count; i++) { if (i % 2 == 0) { aboveBodies.Add(body[i]); depthDistanceAbove.Add(body[i], body[i].transform.localPosition.x); verticalDistanceAbove.Add(body[i], body[i].transform.localPosition.y); } else { belowBodies.Add(body[i]); depthDistanceBelow.Add(body[i], body[i].transform.localPosition.x); verticalDistanceBelow.Add(body[i], body[i].transform.localPosition.y); } } for (int i = 0; i < aboveBodies.Count; i++) { ActivatingBodyList.Add(aboveBodies[i]); } if (!Activate2ndReversed) { for (int i = 0; i < belowBodies.Count; i++) { ActivatingBodyList.Add(belowBodies[i]); } } else { // activates belowBodies in the reverse order of assignment, nice effect for (int i = belowBodies.Count; i-- > 0;) { ActivatingBodyList.Add(belowBodies[i]); } } // MoveNearPlayer(); if (skipIntro) { foreach (GameObject picked in body) { picked.SetActive(true); } } // check for final and set normalFiringActive = true; }