Exemplo n.º 1
0
    /// <summary>
    /// 协程 战斗
    /// </summary>
    /// <returns></returns>
    private IEnumerator CoroutineForCommandFight()
    {
        NpcAIMiniGameCombatCpt actionNpc = miniGameData.GetRoundActionCharacter();
        NpcAIMiniGameCombatCpt targetNpc = miniGameData.GetRoundTargetCharacter();

        //获取属性
        actionNpc.characterData.GetAttributes(actionNpc.characterMiniGameData, out CharacterAttributesBean actionCharacterAttributes);

        //让行动角色移动到被攻击对象面前
        Vector3 offsetPosition;

        //根据角色朝向决定位置
        if (targetNpc.GetCharacterFace() == 1)
        {
            offsetPosition = new Vector3(-1, 0);
        }
        else
        {
            offsetPosition = new Vector3(1, 0);
        }
        //记录之前的位置
        Vector3 oldPosition = actionNpc.transform.position;

        //行动角色移动到目标角色面前
        actionNpc.transform.DOMove(targetNpc.transform.position + offsetPosition, 0.5f);
        yield return(new WaitForSeconds(0.5f));

        //TODO 计算闪避(待定)
        float dodgeRate = UnityEngine.Random.Range(0f, 1f);

        if (dodgeRate <= 1)
        {
            //力量测试加成
            float damagePowerRate = (miniGameData.GetRoundActionPowerTest() + 0.2f);
            //计算伤害
            int damage = (int)(damagePowerRate * actionCharacterAttributes.force);
            //伤害减免
            damage = targetNpc.characterMiniGameData.GetTotalDef(damage);
            //角色伤害
            targetNpc.UnderAttack(damagePowerRate, damage);
            AudioHandler.Instance.PlaySound(AudioSoundEnum.Fight);
        }
        else
        {
            //角色闪避了
            targetNpc.ShowTextInfo(TextHandler.Instance.manager.GetTextById(14001), Color.blue);
        }
        //行动角色回到自己的位置
        yield return(new WaitForSeconds(0.5f));

        actionNpc.transform.DOMove(oldPosition, 0.5f);
    }
Exemplo n.º 2
0
    public void CompleteEffect(MiniGameCharacterForCombatBean miniGameCharacter)
    {
        //回复生命处理
        int addLife = EffectTypeEnumTools.GetTotalLife(targetCharacter.characterData, listEffectTypeData);

        if (addLife > 0)
        {
            //显示增加的血量
            targetCharacter.ShowTextInfo("+" + addLife, Color.green);
            targetCharacter.characterMiniGameData.AddLife(addLife);
            //更新血量显示
            targetCharacter.characterLifeCpt.SetData(miniGameCharacter.characterCurrentLife, miniGameCharacter.characterMaxLife);
        }
        //伤害处理
        int addDamage = EffectTypeEnumTools.GetTotalDamage(actionCharacter, listEffectTypeData);

        if (addDamage > 0)
        {
            targetCharacter.UnderAttack(1, addDamage);
        }
    }