EasyScan
Tutorials
|
|
|
Customize factions and classifications
There are a number of enum categories that may be easily customized for your project. Faction names are found in MF_EasyScan_UnitList: FactionType { Editor, Side1, Side2 } Change and add as many as you would like. Classification categories are found within MF_EasyScan: Class1 { Unknown, Tiny, Small, Medium, Large, Huge } Class2 { Unknown, Weak, Normal, Elite, Boss } Role1 { Unknown, Tank, Support, Carrier, DPS, Heal } Role2 { Unknown, Short, Medium, Long } These entries are merely suggestions. If you were making an RPG, for example, you might consider something along the lines of: Class1 { Unknown, Thief, Mage, Priest, Warrior } Using interfaces with unit stats
To use EasyScan with unit stats such as health, and other metrics, you'll want to set up your existing stat scripts to use an interface. EasyScany comes built in with interfaces for: Health, Shields, Armor, Energy, CustomStat, and a meta group representing some combination of the total: TotalStrength To use a particular stat, that script needs to implement the appropriate interface methods that can be referenced by MF_EasyScan for targeting preferences. IGetShield GetShield : float (), GetShieldMax : float () IGetArmor GetArmor : float (), GetArmorMax : float () IGetHealth GetHealth : float (), GetHealthMax : float () IGetEnergy GetEnergy : float (), GetEnergyMax: float () IGetThreat GetThreat : float (), GetThreatMax: float () IGetTotalStrength -> GetTotalStrength : float (), GetTotalStrengthMax : float () IGetCustomStat -> GetCustomStat : float (), GetCustomStatMax: float () TotalStrength is intended to be a way to return a value combining any or all other stats, but implementation is ultimately up to your individual scripts. Sample code to implement IGetHealth on your script. using UnityEngine; using MobFarm; public class YourUnitClass : MonoBehaviour, IGetHealth, { // your health variables - use any name public float health; public float healthMax; public float GetHealth () { return health; } public float GetHealthMax () { return healthMax; } } |
Adding custom stats
To add a custom stat you'll need to edit the MF_EasyScan_Targeting script - if you're comfortable doing so. Warning - Updates to EasyScan will overwrite any changes you make, so be sure to save a back-up. There are several places to change, but they've been organized to be as easy as possible. Within the script, search for "CustomizeStats" and this will take you to all the places to change or add on to. One spot is in the middle, the rest are at the bottom. Additionally, you can optionally make a tweak in MF_FilterItem_Drawer to add it to the list of filters to nicely shrink the value fields when dealing with % comparisons. Search for "CustomizeStats" here as well. See the commented sections of code. Change CustomStat or add new ones based on the same format. Using interface IScanEvents
If you want EasyScan to send ScanEvents to other scripts, you can use use an interface. You'll first need to set up your script to handle sent events, then add it to the list of items to send events to. Set up your class to inherit the interface: public class MyScript : Monobehaviour, IScanEvents Then implement the ScanEvent() method: public void ScanEvent ( ScanEventType eventType, MF_EasyScan target ) { } In this method you can check for any or all particular events of ScanEventType: enum ScanEventType { ScanPulse, NewEnemyScan, NewNeutralScan, NewAllyScan, NewUnknownScan, NewTarget, LostTarget } Additinally, the current target is passed as well. ScanPulse: Sends this event every time the scanner updates according to the scanInterval. target will return null. NewEnemyScan: Sent if a newely detected unit is an enemy. NewNeutralScan: If a newely detected unit is neutral. NewAllyScan: If a newely detected unit is an ally. NewUnknownScan: If a newely detected unit is of an unknown relation. NewTarget: Sends this event every time a new target is selected. LostTarget: Sent upon loosing a target that is not replaced. target will return null. For example, to have some action every time a new target is chosen: public void ScanEvent ( eventType, target ) { if ( eventType == ScanEventType.NewTarget ) { // do a thing here } } Finally, in the inspector of the object with an MF_EasyScan script, drag and drop the object with the script inheriting IScanEvents into the list of Event Targets. Upon Awake() the script will assign these items as places to send ScanEvents. Alternately, you can use: AddEventTarget ( eventTarget ) RemoveEventTarget ( eventTarget ) to add or remove an object during runtime. |