public void InstantiateHudObjects(Canvas canvas, Weapon weapon, SkillPanel skillPanel) { _hpBar = Instantiate(_hpBar) as Bar; _hpBar.transform.SetParent(canvas.transform, false); _expBar = Instantiate(_expBar) as Bar; _expBar.transform.SetParent(canvas.transform, false); _lvPanel = Instantiate(_lvPanel) as LevelPanel; _lvPanel.transform.SetParent(canvas.transform, false); skillPanel = Instantiate(skillPanel) as SkillPanel; skillPanel.transform.SetParent(canvas.transform, false); RegisterWeapon(weapon, skillPanel); }
private void RegisterWeapon(Weapon weapon, SkillPanel skillPanel) { if (weapon is Fist && skillPanel is PandaSkillPanel) { var fist = (Fist)weapon; var pandaSkillPanel = (PandaSkillPanel)skillPanel; pandaSkillPanel.Register(fist); } else if (weapon is Hammer && skillPanel is WarriorSkillPanel) { var hammer = (Hammer)weapon; var warriorSkillPanel = (WarriorSkillPanel)skillPanel; warriorSkillPanel.Register(hammer); } else { skillPanel.Register(weapon); } }