UI/raid/implament/online mode#1640
Conversation
| } | ||
|
|
||
| List<ClanWeightLimit> limits = new(); | ||
| string[] entries = value.Split('|'); |
There was a problem hiding this comment.
Periaatteessahan tästä voisi tehdä omat metodinsa, koska tuo jakajan lisääminenkin on oma metodinsa.
| } | ||
| } | ||
|
|
||
| private static void SetLocalizedText(TextMeshProUGUI textField, string finnishText, string englishText, params string[] additions) |
There was a problem hiding this comment.
Tässähän voisi tehdä sen oletuksen, että se teksti kenttä sisältää nimenomaan tuon TextLanguageSelectorCallerin, jolloin me voidaan antaa se suoraan metodille ja täten ei tarvitse suorittaa tuota muuntamista erikseen.
Jos haluaa mahdollistaa myös käyttämisen ilman tuota Calleria tekstin lisäämisen, niin silloinhan vain oletetaan että sitä Calleria ei ole ja tehdään toinen metodi overload, joka ottaa vastaan tuon tekstikentän.
| { | ||
| if (inventoryHandler == null) | ||
| { | ||
| TryGetComponent(out inventoryHandler); |
There was a problem hiding this comment.
Tässähän voisi siirtää tuon rivin 86 if lausekkeen tähän ja vaihtaa sen konditionaali tällä tryGetComponentilla, koska tämä palauttaa truen, jos se komponentti löytyy. Tällöin ei tarvitse tehdä turhaan erillistä null-tarkistusta.
Sama pätee tuohon raid_LootTracking hakuun.
|
Tuo ryöstön käynnistys ruutu käyttää juuri nyt tuota kivihahmoa klaanin logona, mutta tuo kivihahmo on jo poistettu suunnitelmista ja käytetään vain sitä sydäntä edelleen. |
| float inset = Mathf.Clamp(circumferenceInset, 0f, 0.25f); | ||
| float outerRadius = size * (0.5f - inset); | ||
| float thicknessRatio = Mathf.Clamp(circumferenceThickness, 0.01f, 0.6f); | ||
| float thickness = Mathf.Clamp(size * thicknessRatio, 1f, outerRadius); |
There was a problem hiding this comment.
Eikös tässä ole ihan pienen pieni riski, että outerRadius voisi olla pienempi kuin 1, jolloin tämä ei taida tehdä enää sitä mitä halutaan.
|
|
||
| targetImage = GetComponent<Image>(); | ||
| Transform haloParent = targetRect.parent != null ? targetRect.parent : targetRect; | ||
| GameObject haloObject = new GameObject($"{gameObject.name}_RedHalo", typeof(RectTransform), typeof(LayoutElement)); |
There was a problem hiding this comment.
Eikös tässä olisi helpompi vain tehdä valmis pohja prefabi, joka voidaan vaan instantietaan tähän sen sijaan että se luodaan koodin sisällä.
Poistaisi tarpeen suurimmalle osalle tästä koodista.
| haloImages = new Image[LayerSizeRatios.Length]; | ||
| for (int i = 0; i < LayerSizeRatios.Length; i++) | ||
| { | ||
| GameObject layerObject = new GameObject($"Shadow_{i}", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image)); |
There was a problem hiding this comment.
Sama kuin rivin 155 kommentti.
|
|
||
| haloObject.transform.SetSiblingIndex(targetRect.GetSiblingIndex()); | ||
|
|
||
| haloRects = new RectTransform[LayerSizeRatios.Length]; |
There was a problem hiding this comment.
Eikös tässä myös voisi olla vain yksi lista, joka sisältää luokan, johon sekä tuo rectTransformin ja Imagen tiedot voidaan laittaa yhteen.
| targetRect = transform as RectTransform; | ||
| } | ||
|
|
||
| if (targetImage == null) |
There was a problem hiding this comment.
Tämähän tieto asetetaan paikalleen EnsureHalo metodissa kun objekti pistetään käyttöön, joten tämän ei pitäisi olla koskaan null ja jos se jostain syystä on niin se johtuu siitä että sitä komponentti ei ole. Täten tämä tarkistus ja hakukoodi on todellisuudessa turha.
| } | ||
|
|
||
| float sizeRatio = LayerSizeRatios[layerIndex]; | ||
| haloRect.anchorMin = Vector2.zero; |
There was a problem hiding this comment.
Näistähän voisi kaikki paitsi tuon sizeDeltan poistaa, jos tästä tekisi prefabin kuten ylempänä ehdotin.
There was a problem hiding this comment.
Tämä skriptiä haetaan niin monta kertaa FindObjectOfType kutsulla, että voisiko olla helpompaa vain tehdä tästä singleton ja hakea tätä sitten Instance kutsulla. Säästäisi huomattavasti resursseja verrattuna Findin käyttämiseen verrattuna.
| UpdateHeartLootText(); | ||
| } | ||
|
|
||
| public void ResetLootCount() | ||
| { | ||
| ListOfCollectedLoot = new List<GameFurniture>(); |
There was a problem hiding this comment.
Tarvitseeko tässä luoda uutta listaa vai voisiko vain tyhjentää vanhan listan?
| _ownerMaxWeights.Clear(); | ||
| _ownerCollectedLoot.Clear(); | ||
| _ownerCollectedLootWeights.Clear(); | ||
| _collectedLootWeights.Clear(); |
There was a problem hiding this comment.
Eikös tämä loppu ole sama kuin ResetLootCount metodissa, voisit yhtä hyvin kutsua sen sen sijaan että se on kirjoitettuna kahteen kertaan.
| if (ownerId == _displayedOwnerId) | ||
| { | ||
| RefreshDisplayedOwnerValues(); | ||
| } | ||
| } | ||
|
|
||
| public void SetLootCount(GameFurniture furniture, float MaxLootWeight, float lootWeightMultiplier = 1f) |
There was a problem hiding this comment.
Tämä MaxLootWeight:hän on sama kuin tässä skriptissä oleva MaxLootWeight. Tarvitseeko sitä antaa ulkopuolelta?
| float AddedLootWeight = (float)furniture.Weight * lootWeightMultiplier; | ||
| ListOfCollectedLoot.Add(furniture); | ||
| _collectedLootWeights.Add(AddedLootWeight); | ||
|
|
||
| float NewLootWeight = CurrentLootWeight + AddedLootWeight; |
There was a problem hiding this comment.
Eikös nämä kaksi riviä voisi yhdistää?
| return configuredMaxWeight; | ||
| } | ||
|
|
||
| if (fallbackMaxWeight > 0f) |
There was a problem hiding this comment.
Tarvitseeko tätä fallbackiä tässä vai voisiko tuo MaxLootWeight arvo olla se fallback?
| public event Action CollectedLootChanged; | ||
|
|
||
| private readonly List<float> _collectedLootWeights = new(); | ||
| private readonly Dictionary<string, float> _ownerCurrentWeights = new(); |
There was a problem hiding this comment.
Käytetäänkö näitä dictionareja oikeasti mihinkään, koska näyttäisi että ainoa arvo mitä oikeasti luetaan on pelaajan oma arvo?
| ResolveLootTracker(); | ||
| if (raid_LootTracking != null) | ||
| { | ||
| raid_LootTracking.CollectedLootChanged -= OnCollectedLootChanged; |
There was a problem hiding this comment.
Tarvitseeko tätä kytköksen erottamista kutsua jos sitä kytköstä ei pitäisi muutenkaan vielä olla olemassa.
| using UnityEngine; | ||
| using UnityEngine.UI; | ||
|
|
||
| public class HeartScript : MonoBehaviour | ||
| { | ||
| private static readonly Vector2 LossHaloPadding = new Vector2(200f, 200f); | ||
| private static readonly Vector2 LossHaloOffset = Vector2.zero; | ||
|
|
||
| public Raid_LootTracking raid_LootTracking; |
There was a problem hiding this comment.
Tämän tuskin tarvitsee olla julkinen.
| private void Awake() | ||
| { | ||
| ResolveLootTracker(); | ||
| ResolveRecentLootImages(); |
There was a problem hiding this comment.
Tämä on myös UpdateRecentLootImages metodin sisällä, joka kutsutaan tuossa seuraavana, joten tätä ei tarvitse kutsua tässä.
Summary
Implements the online Raid matchmaking flow and updates the Raid UI/prefab setup around it.
Changes
EmptySlot,FurnitureSlot, andGraphicsChanger.