public static Rank item()
        {
/*
 *          if (entity != null) {
 *              Debug.Log("item():30 entity enable");
 *          } else {
 *              Debug.Log("item():32 entity disable");
 *          }
 */
            return(entity.rand(Mathf.FloorToInt(GameStageService.status("clear_count") * item_rank_scale)));
        }
Esempio n. 2
0
        public static void startSpawn()
        {
            // ゲームステージサービスから敵の数もらう
            int enemy_num = GameStageService.status("enemy_num");

            // スポーン中なら現在のスポーンを中止
            stopSpawn();

            Debug.Log("EnemyService.startSpawn()");

/*
 *          // 1秒に1回、x回まで処理する(敵の出現数が上限を超えてたら待つ)
 *          spawn_disposable = Observable.Interval(System.TimeSpan.FromSeconds(1)).Take(enemy_num).Subscribe(y => {
 *              // ランクに合わせて敵を生成
 *              EnemyEntity enemy = EnemyService.create();
 *              // 左から出るか前から出るかを決定
 *              SpawnerPoint point = EnemyService.random_pos();
 *              // 敵オブジェクトに設定
 *              EnemyService.set_direction(enemy, point);
 *              // 出撃
 *              EnemyService.activate(enemy);
 *          });
 */
            int spawn_count = 0;

            // (敵の出現数が上限を超えてたら待つ)が出来ていないので修正必要
            // スポーンタイマーは基本的に無制限に動作するようにし、動作内で敵を上限まで出現させたかどうか判定させる
            // 出現済みで生きてる敵の数を数えて、出現上限に達していたら次まで待つ
            // 出現済みで生きてる敵の数が出現上限数以下で、かつ生成上限にまだ達していなければ敵を生成
            spawn_disposable = Observable.Interval(System.TimeSpan.FromSeconds(1)).Subscribe(x => {
                // 生成上限に達していたら終了
                if (enemy_num <= spawn_count)
                {
                    return;
                }
                spawn_count += 1;

                // アクティブな敵が出現上限に達していたら終了
                if (spawn_limit <= GameObject.FindGameObjectsWithTag("Enemy").Length)
                {
                    return;
                }

                // ランクに合わせて敵を生成
                EnemyEntity enemy = EnemyService.create();
                // 左から出るか前から出るかを決定
                SpawnerPoint point = EnemyService.random_pos();
                // 敵オブジェクトに設定
                EnemyService.set_direction(enemy, point);
                // 出撃
                EnemyService.activate(enemy);
            });
        }
Esempio n. 3
0
        public static EnemyEntity createEntity(Rank rank, EnemyType id)
        {
            if (!base_resources.ContainsKey(rank) || !base_resources[rank].ContainsKey(id))
            {
                throw new KeyNotFoundException();
            }

            var enemy_strength = GameStageService.status("enemy_strength");
            var entity         = base_resources[rank][id].clone();

            entity.id  = entity_id;
            entity_id += 1;

            var strength = Mathf.RoundToInt(enemy_strength * strength_scale);
            //var exp = Mathf.RoundToInt(GameStageService.status("clear_count") * exp_scale);
            var exp = Mathf.RoundToInt(enemy_strength * exp_scale);

            if (exp < 1)
            {
                exp = 1;
            }

            //Debug.Log("EnemyFactory : enemy_strength * exp_scale : " + (enemy_strength * exp_scale).ToString());
            //Debug.Log("EnemyFactory : exp : " + exp.ToString());

            entity.lv  = GameStageService.status("clear_count") + 1;
            entity.exp = exp;

            var hp = entity.hp + Mathf.RoundToInt(entity.lv * hp_scale);

            entity.hp     = hp;
            entity.hp_max = hp;

            entity.atk = Random.Range(base_random[rank].Item1, base_random[rank].Item2) + strength;
            entity.def = Random.Range(base_random[rank].Item1, base_random[rank].Item2) + strength;
            entity.spd = Random.Range(base_random[rank].Item1, base_random[rank].Item2) + strength;
            //Debug.Log("atk: " + entity.atk);
            //Debug.Log("def: " + entity.def);
            //Debug.Log("spd: " + entity.spd);

/*
 *          Debug.Log("Enemy spawn; " +
 *              entity.lv.ToString() + " / " +
 *              entity.exp.ToString() + " / " +
 *              entity.hp_max.ToString() + " / " +
 *              entity.atk.ToString() + " / " +
 *              entity.def.ToString() + " / " +
 *              entity.spd.ToString()
 *          );
 */

            return(entity);
        }
Esempio n. 4
0
        public static void save()
        {
            Debug.Log("SaveDataService.save()");

            // 装備データ保存
            // savePlayerEquip(_use_slot, EqiupService.entity);

            // プレイヤーデータ保存
            savePlayer(use_slot, PlayerService.entity);

            // ステージデータ保存
            StageSaveData stage_save_data = new StageSaveData {
                room_clear_count = GameStageService.status("clear_count"),
                enemy_strength   = GameStageService.status("enemy_strength"),
                enemy_num        = GameStageService.status("enemy_num"),
            };

            saveStage(use_slot, stage_save_data);
        }
        public static Rank bgm()
        {
            var bgm_rank = Mathf.FloorToInt(GameStageService.status("clear_count") * bgm_rank_scale);

            //var bgm_rank = GameStageService.room_clear_count;

            switch (bgm_rank)
            {
            case 0: return(Rank.D);

            case 1: return(Rank.C);

            case 2: return(Rank.B);

            case 3: return(Rank.A);

            default: return(Rank.S);
            }
        }
 public static Rank enemy()
 {
     return(entity.rand(Mathf.FloorToInt(GameStageService.status("enemy_strength") * enemy_rank_scale)));
 }
Esempio n. 7
0
/*
        public static void backgroundFade(float rate, float time = 0.5f)
        {
            var image = fade_background.GetComponent<Image>();
            image.color = new Color(0, 0, 0, rate);
        }
*/


        public static void update()
        {
            if (_state != GuiState.Room) return;

            // *左上*
            // Lv表示
            string lv_str = PlayerService.statuString("Lv");
            ui_text["Lv"].text = lv_str;

            // 経験値バー
            int lv = PlayerService.status("Lv");
            int exp = PlayerService.now_exp();
            int next_level = PlayerService.next_exp();
            //Debug.Log("exp: " + exp.ToString());
            //Debug.Log("next_level: " + next_level.ToString());
            ui_bar["ExpBar"].value = exp;
            ui_bar["ExpBar"].maxValue = next_level;
            /*
            ui_bar["ExpBar"].value = PlayerService.status("Exp");
            ui_bar["ExpBar"].maxValue = PlayerService.nextLevel(lv);
            */

            // HP表示
            string hp_str = PlayerService.statuString("HP");
            string max_hp_str = PlayerService.statuString("MaxHP");
            ui_text["HP"].text = (hp_str + " / " + max_hp_str);

            // HPバー
            //int hp = PlayerService.status("HP");
            //int max_hp = PlayerService.status("MaxHP");
            ui_bar["HPBar"].value = PlayerService.status("HP");
            ui_bar["HPBar"].maxValue = PlayerService.status("MaxHP");

            // *右上*
            // クリアした部屋の数
            ui_text["RoomClear"].text = GameStageService.status("clear_count").ToString();
            // 敵の強さ
            ui_text["EnemyStrength"].text = GameStageService.status("enemy_strength").ToString();
            // 敵数
            ui_text["EnemyNum"].text = GameStageService.status("enemy_num").ToString();

            // *左下*
            int p_atk = PlayerService.status("Atk");
            int p_def = PlayerService.status("Def");
            int p_spd = PlayerService.status("Spd");
            ui_text["PlayerAtk"].text = p_atk.ToString();
            ui_text["PlayerDef"].text = p_def.ToString();
            ui_text["PlayerSpd"].text = p_spd.ToString();

            // *右下*
            int atk = EquipService.status("Atk");
            int def = EquipService.status("Def");
            int spd = EquipService.status("Spd");
            int atk_op = EquipService.status("AtkOp");
            int def_op = EquipService.status("DefOp");
            int spd_op = EquipService.status("SpdOp");

            ui_text["WeaponName"].text = EquipService.weapon_name();
            ui_text["WeaponAtkTotal"].text = (atk + atk_op).ToString();
            ui_text["WeaponDefTotal"].text = (def + def_op).ToString();
            ui_text["WeaponSpdTotal"].text = (spd + spd_op).ToString();
            ui_text["WeaponAtkBaseOp"].text = $"{atk} + {atk_op}";
            ui_text["WeaponDefBaseOp"].text = $"{def} + {def_op}";
            ui_text["WeaponSpdBaseOp"].text = $"{spd} + {spd_op}";
        }
 public static void game_over()
 {
     Observable.Timer(TimeSpan.FromSeconds(5)).Subscribe(x => {
         GameStageService.game_over();
     });
 }