Hi, while I was programming I got this error: error CS7036: There is no argument given that corresponds to the required formal parameter ‘value’ of 'Dictionary<Stat, int>.Add(Stat, int).
I tried to fix it, but I couldn’t, could someone help me? thank you.
Here’s the code(Visual studio reports the error on lines 48 to 52):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Pokémon
{
[SerializeField] PokémonBase _base;
[SerializeField] int level;
public PokémonBase Base {
get
{
return _base;
}
}
public int Level
{
get
{
return level;
}
}
public int HP { get; set; }
public List<Move> Moves { get; set; }
public Dictionary<Stat, int> Stats { get; private set; }
public Dictionary<Stat, int> StatBoosts { get; private set; }
public void Init()
{
//Generate Moves
Moves = new List<Move>();
foreach (var move in Base.LearnableMoves)
{
if (move.Level <= Level)
Moves.Add(new Move(move.Base));
if (Moves.Count >= 4)
break;
}
CalculateStats();
HP = MaxHp;
StatBoosts = new Dictionary<Stat, int>()
{
(Stat.Attack, 0),
(Stat.Defense, 0),
(Stat.SpAttack, 0),
(Stat.SpDefense, 0),
(Stat.Speed, 0)
};
}
void CalculateStats()
{
Stats = new Dictionary<Stat, int>();
Stats.Add(Stat.Attack, Mathf.FloorToInt((Base.Attack * level) / 100f + 5));
Stats.Add(Stat.Defense, Mathf.FloorToInt((Base.Defense * level) / 100f + 5));
Stats.Add(Stat.SpAttack, Mathf.FloorToInt((Base.SpAttack * level) / 100f + 5));
Stats.Add(Stat.SpDefense, Mathf.FloorToInt((Base.SpDefense * level) / 100f + 5));
Stats.Add(Stat.Speed, Mathf.FloorToInt((Base.Speed * level) / 100f + 5));
MaxHp = Mathf.FloorToInt((Base.Speed * Level) / 100f) + 10;
}
int GetStat(Stat stat)
{
int statVal = Stats[stat];
//applty stat boost
int boosts = StatBoosts[stat];
var boostValues = new float[] { 1f, 1.5f, 2f, 2.5f, 3f, 3.5f, 4f };
if (boosts >= 0)
statVal = Mathf.FloorToInt(statVal * boostValues[boosts]);
else
statVal = Mathf.FloorToInt(statVal / boostValues[boosts]);
return statVal;
}
public int Attack
{
get { return GetStat(Stat.Attack); }
}
public int Defense
{
get { return GetStat(Stat.Defense); }
}
public int SpAttack
{
get { return GetStat(Stat.SpAttack); }
}
public int SpDefense
{
get { return GetStat(Stat.SpDefense); }
}
public int Speed
{
get { return GetStat(Stat.Speed); }
}
public int MaxHp
{
get; private set;
}
public DamageDetails TakeDamage(Move move, Pokémon attacker)
{
float critical = 1f;
if (Random.value * 100f < 6.25f)
critical = 2f;
float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);
var damageDetails = new DamageDetails()
{
TypeEffectiveness = type,
Critical = critical,
Fainted = false
};
float attack = (move.Base.Category == MoveCategory.Speciale) ? attacker.SpAttack : attacker.Attack;
float defense = (move.Base.Category == MoveCategory.Speciale) ? SpDefense : Defense;
float modifiers = Random.Range(0.85f, 1f) * type * critical;
float a = (2 * attacker.Level + 10) / 250f;
float d = a * move.Base.Power * ((float)attack / defense) + 2;
int damage = Mathf.FloorToInt(d * modifiers);
HP -= damage;
if(HP <= 0)
{
HP = 0;
damageDetails.Fainted = true;
}
return damageDetails;
}
public Move GetRandomMove()
{
int r = Random.Range(0, Moves.Count);
return Moves[r];
}
}
public class DamageDetails
{
public bool Fainted { get; set; }
public float Critical { get; set; }
public float TypeEffectiveness { get; set; }
}