/** AttributeDisplayable public void Method * @Params : IDisplayable * This public method should only be called by the Champion script so far. * In this method, we attribute to the Gui the correct autoAttack. * Then, we try to locate a Sprite associated to the autoAttack in the Image Folder associated to the Champion. **/ public void AttributeDisplayable(IDisplayable displayable) { _autoAttackBase = (AutoAttackBase)displayable; Image autoAttackBaseImage = GetComponent <Image>(); autoAttackBaseImage.sprite = Resources.Load <Sprite>("Images/AutoAttacks/" + _autoAttackBase.GetComponent <Champion>().GetType().ToString() + "/" + _autoAttackBase.GetType()); if (autoAttackBaseImage.sprite == null) { autoAttackBaseImage.sprite = Resources.Load <Sprite>("Images/Spells/DefaultSpell"); } }
/** AttributeAutoAttackToClass protected virtual void Method. * This method is called by the Start method. The Objective of the method is to get the AutoAttack spell name in the championData instance. * Then, it get the script in the scripts library and attach it to the player. * If the script is not found or mispelled, the HandleException(2) is launched. * After that, we call the AttributeDisplayable method to give to the GUI all information in requires to display informations about the AutoAttack. **/ protected virtual void AttributeAutoAttackToClass() { Type t = Type.GetType(championData.AutoAttack); if (t == null) { HandleException(2); return; } autoAttack = (AutoAttackBase)gameObject.AddComponent(t); GUIAutoAttackDisplayer autoAttackDisplayer = GameObject.Find("AutoAttack").GetComponent <GUIAutoAttackDisplayer>(); autoAttackDisplayer.AttributeDisplayable(autoAttack); }