public static void Cast(this UnitSkillComponent self, string keycode) { RayUnitComponent ray = self.GetParent <Unit>().GetComponent <RayUnitComponent>(); AttackComponent attack = self.GetParent <Unit>().GetComponent <AttackComponent>(); self.currentKey = keycode; self.keycodeIds.TryGetValue(self.currentKey, out long skid); if (skid == 0) { skid = 41101; } Skill skill = Game.Scene.GetComponent <SkillComponent>().Get(skid); self.curSkillItem = ComponentFactory.CreateWithId <SkillItem>(skid); self.curSkillItem.UpdateLevel(10); if (ray.target != null) { attack.target = ray.target; } if (attack.target != null) { attack.target.GetComponent <AttackComponent>().TakeDamage(self.curSkillItem); } }
public void Init(UnitConfigData data) { Data = data; mAttributes [(int)FighterAttributeType.Life] = data.life; mAttributes [(int)FighterAttributeType.Speed] = data.speed; mAttributes [(int)FighterAttributeType.Attack] = data.attack; mAttributes [(int)FighterAttributeType.AttackRange] = data.attackRange; Position = Data.borthPos; ID = Data.id; IsDead = false; mAI = new UnitAIComponent(this); mAI.Init(); skillComp = new UnitSkillComponent(this); skillComp.Init((data.skillList)); moveComp = new UnitMoveComponent(); moveComp.Init(this); buffComp = new UnitBuffComponent(this); }