Beispiel #1
0
 protected override void OnExecute(InteractiveObj self, InteractiveObj target)
 {
     if (target.IsEnemy(self.Camp))
     {
         target.Camp = self.Camp;
         SceneObjHeadInfo info = target.UIHeadInfo;
         if (info)
         {
             if (self.Camp == Common.MyselfCamp)
             {
                 info.txtBlood.color = Color.green;
                 info.sldBlood.fillRect.GetComponent <UnityEngine.UI.Graphic>().color = Color.green;
                 DrawAttackRange draw = target.GetComponent <DrawAttackRange>();
                 if (draw)
                 {
                     draw.bNeedUpdate = false;
                 }
                 LineRenderer line = target.GetComponent <LineRenderer>();
                 if (line)
                 {
                     line.enabled = false;
                 }
             }
             else
             {
                 info.txtBlood.color = Color.red;
                 info.sldBlood.fillRect.GetComponent <UnityEngine.UI.Graphic>().color = Color.red;
             }
         }
         self.DoDamage(new Damage(WorldSetting.Effect.Dark, 5), WorldInteractObj.Instance);
     }
 }
Beispiel #2
0
 private void InitBloodUI()
 {
     if (!tsfBloodUIPoint)
     {
         tsfBloodUIPoint = new GameObject("BloodPoint").transform;
         tsfBloodUIPoint.SetParent(transform, false);
         Vector3 vecCenter = ColliderSelf.bounds.center;
         vecCenter.y = ColliderSelf.bounds.max.y + 0.3f;
         tsfBloodUIPoint.position = vecCenter;
     }
     if (!prefabBloodUI)
     {
         prefabBloodUI = Resources.Load <GameObject>("GUI/SceneUI/SceneObjHeadInfo");
     }
     if (!prefabBloodUI)
     {
         Debug.LogError("加载血条资源GUI/SceneUI/SceneObjHeadInfo失败!");
         return;
     }
     UIHeadInfo = Instantiate(prefabBloodUI).GetComponent <SceneObjHeadInfo>();
     UIHeadInfo.Init(this);
 }