public CharacterUi(CharAvatar charAvatarControl, CharIcon charIconControl) { CharAvatarControl = charAvatarControl; CharIconControl = charIconControl; CharAvatarControl.HitBox.MouseEnter += HitBoxOnMouseEnter; CharAvatarControl.HitBox.MouseLeave += HitBoxOnMouseLeave; CharAvatarControl.HitBox.MouseDown += HitBox_MouseDown; _scalingType = ScaleType.NoScaling; }
// El método DeployRegiment crea una instancia del héroe en el campo de batalla public static void DeployRegiment(BattleHex parentObject) // el héroe aparece en parentObject { Hero regiment = readyForDeploymentIcon.charAttributes.heroSO; // obtiene el héroe prefabricado Hero fighter = Instantiate(regiment, parentObject.Landscape.transform); // crea una instancia del héroe y fighter.GetComponent <Move>().ManageSortingLayer(parentObject); parentObject.CleanUpDeploymentPosition(); // oculta la marca de verificación y deshabilita el colisionador readyForDeploymentIcon.HeroIsDeployed(); // marca el icono en gris readyForDeploymentIcon = null; // borra una variable para evitar que el héroe reaparezca storage.GetComponent <StartBTN>().ControlStartBTN(); // habilita el botón de inicio }
//DeployRegiment method instantiates the hero on the battlefield public static void DeployRegiment(BattleHex parentObject) //hero appears on parentObject { Hero regiment = readyForDeploymentIcon.charAttributes.heroSO; // gets the hero prefab Hero fighter = Instantiate(regiment, parentObject.Landscape.transform); //instantiates the hero and fighter.GetComponent <Move>().ManageSortingLayer(parentObject); //returns a hero object parentObject.CleanUpDeploymentPosition(); //hides the checkmark and disables the collider readyForDeploymentIcon.HeroIsDeployed(); //marks the icon in gray readyForDeploymentIcon = null; //clears a variable to prevent the hero from reappearing storage.GetComponent <StartBTN>().ControlStartBTN(); //enables the start button }
internal void TintIcon(CharIcon clickedIcon) //marks a regiment to be placed on the battlefield { CharIcon[] charIcons = GetComponentsInChildren <CharIcon>(); //collects all icons foreach (CharIcon icon in charIcons) { if (!icon.charAttributes.isDeployed) { icon.backGround.sprite = defaultIcon;//sets default background to the icon } } clickedIcon.backGround.sprite = selectedIcon; //sets green background to the icon Deployer.readyForDeploymentIcon = clickedIcon; //Saves the selected icon in memory }
private void CallHeroIcons() //places heroes icons in storage { regimentIcons = currentProgress.heroesOfPlayer; //access to player's regiments Transform parentOfIcons = scrollRect.content.transform; //defines the parent object for all icons for (int i = 0; i < regimentIcons.Count; i++) { CharIcon fighterIcon = Instantiate(iconPrefab, parentOfIcons); //instantiate and return an icon fighterIcon.charAttributes = regimentIcons[i]; //assigns scriptable object to an icon fighterIcon.FillIcon(); //fills the icon with a sprite and the number of units. //data taken from scriptable object } }
internal void TintIcon(CharIcon clickedIcon) // marca un regimiento para colocarlo en el campo de batalla { CharIcon[] charIcons = GetComponentsInChildren <CharIcon>(); // recopila todos los iconos foreach (CharIcon icon in charIcons) { if (!icon.charAttributes.isDeployed) { icon.backGround.sprite = defaultIcon;// establece el fondo predeterminado del icono } } clickedIcon.backGround.sprite = selectedIcon; // establece un fondo verde para el icono Deployer.readyForDeploymentIcon = clickedIcon; // Guarda el icono seleccionado en la memoria }
private void CallHeroIcons() // coloca los iconos de los héroes en el almacenamiento { regimentIcons = currentProgress.heroesOfPlayer; // acceso a los regimientos del jugador Transform parentOfIcons = scrollRect.content.transform; // define el objeto padre para todos los iconos for (int i = 0; i < regimentIcons.Count; i++) { CharIcon fighterIcon = Instantiate(iconPrefab, parentOfIcons); // crear una instancia y devolver un icono fighterIcon.charAttributes = regimentIcons[i]; // asigna un objeto programable a un icono fighterIcon.FillIcon(); // llena el icono con un sprite y el número de unidades. // datos tomados de un objeto programable } }
//instantiates all icons of heroes who participated in the battle public void CallHeroIcons() //places heroes icons in storage { regimentsSO = currentProgress.heroesOfPlayer; //access to player's regiments Transform parentOfIcons = scrollRect.content.transform; //defines the parent object for all icons for (int i = 0; i < regimentsSO.Count; i++) { if (regimentsSO[i].isDeployed) { CharIcon fighterIcon = Instantiate(iconPrefab, parentOfIcons); //instantiate and return an icon fighterIcon.FillIconWhenGameIsOver(regimentsSO[i]); //fills the icon with //data taken from scriptable object } } }
// crea una instancia de todos los íconos de los héroes que participaron en la batalla public void CallHeroIcons() // coloca los iconos de los héroes en el almacenamiento { regimentsSO = currentProgress.heroesOfPlayer; // acceso a los regimientos del jugador Transform parentOfIcons = scrollRect.content.transform; // define el objeto padre para todos los iconos for (int i = 0; i < regimentsSO.Count; i++) { if (regimentsSO[i].isDeployed) { CharIcon fighterIcon = Instantiate(iconPrefab, parentOfIcons); // crear una instancia y devolver un icono fighterIcon.FillIconWhenGameIsOver(regimentsSO[i]); // llena el icono con // datos tomados de un objeto programable } } }