Example #1
0
        private IEnumerator DoAttackCoroutine()
        {
            int        damage = _damage;
            TypeEffect te     = TypeEffect.None;
            int        turns  = 0;

            if (Random.Range(0, 100) <= _criticalChance)
            {
                damage = damage + damage;
            }
            if (_weaponEffect.TypeEffect != TypeEffect.None)
            {
                if (Random.Range(0, 100) <= _weaponEffect.Probability)
                {
                    te    = _weaponEffect.TypeEffect;
                    turns = _weaponEffect.Time;
                }
            }
            yield return(new WaitUntil(() => _isDoingAnimation == false));

            _animator.Play("Attack");
            yield return(new WaitUntil(() => _isDoingAnimation == false));

            CombatTurnManager.Instance.DealDamageToEnemy(damage, te, turns);
        }
Example #2
0
        public void ShouldMoreThanTwentyButLessThanFiftyDamagePoints()
        {
            IPokemon attackingPokemon = PokemonFactory.CreatePokemon <Gengar>();
            IPokemon targetPokemon    = PokemonFactory.CreatePokemon <Pidgeot>();

            TypeEffect effectOfTypeOnTargetPokemon = TypeComparer.CompareGhostType(targetPokemon.Types[0]);

            int totalDamage = TypeDamageCalculator.CalculateDamage(
                attackingPokemon,
                targetPokemon,
                attackingPokemon.Moves[2],
                effectOfTypeOnTargetPokemon
                );

            Assert.True(totalDamage >= 20 && totalDamage < 50);

            totalDamage = TypeDamageCalculator.CalculateDamage(
                attackingPokemon,
                targetPokemon,
                attackingPokemon.Moves[1],
                effectOfTypeOnTargetPokemon
                );

            Assert.True(totalDamage >= 20 && totalDamage < 50);
        }
Example #3
0
        public void ShouldDealLessOrEqualToTwentyDamage()
        {
            IPokemon attackingPokemon = PokemonFactory.CreatePokemon <Pikachu>();
            IPokemon targetPokemon    = PokemonFactory.CreatePokemon <Onix>();

            TypeEffect effectOfTypeOnTargetPokemon = TypeComparer.CompareElectricType(targetPokemon.Types[0]);

            int totalDamage = TypeDamageCalculator.CalculateDamage(
                attackingPokemon,
                targetPokemon,
                attackingPokemon.Moves[1],
                effectOfTypeOnTargetPokemon
                );

            Assert.True(totalDamage <= 20);

            totalDamage = TypeDamageCalculator.CalculateDamage(
                attackingPokemon,
                targetPokemon,
                attackingPokemon.Moves[2],
                effectOfTypeOnTargetPokemon
                );

            Assert.True(totalDamage <= 20);
        }
Example #4
0
    public GameObject PlayEffect(TypeEffect type, Vector3 pos, Vector3 rot, float time = 1f)
    {
        bool isPool = false;

        for (int j = 0; j < _mapper[type].Count; j++)
        {
            EffectObject efobj2 = _mapper[type][j];
            if (efobj2.getAction() == false)
            {
                efobj2.ActionEffect(pos, rot);
                isPool = true;
                if (time != 0)
                {
                    StartCoroutine(WatingHideEffect(efobj2, time));
                }
                return(efobj2.gameObject);
            }
        }
        if (isPool == false)
        {
            Debug.LogWarning("PLEASE ADD MORE POOL: " + type.ToString());
            EffectObject effectObject = Instantiate(_mapper[type][0], transform) as EffectObject;
            effectObject.Hide();
            effectObject.ActionEffect(pos, rot);
            if (time != 0)
            {
                StartCoroutine(WatingHideEffect(effectObject, time));
            }
            _mapper[type].Add(effectObject);
            return(effectObject.gameObject);
        }
        Debug.LogError("Not find this effect");
        return(null);
    }
Example #5
0
        public static List <TypeEffect> ExtractTypeEffects(List <TypingData> listTypingData, List <TypeEffectData> listTypeEffectData, IMapper mapper)
        {
            // Create list of TypeEffect for Typing
            List <TypeEffect> listNew = new List <TypeEffect>();
            int id = 1;

            foreach (var dataObj in listTypeEffectData)
            {
                // Check if Typings exist
                int offenseIndex = listTypingData.FindIndex(t => t.Name == dataObj.Attack);
                int defenseIndex = listTypingData.FindIndex(t => t.Name == dataObj.Defend);

                // Create TypeEffect object
                if (offenseIndex >= 0 && defenseIndex >= 0)
                {
                    TypeEffect typeEffect = mapper.Map <TypeEffect>(dataObj);
                    typeEffect.TypeEffectId    = id;
                    typeEffect.OffenseTypingId = listTypingData[offenseIndex].TypingId;
                    typeEffect.DefenseTypingId = listTypingData[defenseIndex].TypingId;
                    listNew.Add(typeEffect);
                    id++;
                }
            }
            return(listNew);
        }
Example #6
0
 public void HideEffectOne(TypeEffect type)
 {
     for (int i = 0; i < _mapper[type].Count; i++)
     {
         if (_mapper[type][i].getAction())
         {
             _mapper[type][i].Hide();
         }
     }
 }
Example #7
0
    // Clone
    public static TypeEffect Clone(TypeEffect original)
    {
        TypeEffect cloneEffect = new TypeEffect(
            effectType: original.effectType,
            forceEffectDisplay: original.forceEffectDisplay,
            boolParams: original.boolParams,
            floatParams: original.floatParams,
            stringParams: original.stringParams
            );

        return(cloneEffect);
    }
Example #8
0
        public async Task <EntityEntry <TypeEffect> > AddOrUpdateAsync(TypeEffect entity)
        {
            var exists = await FindAsync <TypeEffect>(entity.TypeId, entity.EffectId);

            if (exists == null)
            {
                return(Add(entity));
            }
            else
            {
                Entry(exists).CurrentValues.SetValues(entity);
                return(Entry(entity));
            }
        }
 public void RecieveAttack(int damage, TypeEffect typeEffect, int turns)
 {
     _actualLifePoints = _actualLifePoints - Mathf.Max(1, Mathf.RoundToInt((damage / (float)_damageReduction)));
     if (_actualLifePoints <= 0)
     {
         _actualLifePoints = 0;
         StartCoroutine(DieCoroutine());
     }
     else
     {
         _typeEffect  = typeEffect;
         _affectedFor = turns;
         StartCoroutine(RecieveAttackCoroutine());
     }
 }
Example #10
0
        public void ShouldDealMoreThanFiftyDamagePoints()
        {
            IPokemon attackingPokemon = PokemonFactory.CreatePokemon <Venusaur>();
            IPokemon targetPokemon    = PokemonFactory.CreatePokemon <Golem>();

            TypeEffect effectOfTypeOnTargetPokemon = TypeComparer.CompareGrassType(targetPokemon.Types[0]);

            int totalDamage = TypeDamageCalculator.CalculateDamage(
                attackingPokemon,
                targetPokemon,
                attackingPokemon.Moves[3],
                effectOfTypeOnTargetPokemon
                );

            Assert.True(totalDamage > 50);
        }
Example #11
0
        private static void ProcessAttack(IPokemon attackingPokemon, IPokemon targetPokemon, IMove move)
        {
            TypeEffect moveEffectOnPokemon = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(move.Type, targetPokemon.Types.FirstOrDefault());

            int calculatedDamage = TypeDamageCalculator.CalculateDamage(attackingPokemon, targetPokemon, move, moveEffectOnPokemon);

            attackingPokemon.UseMove(move);

            if (move.StatusMoves != null)
            {
                BattleAux.ProcessStatusAttack(attackingPokemon, targetPokemon, move);
            }
            else
            {
                targetPokemon.ReceiveDamage(calculatedDamage);
                ConsoleBattleInfoPokemon.ShowPokemonReceivedDamage(targetPokemon, calculatedDamage);
                ConsoleBattleInfoTypes.ShowHowEffectiveTheMoveWas(moveEffectOnPokemon);
            }
        }
Example #12
0
    private void Start()
    {
        talkManager  = GameObject.Find("TalkManager").GetComponent <TalkManager>();
        questManager = GameObject.Find("QuestManager").GetComponent <QuestManager>();
        player       = GameObject.Find("Player").GetComponent <Transform>();

        //talkText = GameObject.Find("Canvas").transform.Find("Talk Set").GetComponentInChildren<Text>();
        talkPanel    = GameObject.Find("Canvas").transform.Find("Talk Set").GetComponent <Animator>();
        typeEffect   = talkPanel.transform.Find("Text").GetComponent <TypeEffect>();
        portraitImg  = talkPanel.transform.Find("Portrait").GetComponent <Image>();
        portraitAnim = talkPanel.transform.Find("Portrait").GetComponent <Animator>();
        menuSet      = GameObject.Find("Canvas").transform.Find("Menu Set").GetComponent <Transform>();
        questText    = menuSet.transform.Find("Quest Panel").GetComponentInChildren <Text>();
        buttonPanel  = menuSet.transform.Find("Button Panel").GetComponent <Transform>();

        exitButton = buttonPanel.transform.Find("Exit").GetComponent <Button>();
        exitButton.onClick.AddListener(GameExit);

        saveButton = buttonPanel.transform.Find("Save").GetComponent <Button>();
        saveButton.onClick.AddListener(GameSave);

        GameLoad();
        questText.text = questManager.CheckQuest();
    }
Example #13
0
        public void BugAgainstFairyShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(bugType, Type.FAIRY);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
Example #14
0
        public void BugAgainstDarkShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(bugType, Type.DARK);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
Example #15
0
        public void GrassAgainstDragonShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(grassType, Type.DRAGON);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
        public void GroundAgainstBugShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(groundType, Type.BUG);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
        public void GhostAgainstPsychicShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(ghostType, Type.PSYCHIC);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
        public void ElectricAgainstFlyingShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(electricType, Type.FLYING);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
Example #19
0
        public void GrassAgainstFlyingShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(grassType, Type.FLYING);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
        public void PoisonAgainstGhostShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(poisonType, Type.GHOST);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
        public void GhostAgainstFightingShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(ghostType, Type.FIGHTING);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
        public void PoisonAgainstSteelShouldBeImmune()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(poisonType, Type.STEEL);

            Assert.Equal(TypeEffect.IMMUNE, typeEffect);
        }
        public void ElectricAgainstGroundShouldBeImmune()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(electricType, Type.GROUND);

            Assert.Equal(TypeEffect.IMMUNE, typeEffect);
        }
        public void PoisonAgainstFairyShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(poisonType, Type.FAIRY);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
        public void ElectricAgainstDragonShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(electricType, Type.DRAGON);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
Example #26
0
        public void FairyAgainstFightingShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(fairyType, Type.FIGHTING);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
        public void GroundAgainstFlyingShouldBeImmune()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(groundType, Type.FLYING);

            Assert.Equal(TypeEffect.IMMUNE, typeEffect);
        }
Example #28
0
        public void FairyAgainstSteelShouldBeNotVeryEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(fairyType, Type.STEEL);

            Assert.Equal(TypeEffect.NOT_VERY_EFFECTIVE, typeEffect);
        }
        public void GroundAgainstSteelShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(groundType, Type.STEEL);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }
        public void DragonAgainstDragonShouldBeSuperEffective()
        {
            TypeEffect typeEffect = TypeComparer.GetMoveEffectivenessBasedOnPokemonType(dragonType, dragonType);

            Assert.Equal(TypeEffect.SUPER_EFFECTIVE, typeEffect);
        }