But there still is a problem as
Code: Select all
[SerializeField]public ArrayList _inventory;
[SerializeField]public Hashtable _properties;
[SerializeField]public Hashtable _spells;
Is returning null.
Code: Select all
[SerializeField]public ArrayList _inventory;
[SerializeField]public Hashtable _properties;
[SerializeField]public Hashtable _spells;
Code: Select all
public string toString()
{
Debug.Log("RPG Character: " + this._name);
Debug.Log("Type: " + this._type);
if (_inventory != null)
{
Debug.Log("Inventory is not null");
Debug.Log(this._inventory);
foreach (Item Item in this._inventory)
{
Debug.Log("Item: " + Item);
}
}
if (_spells != null)
{
Debug.Log("_spells is not null");
Debug.Log(_spells);
foreach (Spell spell in _spells)
{
Debug.Log("Spells: " + spell);
}
}
if (_properties != null)
{
Debug.Log("properties is not null");
Debug.Log(_properties);
foreach (CharacterProperty prop in _properties)
{
Debug.Log("Properties: " + prop);
}
return "";
}
}
}
NullReferenceException: Object reference not set to an instance of an object
altarianonline.model.RpgCharacter.toString () (at Assets/model/RpgCharacter.cs:124)
GameManager.dumpModel (ISFSObject data) (at Assets/Scripts/GameManager.cs:512)
GameManager.OnExtensionResponse (Sfs2X.Core.BaseEvent e) (at Assets/Scripts/GameManager.cs:492)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Rethrow as Exception: Error dispatching event extensionResponse: Object reference not set to an instance of an object at altarianonline.model.RpgCharacter.toString () (at Assets/model/RpgCharacter.cs:124)
GameManager.dumpModel (ISFSObject data) (at Assets/Scripts/GameManager.cs:512)
GameManager.OnExtensionResponse (Sfs2X.Core.BaseEvent e) (at Assets/Scripts/GameManager.cs:492)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Sfs2X.SmartFox.ProcessEvents ()
GameManager.FixedUpdate () (at Assets/Scripts/GameManager.cs:195)
Code: Select all
DefaultSFSDataSerializer.RunningAssembly = Assembly.GetExecutingAssembly();
Code: Select all
public int hitpoints
{
get
{
return _hitPoints;
}
set
{
this._hitPoints = hitpoints;
}
}
Code: Select all
public int hitpoints
{
get
{
return _hitPoints;
}
set
{
this._hitPoints = value;
}
}
Code: Select all
public int hitpoints { get; set; }
Code: Select all
using Sfs2X.Protocol.Serialization;
public interface Item : SerializableSFSType
{
string getId();
void useItem();
void sell();
void buy();
}
Code: Select all
using UnityEngine;
using Sfs2X.Protocol.Serialization;
namespace altarianonline.model
{
public class WeaponItem : Item, SerializableSFSType
{
public WeaponItem()
{
//Debug.Log("WeaponItem Dynamically Called.");
}
public WeaponItem(string id, int price, int patk, int matk, int satk, int fire, int earth, int water, int wind, int thunder, string quality, int location)
{
this.id = id;
this.price = price;
this.active = true;
this.Patk = patk;
this.Matk = matk;
this.Satk = satk;
this.wind = wind;
this.thunder = thunder;
this.earth = earth;
this.fire = fire;
this.quality = quality;
this.location = location;
}
public string id;
public bool active;
public int price;
public int Patk;
public int Matk;
public int Satk;
public int wind;
public int thunder;
public int earth;
public int water;
public int fire;
public string quality;
public int location;
public string getId()
{
return id;
}
public void useItem()
{
Debug.Log("Used Item: " + id);
}
public void sell()
{
Debug.Log("Sold Item: " + id);
}
public void buy()
{
Debug.Log("Bought Item: " + id);
}
}
}
//Create Hashmaps to hold charater information
Map<String, Item> inventory = new HashMap<>();
Map<String, CharacterProperty> props1 = new HashMap<>();
Map<String, Skill> skills = new HashMap<>();
Map<String, Pet> pets = new HashMap<>();
Map<String, Buffs> buffs = new HashMap<>();
RpgCharacter knightOfTheRoundTable1 = new RpgCharacter();
Code: Select all
if (skills != null)
for (Map.Entry<String, Skill> entry : skills.entrySet())
sb.append(TAB).append(TAB).append(entry.getValue().getId()).append(" -- Modifies: ").append(entry.getValue().getModifies()).append(", Level: ").append(entry.getValue().getLevel()).append(NEW_LINE);
Code: Select all
if (inventory != null)
{
foreach (var Item in inventory.Values)
{
dump(Item);
}
}
if (inventory != null)
{
foreach (Item Item in inventory.Values)
{
dump(Item.getId.ToString());
}
}
Severity Code Description Project File Line Suppression State
Error CS0119 'Item.getId()' is a method, which is not valid in the given context Assembly-CSharp D:\Documents\Smart Fox Server\Training\07 MMORoomDemo\source\client\MMORoomDemo\MMORoomDemo\Assets\model\RpgCharacter.cs 102 Active
Code: Select all
foreach (Item item in inventory.Values)
{
Debug.Log(item.getId().ToString());
}
Code: Select all
foreach (Item Item in inventory.Values)
{
Debug.Log(Item.getId().ToString());
}
Users browsing this forum: No registered users and 97 guests