Exemple #1
0
    private void Awake()
    {
        current_scene_index = Scenes.CurrentSceneIndex();

        #region GameEventSystem
        GameEventSystem.Nullify();
        #endregion GameEventSystem

        #region FightData
        FightData.Nullify();

        Debug.Assert(fight_data_win_count > 0);
        Debug.Assert(fight_data_round_duration > 0);
        Debug.Assert(fight_data_fighter_hp > 0);

        FightData.fighter_hp               = fight_data_fighter_hp;
        FightData.win_count                = fight_data_win_count;
        FightData.round_duration           = fight_data_round_duration;
        FightData.current_round            = 0;
        FightData.delay_before_first_round = delay_before_first_round;
        FightData.delay_after_last_round   = delay_after_last_round;
        FightData.delay_before_round_start = delay_before_round_start;
        FightData.delay_after_round_end    = delay_after_round_end;
        FightData.delay_between_rounds     = delay_between_rounds;

        Debug.Assert(spawn_points.Length > 0);

        Transform random_spawn_point = RandomSpawnPoint();
        float     half_distance      = distance_between_fighters / 2;

        switch (game_mode)
        {
        case GameMode.AIFight:
            fighter1_type = FighterType.Enemy;
            fighter2_type = FighterType.Enemy;
            break;

        case GameMode.Arcade:
            fighter1_type = FighterType.Player;
            fighter2_type = FighterType.Enemy;
            break;

        case GameMode.Versus:
            fighter1_type = FighterType.Player;
            fighter2_type = FighterType.Player;
            break;

        default:
            goto case GameMode.Arcade;
        }

        InstantiateFighter(true, fighter1_prefab, ref FightData.fighter1, fighter1_type, random_spawn_point, half_distance);
        InstantiateFighter(false, fighter2_prefab, ref FightData.fighter2, fighter2_type, random_spawn_point, half_distance);
        #endregion FightData

        #region Singletones
        #region HUD
        Debug.Assert(hud_prefab != null);
        Singletones.hud = Instantiate(hud_prefab).GetComponent <HUD>();
        Debug.Assert(Singletones.hud != null);
        #endregion HUD

        #region EventSystem
        Debug.Assert(event_system_prefab != null);
        Singletones.event_system = FindObjectOfType <EventSystem>();

        if (Singletones.event_system == null)
        {
            Singletones.event_system = Instantiate(event_system_prefab).GetComponent <EventSystem>();
        }

        Debug.Assert(Singletones.event_system != null);
        #endregion EventSystem

        #region MainCamera
        Singletones.main_camera = FindObjectOfType <MainCamera>();
        Debug.Assert(Singletones.main_camera != null);
        #endregion MainCamera

        #region FightEvents
        Debug.Assert(fight_events_prefab != null);
        Instantiate(fight_events_prefab);
        #endregion FightEvents
        #endregion Singletones
    }