Esempio n. 1
0
    /// <summary>
    /// 执行技能
    /// </summary>
    /// <param name="skill"></param>
    /// <param name="targetID"></param>
    private void DoSkill(ClientSkill skill, int targetID, Vector3 position)
    {
        proto.UseSkill useSkill = new proto.UseSkill();
        useSkill.skillid    = skill.ID;
        useSkill.unitid     = this.ID;
        useSkill.partid     = skill.ControlPart.Id;
        useSkill.skillstage = Def.SkillStage.Casting;
        useSkill.posx       = (int)(position.x * 10000);
        useSkill.posy       = (int)(position.y * 10000);
        useSkill.posz       = (int)(position.z * 10000);
        FightMessageCache.Instance.AddMessage(useSkill);

        var targetList = TargetSelector.FindSkillTarget(this, skill, targetID, position);

        for (int i = 0; i < targetList.Count; ++i)
        {
            ShipEntity         target   = targetList[i];
            proto.PartFireInfo fireInfo = new proto.PartFireInfo();
            fireInfo.targetid   = target.ID;
            fireInfo.delayframe = skill.Prop.continued_time;
            if (skill.Prop.missle_vel > 0)
            {
                float distance = Vector3.Distance(this.Ship.Position, target.Ship.Position);
                fireInfo.delayframe = Mathf.CeilToInt(distance / (skill.Prop.missle_vel * FightServiceDef.SPEED_SCALAR));
            }
            useSkill.add_fireinfolist(fireInfo);

            // 给目标发一条被技能打击的消息
            MessageDispatcher.Instance.DispatchMessage(TelegramType.UnderSkillAttack, this.ID, target.ID, fireInfo.delayframe, skill.Prop.effect_val, skill.Prop.skill_effect_type);
        }
    }
Esempio n. 2
0
    private proto.PartFireInfo PartFire(ClientParts part, ShipEntity target)
    {
        proto.PartFireInfo fireInfo = new proto.PartFireInfo();
        fireInfo.targetid = target.ID;

        if (part.Reference.missle_vel > 0)
        {
            float distance   = Vector3.Distance(this.Ship.Position, target.Ship.Position);
            int   delayFrame = Mathf.CeilToInt(distance / (part.Reference.missle_vel * FightServiceDef.SPEED_SCALAR));
            fireInfo.delayframe = delayFrame;
        }
        else
        {
            int delayFrame = Mathf.CeilToInt(part.Reference.continued_time / FightServiceDef.FRAME_INTERVAL_TIME);
            fireInfo.delayframe = delayFrame;
        }

        int baseAtk = GetBaseAtkValue(part, target);

        if (Ship.Reference.stack)
        {
            baseAtk *= StackAliveNum_;
        }
        MessageDispatcher.Instance.DispatchMessage(TelegramType.UnderAttack, this.ID, target.ID, fireInfo.delayframe, baseAtk, part.Reference.effect_type);

        return(fireInfo);
    }
Esempio n. 3
0
 /// <summary>
 /// 部件开火
 /// </summary>
 /// <param name="fireEvent"></param>
 /// <param name="part"></param>
 private void CastPartFire(proto.PartFireEvent fireEvent, Part part)
 {
     ShowCast(part);
     // 范围攻击,只生成一个子弹
     if (part.partType == SpellType.AOE)
     {
         List <BulletTarget> targetList = new List <BulletTarget>();
         for (int i = 0; i < fireEvent.fireinfo_size(); i++)
         {
             proto.PartFireInfo info   = fireEvent.fireinfo(i);
             TeamDisplay        target = BattleSceneDisplayManager.Instance.GetTeamDisplay(info.targetid);
             if (target == null)
             {
                 continue;
             }
             BulletTarget bulletTarget = new BulletTarget();
             bulletTarget.delayFrame = info.delayframe;
             bulletTarget.Target     = target;
             targetList.Add(bulletTarget);
         }
         ClientParts parts = Team_.GetPartsByID(part.partID);
         ShowBullet(parts, targetList, part.partType, part.attackPoint, part.bulletPath, part.hitEffect, Vector3.zero);
         return;
     }
     // 个体攻击,每个对象都生成子弹
     for (int i = 0; i < fireEvent.fireinfo_size(); i++)
     {
         proto.PartFireInfo info   = fireEvent.fireinfo(i);
         TeamDisplay        target = BattleSceneDisplayManager.Instance.GetTeamDisplay(info.targetid);
         if (target == null)
         {
             continue;
         }
         List <BulletTarget> targetList   = new List <BulletTarget>();
         BulletTarget        bulletTarget = new BulletTarget();
         bulletTarget.delayFrame = info.delayframe;
         bulletTarget.Target     = target;
         targetList.Add(bulletTarget);
         ClientParts parts = Team_.GetPartsByID(part.partID);
         ShowBullet(parts, targetList, part.partType, part.attackPoint, part.bulletPath, part.hitEffect, Vector3.zero);
     }
 }
Esempio n. 4
0
    private IEnumerator CastSkill(proto.UseSkill useSkill)
    {
        Skill skill = GetSkill(useSkill.partid);

        if (skill == null)
        {
            Debug.Log("skill is null");
            yield break;
        }
        ShowCast(skill);
        ClientSkill clientSkill = BattleSys.GetCommanderShip().GetSkillById(useSkill.skillid);

        // 范围攻击,只生成一个子弹
        if (skill.partType == SpellType.AOE)
        {
            List <BulletTarget> targetList = new List <BulletTarget>();
            for (int i = 0; i < useSkill.fireinfolist_size(); i++)
            {
                proto.PartFireInfo info   = useSkill.fireinfolist(i);
                TeamDisplay        target = BattleSceneDisplayManager.Instance.GetTeamDisplay(info.targetid);
                if (target == null)
                {
                    continue;
                }
                BulletTarget bulletTarget = new BulletTarget();
                bulletTarget.delayFrame = info.delayframe;
                bulletTarget.Target     = target;
                targetList.Add(bulletTarget);
            }
            ClientParts parts    = Team_.GetPartsByID(skill.partID);
            float       x        = (float)useSkill.posx / 10000f;
            float       y        = (float)useSkill.posy / 10000f;
            float       z        = (float)useSkill.posz / 10000f;
            Vector3     position = new Vector3(x, y, z);
            ShowBullet(parts, targetList, skill.partType, skill.attackPoint, skill.bulletPath, skill.hitEffect, position, clientSkill);
        }
        // 个体攻击,每个对象都生成子弹
        else
        {
            for (int i = 0; i < useSkill.fireinfolist_size(); i++)
            {
                proto.PartFireInfo info   = useSkill.fireinfolist(i);
                TeamDisplay        target = BattleSceneDisplayManager.Instance.GetTeamDisplay(info.targetid);
                if (target == null)
                {
                    continue;
                }
                List <BulletTarget> targetList   = new List <BulletTarget>();
                BulletTarget        bulletTarget = new BulletTarget();
                bulletTarget.delayFrame = info.delayframe;
                bulletTarget.Target     = target;
                targetList.Add(bulletTarget);
                ClientParts parts = Team_.GetPartsByID(skill.partID);
                ShowBullet(parts, targetList, skill.partType, skill.attackPoint, skill.bulletPath, skill.hitEffect, Vector3.zero, clientSkill);
            }
        }
        yield return(new WaitForSeconds(1.2f));

        for (int i = 0; i < SingEffectList_.Count; i++)
        {
            if (SingEffectList_[i] == null)
            {
                continue;
            }
            Destroy(SingEffectList_[i]);
        }
        SingEffectList_.Clear();
    }