Example #1
0
    //---------------------------------------------------------------
    void Update()
    {
        if (EnemyWaveController.GetWaveHasStarted() && !Prisoner.GetAllPrisonerDead())
        {
            spawningTime -= Time.deltaTime;

            if (spawningTime <= 0)
            {
                SpawnBattleBall();
                spawningTime            = maxSpawningTime;
                readyStartCountWaitTime = true;
            }
            if (readyStartCountWaitTime)
            {
                waitTimeForLaunched -= Time.deltaTime;
                if (waitTimeForLaunched <= 0 && ball)
                {
                    ball.GetComponent <ProjectileBall> ().PushBall();
                    waitTimeForLaunched     = maxWaitTimeForLaunched;
                    readyStartCountWaitTime = false;
                }
            }
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        //If the aiming shot is launched from straight shot
        if (GetComponent <EnemyShot>() && bCanGenerateOtherShot)
        {
            randomTimeShotExplode -= Time.deltaTime;
            if (randomTimeShotExplode <= 0)
            {
                Fire();

                //TODO add explosion effect
                GameObject explodeEffect = GetComponent <EnemyShot>().explodeParticlePref;
                Instantiate(explodeEffect, transform.position, Quaternion.identity);
                Destroy(gameObject);
            }
            return;
        }

        //If the aiming shot is launched from enemy
        if (EnemyWaveController.GetWaveHasStarted())
        {
            shotCoolDownTime -= Time.deltaTime;
            if (shotCoolDownTime <= 0f && !Prisoner.GetAllPrisonerDead())
            {
                PLAYABLE_SKILL skillToPlayThisTurn;

                if (bulletCount > 0)
                {
                    skillToPlayThisTurn = PLAYABLE_SKILL.FIRE;
                }
                else
                {
                    skillToPlayThisTurn = GetPlaySkills();
                }

                switch (skillToPlayThisTurn)
                {
                case PLAYABLE_SKILL.FIRE:
                    if (numberOfShotsPerLaunch <= 1)
                    {
                        Fire();

                        actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak);
                        shotCoolDownTime     = maxCoolDownTime + actualRandomCoolDown;
                    }
                    else if (numberOfShotsPerLaunch > 1)
                    {
                        if (bulletCount >= numberOfShotsPerLaunch)
                        {
                            actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak);
                            shotCoolDownTime     = maxCoolDownTime + actualRandomCoolDown;
                            bulletCount          = 0;
                            break;                                     //TODO check this
                        }

                        intervalPerBullets -= Time.deltaTime;
                        if (intervalPerBullets <= 0)
                        {
                            Fire();
                            bulletCount++;
                            intervalPerBullets = maxBulletInterval;
                        }
                    }
                    break;

                case PLAYABLE_SKILL.HEAL:
                    GetComponent <EnemyHealingSkill>().Heal(shotPower);
                    actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak);
                    shotCoolDownTime     = maxCoolDownTime + actualRandomCoolDown;
                    break;

                case PLAYABLE_SKILL.BOMBBARD:
                    GetComponent <EnemyBombardSkill>().Bombbard();
                    actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak);
                    shotCoolDownTime     = maxCoolDownTime + actualRandomCoolDown + 5;
                    break;

                default:
                    break;
                }
            }
        }
    }
Example #3
0
    //---------------------------------------------------------------
    void Update()
    {
        if (WinLoseCondition.GetIsGameOver() == true)
        {
            return;
        }

        if (EnemyWaveController.GetWaveHasStarted())
        {
            if (bBeingSilenced)
            {
                silencedTime -= Time.deltaTime;
                if (silencedTime <= 0)
                {
                    SpriteRenderer renderer = transform.GetChild(0).GetComponent <SpriteRenderer>();
                    renderer.color = Color.white;
                    bBeingSilenced = false;
                }
                return;
            }

            //cooldown skill over time
            skillCoolDownTime = skillCoolDownTime - Time.deltaTime;

            //visualize cooldown status
            SetSkillBar();

            if (skillCoolDownTime <= 0)
            {
                if (bIsAutoSkill)
                {
                    CastAutoPlaySkill();
                }
                else
                {
                    //Display shootable notification
                    ToggleShootableNotif(true);
                }
            }
        }

        if (bIsSkillCastEffectShowing)
        {
            //if Wave UI Text is displayed while gauge is displayed
            if (UITextController.GetUITextStatusType() == UITextController.DISPLAY_TEXT.WAVE)
            {
                if (bIsShootingSkill)
                {
                    Destroy(GameObject.FindObjectOfType <GaugeMeter>().gameObject); //hide the gauge (destroying it)
                }

                tapTimes = 0;                      //reset the tap times
                bIsSkillCastEffectShowing = false; //the flag telling the gauge is NOT displayed to shot skill
                Prisoner.UnSetPrisonIsCasting();   //the flag telling prisoner is NOT about to shot skill
                return;
            }

            //Only support skills can be activated right on the adjusting time
            CastSupportSkillWhenAdjTimeIs(true);

            needleAdjustTime = needleAdjustTime - Time.unscaledDeltaTime;

            Prisoner.SetPrisonIsCasting();
            if (needleAdjustTime <= 0)
            {
                //TODO refactor this
                //Unpause to shoot
                Time.timeScale = 1;
                skillCastingEffect.EndEffect();
                ExitStandOut();

                if (!bIsSkillUsedThisCharge)
                {
                    //if the skill is the shooting skill
                    if (bIsShootingSkill)
                    {
                        SkillShootingFromNeedle();
                        // else if the skill is the supporting skill
                    }
                    else
                    {
                        CastSupportSkillWhenAdjTimeIs(false);
                    }
                }

                bIsSkillCastEffectShowing = false;
                needleAdjustTime          = maxAdjustTime;
                Prisoner.UnSetPrisonIsCasting();
                prisonerJustUsedSkill = this.gameObject;
                FindNotYetSkillUsersToDelaySkill();
                pausingForSkill = false;
                PlayerPrefManager.SetUITextStatus(PlayerPrefManager.GUITEXT_STATUS_CHANGING);
                UITextController.SetUITextStatusType(UITextController.DISPLAY_TEXT.SKILL_NAME, playingSkillName);
            }
        }
    }