- Home /
CS8025 error
i have been using bits and pieces from burgzergarcade's hack and slash tutorials and i have recently done my modifiedStat script but there is an error (CS8025):
Assets/Ascripts/!Character/Charcter classes/ModifiedStat.cs(6,17): error CS0246: The type or namespace name `List' could not be found. Are you missing a using directive or an assembly reference? i copied nearly exactly
using System;
using System.Collections.Generic;
public class ModifiedStat : BaseStat {
private List _mods; //A list of Attributes that modify this stat
private int _modValue; //The amount added to the baseValue from the modifiers
public ModifiedStat() {
_mods = new List<ModifyingAttribute>();
_modValue = 0;
}
public void AddModifier( ModifyingAttribute mod) {
_mods.Add(mod);
}
private void CalculateModValue() {
_modValue = 0;
if(_mods.Count > 0)
foreach(ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
}
public new int AdjustedBaseValue {
get{ return BaseValue + BuffValue + _modValue; }
}
public void Update() {
CalculateModValue();
}
public struct ModifyingAttribute { public Attribute attribute; public float ratio;
public ModifyingAttribute(Attribute att, float rat) {
attribute = att;
ratio = rat;
}
}
}
help please
There isn't a type called List. List is a generic, so you need something like you have in the $$anonymous$$odifiedStat() function, with List.
Answer by Landern · Dec 04, 2012 at 04:59 PM
List is a generic, it requires a type to be specified. The type specified is the type that is contained in the List Collection.
using System;
using System.Collections.Generic;
public class ModifiedStat : BaseStat {
private List<ModifyingAttribute> _mods; //A list of Attributes that modify this stat
private int _modValue; //The amount added to the baseValue from the modifiers
public ModifiedStat() {
_mods = new List<ModifyingAttribute>();
_modValue = 0;
}
public void AddModifier( ModifyingAttribute mod) {
_mods.Add(mod);
}
private void CalculateModValue() {
_modValue = 0;
if(_mods.Count > 0)
foreach(ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
}
public new int AdjustedBaseValue {
get{ return BaseValue + BuffValue + _modValue; }
}
public void Update() {
CalculateModValue();
}
public struct ModifyingAttribute { public Attribute attribute; public float ratio;
public ModifyingAttribute(Attribute att, float rat) {
attribute = att;
ratio = rat;
}
}
}
Your answer
Follow this Question
Related Questions
CS8025 Error (Parsing Error) 1 Answer
A node in a childnode? 1 Answer
Parse xml with unknown fields 1 Answer
BurgZerg Arcade inventory system tutorials... Incomplete!! 1 Answer
CS8085 Parsing Error? 1 Answer