Esempio n. 1
0
    /// <summary>
    /// 定期的に実行するタスク(1フレームごと)
    /// </summary>
    public void TaskAppear()
    {
        if (!counter.IsTimeOver())
        {
            counter.Update();
            if (counter.IsTimeOver())
            {
                //MhCommon.Print("reset");
                counter.SetCounter(0.5f);
                GameObject enemy     = enemyFactory.Create(StgEnemyConstant.Type.kStraightMoveEnemy);            //StgEnemyConstant.Type.kEnemyNormal);
                EnemyBase  enemyBase = enemy.GetComponent <EnemyBase>();

                RandomIntegerSystem random = new RandomIntegerSystem();
                int value = random.Get(0, 2);
                if (value == 0)
                {
                    enemyBase.SetPosition(new Vector2(0.0f, 6.0f));
                    //Instantiate(enemy, new Vector3(0.0f, 6.0f, 0.0f), Quaternion.identity);
                }
                else if (value == 1)
                {
                    enemyBase.SetPosition(new Vector2(0.5f, 6.0f));
                    //Instantiate(enemy, new Vector3(0.5f, 6.0f, 0.0f), Quaternion.identity);
                }
                else
                {
                    enemyBase.SetPosition(new Vector2(-0.5f, 6.0f));
                    //Instantiate(enemy, new Vector3(-0.5f, 6.0f, 0.0f), Quaternion.identity);
                }
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// やられた時のエフェクトタイプをランダム生成する
    /// </summary>
    /// <param name="x">エフェクトのX座標</param>
    /// <param name="y">エフェクトのY座標</param>
    private void CreateRandomEffect(float x, float y)
    {
        StgEffectFactory factory = new StgEffectFactory();

        MhCommon.Assert(factory != null, "NormalEnemy::CreateRandomEffect() StgEffectFactory null");
        RandomIntegerSystem random = new RandomIntegerSystem();

        MhCommon.Assert(random != null, "NormalEnemy::CreateRandomEffect() RandomIntegerSystem null");
        int value = random.Get(1, 3);

        StgEffectConstant.Type type = StgEffectConstant.Type.kExplosion;
        MhCommon.Assert((value >= 1) && (value <= 3), "NormalEnemy::CreateRandomEffect() random range failure");
        if (value == 1)
        {
            type = StgEffectConstant.Type.kExplosion;
        }
        else if (value == 2)
        {
            type = StgEffectConstant.Type.kExplosion002;
        }
        else
        {
            type = StgEffectConstant.Type.kExplosion003;
        }
        GameObject effect = factory.Create(type);

        MhCommon.Assert(effect != null, "NormalEnemy::CreateRandomEffect() effect null");
        Instantiate(effect, new Vector3(x, y, 0), Quaternion.identity);
    }