private IEnumerator startFirePattern(int slotID, int gap, int randomGap, int continuous, int continuousGap, int randomContinuous) { /* * gap (ms): Time gap between segments * randomGap (ms): Random period for Time gap (Gap + (0 <->randomGap)) * continuous (ms): Numbers of Fire shot in a segment * continuousGap (ms): Gap between Fire shots in a segment * randomContinuous (ms): Random period for continuousGap (continuousGap + (0 <-> randomContinoous)) */ yield return(new WaitForSeconds(1f * (gap + rnd.Next(0, randomGap)) / 1000f)); //TEMPORARY WeaponDB weaponDB = GameObject.Find("GameMaster").GetComponent <WeaponDB>(); while (userInfo.hp > 0) { for (int i = 0; i < continuous; i++) { weaponDB.useCard(ref userInfo, userInfo.currentCard, gameObject); yield return(new WaitForSeconds(1f * (continuousGap + rnd.Next(0, randomContinuous)) / 1000f)); } yield return(new WaitForSeconds(1f * (gap + rnd.Next(0, randomGap)) / 1000f)); } }
// Update is called once per frame void Update() { //PLAYER POSITION playerPositionX = transform.position.x; playerPositionY = transform.position.y; //BASIC MOVEMENT /* * Vector2 mousePos = thecamera.ScreenToWorldPoint(Input.mousePosition); * gameObject.transform.position = Vector2.Lerp(gameObject.transform.position, mousePos, 50 * Time.deltaTime); */ //PROJECTILE FIRING (HOLDING) if (firingState == 1) { if (userInfo.inventory[userInfo.currentCard].delay <= 0 && userInfo.overheatState == 0 && (userInfo.weakShot == 0 || (userInfo.weakShot == 1 && userInfo.heat >= userInfo.inventory[userInfo.currentCard].heatDes))) { WeaponDB weaponDB = GameObject.Find("GameMaster").GetComponent <WeaponDB>(); //get components from the "WeaponDB" script in the GameObject "GameMaster" weaponDB.useCard(ref userInfo, userInfo.currentCard, gameObject); //WEAPON OVERHEAT TRIGGER if (userInfo.heat < 0) { //WeaponOverheated (); TEMPORARY REMOVED userInfo.heat = 0; } } } //IN OVERHEAT STATE else if (userInfo.overheatState == 1) { if (userInfo.heat >= userInfo.heatMax) //Get out of overheat state when Heat reaches Max { userInfo.overheatState = 0; } } // CONSOLE SHIP STATE (ANIMATOR) if (Mathf.RoundToInt(userInfo.heat) >= 0 && userInfo.heat < userInfo.heatMax && userInfo.overheatState == 1 && coolingProcessAwait == 1) //Heat reaches 0 => Initialize cooling process { shipstateAnim.SetBool("startCooling", true); SystemAudioDB systemaudiodb = GameObject.Find("GameMaster").GetComponent <SystemAudioDB>(); //non-static void => get component required systemaudiodb.playSFX(sysAudioSource, "overheat2"); coolingProcessAwait = 0; } if (userInfo.heat >= userInfo.heatMax) { shipstateAnim.SetBool("startCooling", false); shipstateAnim.SetBool("isCooling", false); } // //UPDATE PER FRAMES: WEAPON DELAY DECREASES (Can only shoot when Delay reaches 0) userInfo.inventory[userInfo.currentCard].delay -= Time.deltaTime * 60; if (userInfo.inventory[userInfo.currentCard].delay < 0) { userInfo.inventory[userInfo.currentCard].delay = 0; } // //UPDATE PER FRAMES: WEAPON COOLDOWN (OVERHEAT SYSTEM) if (firingState == 0 || userInfo.weakShot == 1) { userInfo.heat += 15 * Time.deltaTime; } if (userInfo.heat > userInfo.heatMax) { userInfo.heat = userInfo.heatMax; } // //UPDATE PER FRAMES: WEAKSHOT checked if (userInfo.heat > userInfo.inventory[userInfo.currentCard].heatDes + 1) { userInfo.weakShot = 0; } else if (userInfo.heat <= 0) { userInfo.weakShot = 1; } // }