示例#1
0
	public override void OnInit(){
		GameData.SetBtn (this.transform, "BtnOk", "Press", this);
		GameData.SetBtn (this.transform, "BtnNo", "Press", this);
		GameObject oBtnOk = this.transform.FindChild ("BtnOk").gameObject;
		oBtnOk.transform.FindChild("tBtnName").GetComponent<UILabel>().text = "결정";
		m_aAnimal = GameManager.Instance.CurAnimal;
		SelectList ();
		MiddleInfo ();
	}
示例#2
0
	public override void OnPress(GameObject oBtn){
		if ("BtnOk" == oBtn.name) {
			if (null != CallOk) {
				CallOk ();
			}
			GameManager.Instance.CurAnimal = m_aAnimal;
			m_sManager.m_sUpBar.Init ();
			Exit ();
		} else if ("BtnNo" == oBtn.name) {
			Exit ();
		} else if (oBtn.name.Contains ("SelectSlot")) {
			int idx = int.Parse (oBtn.name.Replace ("SelectSlot", ""));
			m_aAnimal = DataManager.Instance.GetAnimalData((MyAnimal)idx);
			MiddleInfo ();
		}
	}
示例#3
0
    void Awake()
    {
        Instance = this;
        Animals = new Dictionary<string, AnimalData>();

        string[] data = animalCsv.text.Split('\n');
        for(int i = 1; i < data.Length; i++)
        {
            string[] rowData = data[i].Split(',');

            AnimalData animal = new AnimalData();
            animal.name = rowData[0].Trim().ToLower();
            if(animal.name.Length != 0)
            {
                try
                {
                    animal.parentName = rowData[1].Trim();
                    if(animal.parentName.Length == 0)
                        animal.parentName = null;
                    animal.spriteIndex = ParseStat(rowData[2]);
                    animal.effectIndex = ParseStat(rowData[3]);
                    // attack graphic
                    animal.attack = ParseStat(rowData[4]);
                    animal.health = ParseStat(rowData[5]);
                    animal.speed = ParseStat(rowData[6]);
                    animal.intelligence = ParseStat(rowData[7]);

                    Animals[animal.name] = animal;
                }
                catch(System.Exception e)
                {
                    Debug.LogError(
                        "error reading animal \"" + animal.name + "\"\n" + e);
                }
            }
        }

        foreach(AnimalData animal in Animals.Values)
        {
            try
            {
                if(animal.parentName != null)
                {
                    AnimalData parent = Assert.NonNull(
                        Get(animal.parentName),
                        "missing parent");

                    if(animal.spriteIndex < 0)
                        animal.spriteIndex = parent.spriteIndex;
                    if(animal.effectIndex < 0)
                        animal.effectIndex = parent.effectIndex;
                    if(animal.attack < 0) animal.attack = parent.attack;
                    if(animal.health < 0) animal.health = parent.health;
                    if(animal.speed < 0) animal.speed = parent.speed;
                    if(animal.intelligence < 0)
                        animal.intelligence = parent.intelligence;
                }
                Assert.Condition(animal.spriteIndex >= 0,
                    "spriteIndex out of range");
                //Assert.Condition(animal.effectIndex >= 0,
                //    "effectIndex out of range");
                Assert.Condition(animal.attack >= 0, "attack out of range");
                Assert.Condition(animal.health >= 0, "health out of range");
                Assert.Condition(animal.speed >= 0, "speed out of range");
                Assert.Condition(animal.intelligence >= 0,
                    "intelligence out of range");
            }
            catch(System.Exception e)
            {
                Debug.LogError(
                    "error processing animal \"" + animal.name + "\"\n" + e);
            }
        }

        //string msg = "";
        //foreach(AnimalData animal in Animals.Values)
        //{
        //    msg += animal.name + " " + animal.attack + " " + animal.health + " " +
        //           animal.speed + " " + animal.intelligence + "\n";
        //}
        //print(msg);
    }
示例#4
0
        //<Summary>
        //The validateData method is used to verify the data before adding/updating the data table.
        //It takes the input table to check, the datagridview for the columns, a bool value to bypass the validation,
        //and a bool value for update or adding the rows.  The datagridview may be null.
        //</Summary
        public DataTable ValidateData(DataTable dtInput, DataGridView dgvColumns, bool bIsChecked, bool bIsUpdate)
        {
            Stopwatch sw = new Stopwatch();
            DataTable dtNotInserted;
            Dictionary<string, string> deCols = new Dictionary<string, string>();
            List<string> ImportRows = new List<string>();
            List<AnimalData> theAnimals = new List<AnimalData>();
            bool bUseMapCol = true;

            sw.Start();

            if (!dtInput.Columns.Contains("DataID"))
                dtInput.Columns.Add("DataID");
            if (!dtInput.Columns.Contains("ExcludeRow"))
                dtInput.Columns.Add("ExcludeRow");

            if (dgvColumns == null)
            {
                dgvColumns = new DataGridView();
                dgvColumns.DataSource = _daoSetup.GetExperimentColumns(GlobalVariables.Experiment.ID);
                bUseMapCol = false;
            }
            DataTable dgvTable = (DataTable)dgvColumns.DataSource;
            foreach (DataRow dgvr in dgvTable.Rows)
            {
                if (dgvr["custom_column_name"] == DBNull.Value ||
                    dgvr["custom_columns_id"] == DBNull.Value ||
                    dgvr["custom_column_data_type"] == DBNull.Value ||
                    (bUseMapCol && dgvr["map_column"] == DBNull.Value))
                {
                    string sMsg = "Cannot import data at this time.  Please verify that all columns have been mapped and imported.";
                    MessageBox.Show(sMsg, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                string col = Convert.ToString(dgvr["custom_column_name"]);
                string colId = Convert.ToString(dgvr["custom_columns_id"]);

                string mapCol = "";
                if (bUseMapCol)
                    mapCol = Convert.ToString(dgvr["map_column"]);
                else
                    mapCol = Convert.ToString(dtInput.Rows[0][Convert.ToString(dgvr["custom_columns_id"])]);
                if (!string.IsNullOrEmpty(mapCol) && !string.IsNullOrEmpty(col) && !string.IsNullOrEmpty(colId))
                {
                    col = colId + "|" + col + "|" + Convert.ToString(dgvr["custom_column_data_type"]);
                    deCols.Add(mapCol, col);
                }
            }

            dtNotInserted = dtInput.Clone();

            foreach (DataRow dr in dtInput.Rows)
            {
                bool bIsValid = false;
                string values = "";
                foreach (KeyValuePair<string, string> entry in deCols)
                {
                    DateTime tempDate;
                    bIsValid = false;
                    double tempDouble = 0;
                    int tempInt = 0;
                    string[] subItem = entry.Value.Split('|');
                    string cellVal = "";
                    if (bUseMapCol)
                        cellVal = Convert.ToString(dr[entry.Key]);
                    else
                        cellVal = entry.Key;
                if(bIsChecked)
                {
                    switch (subItem[2])
                    {
                        case "DECIMAL":
                            if (!string.IsNullOrEmpty(cellVal) && Double.TryParse(cellVal, out tempDouble))
                                bIsValid = true;
                            break;
                        case "INTEGER":
                            if (!string.IsNullOrEmpty(cellVal) && Int32.TryParse(cellVal, out tempInt))
                                bIsValid = true;
                            break;
                        case "DATE_TIME":
                            if (!string.IsNullOrEmpty(cellVal) && DateTime.TryParse(cellVal, out tempDate))
                                bIsValid = true;
                            break;
                        default:
                            bIsValid = true;
                            break;
                    }
                }
                else
                    bIsValid = true;

                    if (bIsValid)
                    {
                        values = values + "|^|" + subItem[0] + "^*^" + cellVal;
                    }
                    else
                    {
                        DataRow newRow = dtNotInserted.NewRow();
                        for (int i = 0; i < newRow.ItemArray.Length; i++)
                        {
                            newRow[i] = dr[i];
                        }
                        dtNotInserted.Rows.Add(newRow);
                        break;
                    }
                }
                if (bIsValid && !bIsUpdate)
                {
                    ImportRows.Add(values);
                }
                else if(bIsValid && bIsUpdate)
                {
                    AnimalData animal = new AnimalData();
                    animal.DataAgg = values;
                    animal.DataID = Convert.ToInt32(dr["DataID"]);
                    animal.ExID = GlobalVariables.Experiment.ID;
                    animal.ExcludeRow = Convert.ToString(dr["ExcludeRow"]);
                    animal.ModUser = GlobalVariables.ADUserName;
                    animal.Picture = dr["1"] as byte[];
                    _daoData.UpdateExperimentData(animal);
                    if (animal.Picture != null)
                        _daoData.InsertPic("EXPERIMENT_DATA", animal.DataID, animal.Picture);
                    ImportRows.Add(values);
                }
            }

            if (ImportRows.Count > 0 && !bIsUpdate)
            {
                _daoSetup.BulkImport(ImportRows);  
            }

            sw.Stop();
            Trace.WriteLine("Import time elapsed:  " + sw.Elapsed);

            string msg2 = ImportRows.Count.ToString() + " were imported.  ";
            if (dtNotInserted.Rows.Count > 0  && !bIsUpdate)
            {

                msg2 = msg2 + dtNotInserted.Rows.Count.ToString() + " were determined to have errors and were not imported/added.  " +
                    "Please verify the data is correct and try to import/add again.  Pressing Yes will bypass the Data checks.  " +
                    "Do you wish to enter the data in its current state?";
            }
            if (dtNotInserted.Rows.Count > 0 && bIsUpdate)
            {

                msg2 = msg2 + dtNotInserted.Rows.Count.ToString() + " were determined to have errors and were not updated.  " +
                    "Please verify the data is correct and try to update again.  Pressing Yes will bypass the Data checks." +
                    "Do you wish to update the data in its current state?";
            }

            if (dtNotInserted.Rows.Count > 0)
            {
                DialogResult result = MessageBox.Show(msg2, "Data Import", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    if (!bIsUpdate)
                        ValidateData(dtNotInserted, dgvColumns, false, false);
                    else
                        ValidateData(dtNotInserted, dgvColumns, false, true);
                }
                else
                    return dtNotInserted;
            }
            else
                MessageBox.Show(msg2, "Data Import", MessageBoxButtons.OK, MessageBoxIcon.Information);

            return null;
        }
示例#5
0
    public static void SaveWorldToGameInformation(int scene)
    {
        int breakableCount = 0;
        int animalCount = 0;
        int characterCount = 0;

        ALLGAMEOBJECTS = UnityEngine.Object.FindObjectsOfType<GameObject>();

        foreach(GameObject g in ALLGAMEOBJECTS) {
            try {
                Breakable b = g.GetComponent<Breakable>();
                breakableCount++;
            } catch (Exception e) {}
            try {
                Animal ani = g.GetComponent<Animal>();
                Action a = g.GetComponent<Action>();
                animalCount++;
            } catch (Exception ee) {}
            try {
                Character c = g.GetComponent<Character>();
                Action a = g.GetComponent<Action>();
                characterCount++;
            } catch (Exception eee) {}
        }

        BreakableData[] breakableArray = new BreakableData[breakableCount];
        AnimalData[] animalArray = new AnimalData[animalCount];
        CharacterData[] characterArray = new CharacterData[characterCount];

        int breakableIndex = 0;
        int animalIndex = 0;
        int characterIndex = 0;

        foreach(GameObject g in ALLGAMEOBJECTS) {
            try {
                Breakable b = g.GetComponent<Breakable>();
                BreakableData bd = new BreakableData(g);
                breakableArray[breakableIndex] = bd;
                breakableIndex++;
            } catch (Exception e) {}
            try {
                Animal ani = g.GetComponent<Animal>();
                Action a = g.GetComponent<Action>();
                AnimalData anid = new AnimalData(g);
                animalArray[animalIndex] = anid;
                animalIndex++;
            } catch (Exception ee) {}
            try {
                Character c = g.GetComponent<Character>();
                Action a = g.GetComponent<Action>();
                CharacterData cd = new CharacterData(g);
                characterArray[characterIndex] = cd;
                characterIndex++;
            } catch (Exception eee) {}
        }

        SceneData sd = new SceneData(scene, breakableArray, animalArray, characterArray);
        if(SCENEARRAY != null) {
            foreach(SceneData i in SCENEARRAY) {
                sceneList.Add(i);
            }
            foreach(SceneData s in sceneList) {
                if(s.getId() == scene) {
                    removeList.Add(s);
                }
            }
            foreach(SceneData s in removeList) {
                sceneList.Remove(s);
            }
            removeList.Clear();
        }
        sceneList.Add(sd);
        SCENEARRAY = new SceneData[sceneList.Count];
        int sceneIndex = 0;
        foreach(SceneData i in sceneList) {
            SCENEARRAY[sceneIndex] = i;
            sceneIndex++;
        }

        WORLDDATA = new WorldData(SCENEARRAY);
    }
示例#6
0
    /* Method to load appropriate information to the worldspace UI
     * based on animal and the selected sense
     */
    public void LoadRuntimeData(string animal, string sense)
    {
        //declare variables to be used
        SensesData senseData  = null;
        AnimalData animalData = null;

        Text[]     activationData = new Text[4];
        Text[]     titleData      = new Text[2];
        Color      senseColor     = new Color();
        GameObject model          = null;

        //define variables to be used based on animal parameter
        if (animal.Equals("coyote"))
        {
            animalData     = coyoteData;
            titleData      = coyoteTitle;
            activationData = coyoteActivation;
            model          = coyote;
        }
        else if (animal.Equals("human"))
        {
            animalData     = humanData;
            titleData      = humanTitle;
            activationData = humanActivation;
            model          = human;
        }
        else if (animal.Equals("dolphin"))
        {
            animalData     = dolphinData;
            titleData      = dolphinTitle;
            activationData = dolphinActivation;
            model          = dolphin;
        }

        //define sense name with assigned color based on sense
        if (sense.Equals("visual"))
        {
            senseData  = animalData.senses[0];
            senseColor = magenta;
        }
        else if (sense.Equals("auditory"))
        {
            senseData  = animalData.senses[1];
            senseColor = yellow;
        }
        else if (sense.Equals("olfactory"))
        {
            senseData  = animalData.senses[2];
            senseColor = blue;
        }

        //display sense name and sense information
        titleData[1].text       = senseData.name;
        titleData[1].color      = senseColor;
        activationData[0].text  = senseData.activation;
        activationData[0].color = senseColor;
        activationData[1].text  = senseData.facts[0];
        activationData[2].text  = senseData.facts[1];
        activationData[3].text  = senseData.facts[2];

        //fade out text data if they aren't in front
        fadeText(activationData, senseColor, model);
    }
示例#7
0
 static SearchController()
 {
     animalData = AnimalData.GetInstance();
 }
示例#8
0
 protected override void EnterPattern(GameObject gameObject, AnimalData animalData)
 {
     this.AnimalToTimeElapsed.Add(gameObject, 0);
     animalData.animal.MovementData.MovementStatus = Movement.idle;
 }
示例#9
0
 public AnimalSaveData(Animal animal)
 {
     data = animal.data;
     kind = animal.stats.kind;
 }
示例#10
0
        public DataLoader(IModHelper helper)
        {
            Helper    = helper;
            ModConfig = helper.ReadConfig <ModConfig>();
            i18n      = Helper.Translation;

            LooseSpritesName = Helper.Content.GetActualAssetKey("common/LooseSprites.png", ContentSource.ModFolder);
            LooseSprites     = Helper.Content.Load <Texture2D>("common/LooseSprites.png");

            // load tools
            ToolsSprites = Helper.Content.Load <Texture2D>("tools/Tools.png");
            ToolsLoader  = new ToolsLoader(ToolsSprites, Helper.Content.Load <Texture2D>("tools/MenuTiles.png"), Helper.Content.Load <Texture2D>("common/CustomLetterBG.png"));
            ToolsLoader.LoadMail();

            // load recipes
            if (!ModConfig.DisableMeat)
            {
                RecipeLoader = new RecipesLoader();
                RecipeLoader.LoadMails();
            }

            //load treats mail
            if (!ModConfig.DisableTreats)
            {
                LoadTreatsMail();
            }

            // load animal data
            AnimalBuildingData = DataLoader.Helper.Data.ReadJsonFile <AnimalBuildingData>("data\\animalBuilding.json") ?? new AnimalBuildingData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animalBuilding.json", AnimalBuildingData);
            AnimalData = DataLoader.Helper.Data.ReadJsonFile <AnimalData>("data\\animals.json") ?? new AnimalData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animals.json", AnimalData);
            AnimalContestData = DataLoader.Helper.Data.ReadJsonFile <AnimalContestData>("data\\animalContest.json") ?? new AnimalContestData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animalContest.json", AnimalContestData);

            // look cooking data
            CookingData = Helper.Data.ReadJsonFile <CookingData>("data\\cooking.json") ?? new CookingData();
            if (CookingData.Meatloaf.Recipe == null)
            {
                CookingData.CloneRecipeAndAmount(new CookingData());
            }
            Helper.Data.WriteJsonFile("data\\cooking.json", CookingData);

            // load Livin' With The Animals channel
            TvController.AddChannel(new LivingWithTheAnimalsChannel());

            // add editors (must happen *after* data is initialised above, since SMAPI may reload affected assets immediately)
            var editors = Helper.Content.AssetEditors;
            var loaders = Helper.Content.AssetLoaders;

            if (!ModConfig.DisableAnimalContest)
            {
                editors.Add(new EventsLoader());
                loaders.Add(this);
            }
            editors.Add(ToolsLoader);
            editors.Add(this);
            if (!ModConfig.DisableMeat)
            {
                editors.Add(RecipeLoader);
            }
        }
示例#11
0
 static ListController()
 {
     animalData = AnimalData.GetInstance();
 }
示例#12
0
 public AnimalController()
 {
     animalData = new AnimalData();
     personData = new PersonData();
 }