// PRAGMA MARK - Public Interface public void Init(BattlePlayerSkin skin) { skin_ = skin; thumbnailImage_.sprite = skin_.ThumbnailSprite; StateSkinCustomization.OnSelectedSkinsDirty += RefreshSelected; RefreshSelected(); }
// PRAGMA MARK - Static Public Interface public static BattlePlayerSkin GetBestRandomSkin() { BattlePlayerSkin[] skins = GameConstants.Instance.PlayerSkins; BattlePlayerSkin chosenSkin = skins.Random(); // NOTE (darren): could do a better random here.. while (SkinAlreadyInUse(chosenSkin) && !skins.All(SkinAlreadyInUse)) { chosenSkin = skins.Random(); } return(chosenSkin); }
private void HandleSelectableSelected(ISelectable selectable) { BattlePlayerSkin skin = (selectable as SkinSelectable).Skin; // if any player has already selected this skin, we cannot select it // if all skins are selected then we ignore this check if (IsSkinSelected(skin) && !GameConstants.Instance.PlayerSkins.All(s => IsSkinSelected(s))) { AudioConstants.Instance.Negative.PlaySFX(); return; } Player_.Skin = skin; MoveToNextState(); }
// PRAGMA MARK - Static Internal private static bool SkinAlreadyInUse(BattlePlayerSkin skin) { return(RegisteredPlayers.AllPlayers.Any(p => p.Skin == skin)); }
public static bool IsSkinSelected(BattlePlayerSkin skin) { return(RegisteredPlayers.AllPlayers.Where(p => IsPlayerNotSelectingSkin(p)).Any(p => p.Skin == skin)); }