Exemple #1
0
    private IEnumerator PlayOneAction(BattleFightRecord record)
    {
        var character = GetCharacterByAction(record.getAttackAction());
        var characterControll = character.FaceObject.GetComponent<CharacterControl>();

        charactersLeft[character.Location.X, character.Location.Y] = null;

        switch (record.getAttackAction().ActType)
        {
            case BattleRecordConstants.SINGLE_ACTION_TYPE_SP_ATTACK:
                {
                    var monster = GetMonsterByAction(record.ActionList[0]);
                    RunReturn(character, GameConfig.ShortTime);
                    // [FIXME]: Need new SP effect.
                    AddMoveCharacter(character, monster);
                    yield return new WaitForSeconds(RunTime);

                    // wait before attack time.
                    yield return new WaitForSeconds(AttackWaitTime);
                    
                    characterControll.PlayCharacter(Character.State.Super, false);
                    yield return new WaitForSeconds(AttackTime);
                    yield return StartCoroutine(PlayMonsterBeenAttack(record));
                }
                break;
            case BattleRecordConstants.SINGLE_ACTION_TYPE_RECOVER:
                {
                    characterControll.PlayCharacter(Character.State.Attack, false);
                    yield return new WaitForSeconds(AttackTime);
                    characterControll.PlayCharacter(Character.State.Idle, true);
                    CharacterLoseBlood(character.transform.localPosition,
                        record.getAttackAction().getIntProp(BattleRecordConstants.SINGLE_ACTION_PROP_HP));
                }
                break;
            case BattleRecordConstants.SINGLE_ACTION_TYPE_RECOVERED:
                break;
            case BattleRecordConstants.SINGLE_ACTION_TYPE_DEFENCE:
                break;
            default:
                {
                    // run to attack place.
                    var monster = GetMonsterByAction(record.ActionList[0]);
                    RunToAttackPlace(character, monster);
                    yield return new WaitForSeconds(RunTime);

                    // wait before attack time.
                    yield return new WaitForSeconds(AttackWaitTime);

                    // play attack.
                    characterControll.CharacterData.SetSpeed(Character.State.Attack, AttackSpeed);
                    characterControll.PlayCharacter(Character.State.Attack, false);
                    yield return new WaitForSeconds(AttackTime);

                    // play monster is under attack.
                    yield return StartCoroutine(PlayMonsterBeenAttack(record));
                    RunReturn(character, GameConfig.HeroRunReturnTime);
                }
                break;
        }
    }
Exemple #2
0
    private IEnumerator PlayMonsterBeenAttack(BattleFightRecord record)
    {
        var actionList = record.ActionList;
        foreach (var action in actionList)
        {
            var monster = GetMonsterByAction(action);
            if (monster == null)
            {
                continue;
            }

            var hitCount = action.getIntProp(BattleRecordConstants.BATTLE_HERO_PROP_HIT_COUNT);
            var singleDamage = action.getIntProp(BattleRecordConstants.BATTLE_HERO_PROP_HIT_SINGLE_DAMAGE);
            StartCoroutine(MultPopText(monster, hitCount, singleDamage));

            EffectManager.PlayEffect(EffectType.Attrack, 0.8f, 0, -20, monster.transform.position);

            var monsterController = monster.FaceObject.GetComponent<MonsterControl>();
            if (action.prop.ContainsKey(BattleRecordConstants.SINGLE_ACTION_PROP_HP))
            {
                var attackHurt = monsterController.Health -
                                 action.getIntProp(BattleRecordConstants.SINGLE_ACTION_PROP_HP);
                monsterAttackManager.AddMonster(monsterController, attackHurt);

                var hitCounter = monsterAttackManager.GetHitCounter(monsterController);
                monsterController.ShowMultiHit(hitCounter);

                monsterController.SetHealth(action.getIntProp(BattleRecordConstants.SINGLE_ACTION_PROP_HP));

                Debug.LogWarning("---------------------- monster hp: " + monsterController.Health);

                // final fight to show final hurt amount.
                if (battleTeamRecord.RecordList[battleTeamRecord.RecordList.Count - 1] == record)
                {
                    var hurt = monsterAttackManager.GetTotalHurt(monsterController);
                    monsterController.ShowTotalHurt(hurt);
                }
               // Logger.Log("#PlayMonsterBeenAttack.setHp:" + action.getIntProp(BattleRecordConstants.SINGLE_ACTION_PROP_HP));
            }

            // play hurt state.
            monster.PlayState(Character.State.Hurt, false);
            yield return new WaitForSeconds(GameConfig.MonsterAttackStepTime);
            monster.PlayState(Character.State.Idle, true);
        }
    }