private void Start() { MonsterContainer monsterContainer = new MonsterContainer(); monsterContainer.monsterContainer.Add(new Monster { Name = "Goblin", ID = 0, Health = 50f }); monsterContainer.monsterContainer.Add(new Monster { Name = "Ogre", ID = 1, Health = 100f }); monsterContainer.monsterContainer.Add(new Monster { Name = "Troll", ID = 2, Health = 200f }); XmlOperation.Serialize(monsterContainer, Path.Combine(Application.persistentDataPath, "Monster.xml")); }
/// <summary> /// Actions carried out when this instance is started. /// </summary> void Start() { timer = 10; container = serializer.Deserialize(stream) as MonsterContainer; stream.Close(); }
private void Start() { _selectable = GetComponentInChildren <Selectable>(); _selectable.Selected += OnSelected; _selectable.UnSelected += OnUnSelected; _moveRadiusInstance = Instantiate(_moveRadiusPrefab, transform); _moveRadiusInstance.gameObject.SetActive(false); _monsterContainer = GetComponent <MonsterContainer>(); }
public void createDinamicCard(GameObject go, string player, Player jug) { var monsterCollection = MonsterContainer.Load(Path.Combine(Application.dataPath, "monsters.xml")); GameObject c = (GameObject)Instantiate(card); int it = Random.Range(0, monsterCollection.Monsters.Length); foreach (Transform data in c.transform) { if (data.name == "name") { Text t = data.GetComponent <Text> (); t.text = monsterCollection.Monsters [it].getName(); c.name = monsterCollection.Monsters [it].getName(); } if (data.name == "Attack") { Text t = data.GetComponentInChildren <Text> (); t.text = monsterCollection.Monsters [it].getAtk().ToString(); } if (data.name == "Defense") { Text t = data.GetComponentInChildren <Text> (); t.text = monsterCollection.Monsters [it].getHealth().ToString(); } if (data.name == "cost") { Text t = data.GetComponentInChildren <Text> (); t.text = monsterCollection.Monsters [it].getCost().ToString(); } } c.transform.SetParent(go.transform, false); c.tag = player; if ((player == "Player1" && !turnPlayer1) || (!isUsableThisCard(c, jug))) { c.GetComponent <draggable> ().enabled = false; Image img = c.GetComponent <Image> (); img.color = Color.red; } else if ((player == "Player2" && !turnPlayer2) || (!isUsableThisCard(c, jug))) { c.GetComponent <draggable> ().enabled = false; Image img = c.GetComponent <Image> (); img.color = Color.red; } else { Image img = c.GetComponent <Image> (); img.color = Color.green; } }
// Start is called before the first frame update void Start() { var monsterCollection = MonsterContainer.Load(Path.Combine(Application.dataPath, "RealFram/xmlTest/monsters.xml")); Monster[] m_monsters = monsterCollection.Monsters; Debug.Log(m_monsters[0].Name); Debug.Log(m_monsters[0].Health); Debug.Log(m_monsters[0].Description); Debug.Log(m_monsters[0].Funny); var monsterCollection2 = new MonsterContainer(); monsterCollection2.Monsters = new Monster[1]; Monster mMonter = new Monster(); mMonter.Name = "test2"; mMonter.Health = 10; mMonter.Funny = "heyhey"; mMonter.Description = "running away"; monsterCollection2.Monsters[0] = mMonter; monsterCollection2.Save(Path.Combine(Application.dataPath, "RealFram/xmlTest/monsters.xml")); }
private void Awake() { path = Path.Combine(Application.persistentDataPath, "Monster.xml"); monCont = XmlOperation.Deserialize <MonsterContainer>(path); }
private void Start() { _selectable = GetComponentInChildren <Selectable>(); _worldItemContainer = GetComponent <WorldItemContainer>(); _monsterContainer = GetComponent <MonsterContainer>(); }