public void Setup(FlockType grpType, SummonSlot slot) { Clear(); if(slot.data != null) { //set group mGroupType = grpType; if(mGroupType != FlockType.NumType) { FlockGroup grp = FlockGroup.GetGroup(mGroupType); if(grp != null) { grp.addCallback += AddUnit; grp.removeCallback += RemoveUnit; } } hotkeyLabel.gameObject.SetActive(true); unitCountLabel.gameObject.SetActive(true); cooldown.gameObject.SetActive(true); //set portrait image based on type string portraitRef = slot.data.type.ToString(); if(portrait.atlas.GetSprite(portraitRef) != null) { portrait.spriteName = portraitRef; portrait.gameObject.SetActive(true); } else { Debug.LogWarning("sprite not found: "+portraitRef); portrait.gameObject.SetActive(false); } //set info cooldown.fillAmount = 0.0f; mSummonType = slot.data.type; mSummonMax = slot.data.summonMax; //setup initial count UpdateUnitCountFromGroup(); //hotkey SetAvailable(true); } else { portrait.gameObject.SetActive(false); hotkeyLabel.gameObject.SetActive(false); unitCountLabel.gameObject.SetActive(false); cooldown.gameObject.SetActive(false); SetAvailable(false); } //if(slot. //data. }
//when changing/deinit public void Clear() { //group if(mGroupType != FlockType.NumType) { FlockGroup grp = FlockGroup.GetGroup(mGroupType); if(grp != null) { grp.addCallback -= AddUnit; grp.removeCallback -= RemoveUnit; } mGroupType = FlockType.NumType; } //other }
public int GetNumSummonable(FlockType flock) { if(data != null) { PlayerGroup grp = (PlayerGroup)FlockGroup.GetGroup(flock); return data.summonMax - grp.GetUnitCountByType(data.type) - numQueueSummon; } return 0; }
//only call this after awake public static FlockGroup GetGroup(FlockType aType) { return mGroups[(int)aType]; }
/// <summary> /// Check given 'other' to see if we should avoid it. /// </summary> public bool CheckAvoid(FlockType other) { return (avoidTypeFilter & (1<<((int)other))) != 0; }
public static int GroupToIndex(FlockType grp) { return ((int)grp) - Player.playerIndOfs; }
public static Player GetPlayer(FlockType grp) { return mPlayers[GroupToIndex(grp)]; }
public static PlayerCursor GetByType(FlockType aType) { PlayerCursor ret = null; mCursors.TryGetValue(aType, out ret); return ret; }