Example #1
0
    public void SaveGameFile()
    {
        string path = Application.streamingAssetsPath + "/Warbot/" + _gameName + ".gameset";
        //Write some text to the test.txt file
        StreamWriter writer = new StreamWriter(path, false);



        foreach (GameObject unit in _listUnitGameObject)
        {
            writer.WriteLine("<");
            writer.WriteLine(unit.GetComponent <Stats>()._unitType);

            // Recuperer les percepts
            Percept unitPercepts = unit.GetComponent <Percept>();
            unitPercepts.InitPercept();
            foreach (string s in unitPercepts._percepts.Keys)
            {
                if (s.Contains("PERCEPT"))
                {
                    writer.WriteLine("[PERCEPTS]" + s);
                }
                if (s.Contains("MESSAGE"))
                {
                    writer.WriteLine("[MESSAGE]ACTN_" + s.Replace("PERCEPT_", ""));
                }
            }

            // Recuperer les actions
            Action unitAction = unit.GetComponent <Action>();
            unitAction.InitAction();
            foreach (string s in unitAction._actions.Keys)
            {
                writer.WriteLine("[ACTIONS]" + s);
            }

            // Recuperer les actions
            ActionNonTerminal unitActionNonTerminal = unit.GetComponent <ActionNonTerminal>();
            unitActionNonTerminal.InitActionNonTerminal();
            foreach (string s in unitActionNonTerminal._actionsNT.Keys)
            {
                if (!s.Contains("ACTN_MESSAGE_"))
                {
                    writer.WriteLine("[ANT]" + s);
                }
            }

            writer.WriteLine(">");
        }

        writer.Close();

        print("Done !");
    }
Example #2
0
    public void LoadBehaviour()
    {
        if (GetComponent <Stats>()._teamIndex < GameObject.Find("GameManager").GetComponent <TeamManager>()._teams.Count)
        {
            _instructions = GameObject.Find("GameManager").GetComponent <TeamManager>().getUnitsBevahiours(GetComponent <Stats>()._teamIndex, GetComponent <Stats>()._unitType);
        }

        _componentPercepts             = GetComponent <Percept>();
        _componentActions              = GetComponent <Action>();
        _componentActionsNonTerminales = GetComponent <ActionNonTerminal>();
        //_messageManager = new MessageManager(this.gameObject);
        _messageManager = GetComponent <MessageManager>();
    }