void Start () { if (component != null) score = component.score_data; if (win == null) win = GameSettingsComponent.working_rules.win_condition; if (id_text != null || id_text_3d != null){ rx_id_text = LanguageController.controller.rx_load_text("basket_single") .CombineLatest(rx_score.SelectMany(rx_score.SelectMany(s=>s.rx_id)), (text, id)=>{ return text+" #"+id.ToString(); }).ToReadOnlyReactiveProperty<string>(); rx_id_text.Subscribe((text)=>{ if (id_text != null) id_text.text = text; if (id_text_3d != null) id_text_3d.text = text; }); } if (count != null || count_3d != null){ rx_count_text = rx_score .SelectMany(s=>s.rx_count) .Select(value=>value.ToString()) .ToReadOnlyReactiveProperty<string>(); rx_count_text.Subscribe((text)=>{ if (count != null) count.text = text; if (count_3d != null) count_3d.text = text; }); } if (weight != null || weight_3d != null){ rx_weight_text = rx_score .SelectMany(s=>s.rx_weight) .Select(value=>value.ToString("0.00")) .ToReadOnlyReactiveProperty<string>(); rx_weight_text.Subscribe((text)=>{ if (weight != null) weight.text = text; if (weight_3d != null) weight_3d.text = text; }); } condition = rx_score.SelectMany(s=>{ return s.rx_weight.CombineLatest(s.rx_overflow, (w,overflow)=>{ return new UniRx.Tuple<float,bool>(w,overflow); }); }).CombineLatest (rx_win, (tuple, wc) => { float w = tuple.Item1; bool overflow = tuple.Item2; if (overflow){ return BasketCondition.Overflow; } if (wc.basket_weight.is_accept(w)){ return BasketCondition.Accepted; } else { if (wc.basket_weight.is_over(w)){ return BasketCondition.Overweight; } else { return BasketCondition.Underweight; } } }).ToReadOnlyReactiveProperty<BasketCondition>(); rx_with_win = rx_score.CombineLatest(rx_win, (s, w)=>{ return new UniRx.Tuple<BasketSingleScore, GameSettings.WinCondition>(s,w); }); rx_with_win.Subscribe((tuple)=>{ if (flat_score_text != null){ ScoreDetailedForm.format_score_text(flat_score_text, tuple.Item2.evaluate_basket_flat(tuple.Item1)); } if (range_score_text != null){ ScoreDetailedForm.format_score_text(range_score_text, tuple.Item2.evaluate_basket_range(tuple.Item1)); } if (total_score_text != null){ ScoreDetailedForm.format_score_text(total_score_text, tuple.Item2.evaluate_basket(tuple.Item1)); } }); rx_tooltip_text = condition.Select(c=>language_keys[c]).ToReadOnlyReactiveProperty<string>(); rx_tooltip_text.Subscribe((key)=>{ if (tooltip != null){ tooltip.key = key; } }); rx_sprite = condition.Select(c=>sprites[c]).ToReadOnlyReactiveProperty<Sprite>(); rx_sprite.Subscribe ((sprite) => { if (icon != null) icon.sprite = sprite; if (icon_3d != null) icon_3d.sprite = sprite; }); if (opacity != null){ opacity.opacity = off_opacity; } }
public BasketIcon chain_win(GameSettings.WinCondition _win){ win = _win; return this; }