Simplify OnParticipantSpriteClicked setup

This commit is contained in:
henriquenakashima 2020-09-18 23:51:44 -04:00
parent d8af43db53
commit ee8d66610e
2 changed files with 9 additions and 9 deletions

View file

@ -35,9 +35,8 @@ public class BattleController : MonoBehaviour
heroSprites[i].name = "Hero" + i + "_Sprite";
heroSprites[i].transform.position = new Vector3(-6 + 6 * i, 0, 0);
BattleParticipantSprite bps = heroSprites[i].AddComponent<BattleParticipantSprite>();
bps.Init(battlePlayerControls);
BattleParticipant participant = heroes[i];
bps.OnSpriteClicked += delegate() {battlePlayerControls.OnParticipantSpriteClicked(participant);};
bps.Init(battlePlayerControls, heroes[i]);
bps.OnSpriteClicked += battlePlayerControls.OnParticipantSpriteClicked;
heroUIs[i] = (HeroInfoUI) Instantiate(heroUIPrefab.gameObject, uiCanvas.transform).GetComponent(typeof(HeroInfoUI));
heroUIs[i].Init(heroSprites[i], heroes[i]);
@ -56,9 +55,8 @@ public class BattleController : MonoBehaviour
monsterSprites[i].name = "Monster" + i + "_Sprite";
monsterSprites[i].transform.position = new Vector3(-6 + 6 * i, 3, 0);
BattleParticipantSprite bps = monsterSprites[i].AddComponent<BattleParticipantSprite>();
bps.Init(battlePlayerControls);
BattleParticipant participant = monsters[i];
bps.OnSpriteClicked += delegate() {battlePlayerControls.OnParticipantSpriteClicked(participant);};
bps.Init(battlePlayerControls, monsters[i]);
bps.OnSpriteClicked += battlePlayerControls.OnParticipantSpriteClicked;
monsterUIs[i] = (HeroInfoUI) Instantiate(heroUIPrefab.gameObject, uiCanvas.transform).GetComponent(typeof(HeroInfoUI));
monsterUIs[i].Init(monsterSprites[i], monsters[i]);