コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        GameObject SceneManager = GameObject.FindWithTag("SceneManager");
        Scene1     ResetOnGoing = SceneManager.GetComponent <Scene1>();

        //Reset
        if (ResetOnGoing.bResetOnGoing == true)
        {
            Destroy(gameObject);
        }

        if (bMissile) //A Missile Type
        {
            AIFrames.EventAIStart();
            switch (AIFrames.iMovementStage)
            {
            case 1:
                STGEngine.ShootAiming("Player");
                GameObject Target = GameObject.Find("Player");
                if (Target)
                {
                    vLockon = new Vector2(Target.transform.position.x, Target.transform.position.y);
                }
                else
                {
                    //Debug.Log("No Target");
                }
                if (!bMissileDeployedSound)
                {
                    aAudioSource.PlayOneShot(aReadySound, 2);
                    bMissileDeployedSound = true;
                }
                AIFrames.EventMoveEnd(2);
                break;

            case 2:
                if (!bMissileShootSound)
                {
                    aAudioSource.PlayOneShot(aShootSound, 2);
                    bMissileShootSound = true;
                }
                STGEngine.MoveTowards(vLockon, 10.0f);
                if ((this.transform.position.x == vLockon.x) && (this.transform.position.y == vLockon.y))
                {
                    STGEngine.ShootAround(rExplosion, 10, 5.0f);
                    Destroy(gameObject);
                }
                break;
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        GameObject SceneManager = GameObject.FindWithTag("SceneManager");
        Scene1     ScoreCounter = SceneManager.GetComponent <Scene1>();
        Scene1     ResetOnGoing = SceneManager.GetComponent <Scene1>();

        //Reset
        if (ResetOnGoing.bResetOnGoing == true)
        {
            Destroy(gameObject);
        }

        AIFrames.EventAIStart();
        switch (AIFrames.iMovementStage)
        {
        case 1:
            if (iHealth > 0)
            {
                STGEngine.ShootConBullet(rMainProjec, new Vector2(0, 0), fShipFireRate);
                AIFrames.EventMoveEnd(fShipFireRate + 1);
            }
            break;

        case 2:
            if (iHealth > 0)
            {
                STGEngine.ShootConAimed(rSecondProjec, "Player", 1);
                STGEngine.ShootSoundBullet(aBasicShootSound, 1);
                AIFrames.EventMoveEnd(5.0f);
            }
            break;

        case 3:
            if (iHealth > 0)
            {
                STGEngine.ShootAround(rSecondProjec, 10, 5, 1);
                STGEngine.ShootSoundBullet(aBasicShootSound, 1);
                AIFrames.EventMoveEnd(1.0f);
            }
            break;

        case 4:
            AIFrames.EventMoveStart(1);
            break;
        }

        //Out of Bounds
        if ((this.transform.position.y <= 1))
        {
            Destroy(gameObject);
        }

        //Destroyed
        if ((iHealth <= 0) && (bAlive))
        {
            aAudioSource.PlayOneShot(aDestroySound, 1.0f);
            STGEngine.ScoretoAddtoCounter(ScoreCounter.tScoreCounter, 5);
            bAlive = false;
        }
        if (!bAlive)
        {
            spin += 5f;
            rThisBody.bodyType      = RigidbodyType2D.Dynamic;
            this.transform.rotation = Quaternion.Euler(180, 0, spin);
            gameObject.GetComponent <BoxCollider2D>().isTrigger = true;
            Destroy(gameObject, 1.0f);
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        MovementScript    Move  = gameObject.AddComponent <MovementScript>();
        ShootingMechanics Shoot = gameObject.AddComponent <ShootingMechanics>();

        GameObject SceneManager = GameObject.FindWithTag("SceneManager");
        Scene1     ScoreCounter = SceneManager.GetComponent <Scene1>();
        Scene1     ResetOnGoing = SceneManager.GetComponent <Scene1>();

        //Reset
        if (ResetOnGoing.bResetOnGoing == true)
        {
            Destroy(gameObject);
        }

        fCooldownFireRate--;
        AIFrames.EventAIStart();
        if (iHealth > 0)
        {
            switch (AIFrames.iMovementStage)
            {
            case 1:
                Move.Towards(new Vector2(0, 0), 1);
                Shoot.AroundSwirl(rMainProjec, 10, 4);
                AIFrames.EventMoveEnd(12.0f);
                break;

            case 2:
                Move.Towards(new Vector2(-2.0f, 0), 1);
                STGEngine.ShootAroundSwirl(rMainProjec, 20, 0.05f, 4, 1, false);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 3:
                Shoot.Around(rMainProjec, 20, 4);
                AIFrames.EventMoveEnd(0.0f);
                break;

            case 4:
                STGEngine.MoveTowards(new Vector2(2.0f, 0), 1);
                STGEngine.ShootAroundSwirl(rMainProjec, 20, 0.05f, 4, 1, true);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 5:
                STGEngine.ShootAround(rMainProjec, 20, 4, 1);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 6:
                STGEngine.ShootAimed(rMainProjec, "Player", 10);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 7:
                //STGEngine.ShootAimedLeading(rMainProjec, "Player", 10);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 8:
                STGEngine.MoveTowards(new Vector2(0, 1), 1);
                AIFrames.EventMoveEnd(2.0f);
                break;

            case 9:
                STGEngine.ShootAroundSwirl(rMissileProjec, 20, 0.1f, 1, 1, false);
                AIFrames.EventMoveEnd(1.0f);
                break;

            case 10:
                AIFrames.EventMoveEnd(5.0f);
                break;

            case 11:
                AIFrames.EventMoveStart(2);
                break;
            }
        }

        //Destroyed
        if ((iHealth <= 0) && (bAlive))
        {
            aAudioSource.PlayOneShot(aDestroySound, 1.0f);
            STGEngine.ScoretoAddtoCounter(ScoreCounter.tScoreCounter, 5);
            bAlive = false;
        }
        if (!bAlive)
        {
            fDeathSpin             += 5f;
            rThisBody.bodyType      = RigidbodyType2D.Dynamic;
            this.transform.rotation = Quaternion.Euler(180, 0, fDeathSpin);
            gameObject.GetComponent <CapsuleCollider2D>().isTrigger = true;
            Destroy(gameObject, 1.0f);
        }
    }