Esempio n. 1
0
    private void TreatCSV()
    {
        currentPos = -1;
        currentStepList.Clear();

        Debug.Log("stringPath=" + "Path/" + pathOfNextCSV);
        Debug.Log(" original path (without Path/) = " + pathOfNextCSV);
        nextCSVToRead = (TextAsset)Resources.Load("Path/" + pathOfNextCSV);
        if (nextCSVToRead == null)
        {
            print("Yep, null");
        }
        Debug.Log("Csv = " + nextCSVToRead.name);

        string[,] grid = CSV_Reader.SplitCsvGrid(nextCSVToRead.text);
        Step bufferStep = null;

        for (uint y = 0; y < grid.GetUpperBound(1); y++)
        {
            Debug.Log("y ?" + y);
            bufferStep = new Step(grid, y);
            currentStepList.Add(bufferStep);
        }
        readingCSV  = true;
        nbrZoneSous = 0;
        zoneSous.Clear();
        displayNextStep();
    }
Esempio n. 2
0
    public void LoadCSV()
    {
        stepList.Clear();
        if (pathToTreat == "")
        {
        }
        else
        {
            //Here go the real code :
            Debug.Log(" original path (without Path/) = " + pathToTreat);
            nextCSVToRead = (TextAsset)Resources.Load("Path/" + pathToTreat);
            if (nextCSVToRead == null)
            {
                Debug.Log("Yep, null : " + pathToTreat);
            }
            Debug.Log("Csv = " + nextCSVToRead.name);

            string[,] grid = CSV_Reader.SplitCsvGrid(nextCSVToRead.text);
            Step bufferStep = null;
            for (uint y = 0; y < grid.GetUpperBound(1); y++)
            {
                Debug.Log("y ?" + y);
                bufferStep = new Step(grid, y);
                stepList.Add(bufferStep);
            }

            //TO DO : second pass to remplace string to int ? like for each room ?
            foreach (Step s in stepList)
            {
                switch (s.type)
                {
                case Utils.StepType.ChangeZone:
                    if (s.grid[1, s.y] == "" || s.grid[1, s.y] == null)
                    {
                        s.grid[1, s.y] = (0).ToString();
                        if (s.grid[2, s.y] == "" || s.grid[2, s.y] == null)
                        {
                            s.grid[1, s.y] = (0).ToString();
                        }
                    }
                    else
                    {
                        int res = roomsName.IndexOf(s.grid[1, s.y]);
                        s.grid[1, s.y] = res.ToString();
                        if (res == -1)
                        {
                            Debug.LogError(s.grid[1, s.y] + " is not a room id");
                        }
                        else
                        {
                            res            = zoneName[res].IndexOf(s.grid[2, s.y]);
                            s.grid[2, s.y] = res.ToString();
                            if (res == -1)
                            {
                                Debug.LogError(s.grid[2, s.y] + " is not a zone id");
                            }
                        }
                    }
                    //s.grid[3, s.y] == true.ToString()) ? true.ToString() : false.ToString(); //Active or not
                    break;

                case Utils.StepType.ChangeInteraction:
                    if (s.grid[1, s.y] == "" || s.grid[1, s.y] == null)
                    {
                        s.grid[1, s.y] = (0).ToString();
                        if (s.grid[2, s.y] == "" || s.grid[2, s.y] == null)
                        {
                            s.grid[1, s.y] = (0).ToString();
                        }
                        if (s.grid[3, s.y] == "" || s.grid[3, s.y] == null)
                        {
                            s.grid[3, s.y] = (0).ToString();
                        }
                    }
                    else
                    {
                        int res = roomsName.IndexOf(s.grid[1, s.y]);
                        s.grid[1, s.y] = res.ToString();
                        if (res == -1)
                        {
                            Debug.LogError(s.grid[1, s.y] + " is not a room id");
                        }
                        else
                        {
                            int res2 = zoneName[res].IndexOf(s.grid[2, s.y]);
                            s.grid[2, s.y] = res2.ToString();
                            if (res2 == -1)
                            {
                                Debug.LogError(s.grid[2, s.y] + " is not a zone id");
                            }
                            else
                            {
                                res            = interName[res][res2].IndexOf(s.grid[3, s.y]);
                                s.grid[3, s.y] = res.ToString();
                                if (res == -1)
                                {
                                    Debug.LogError(s.grid[3, s.y] + " is not an interaction id");
                                }
                            }
                        }
                    }
                    break;

                case Utils.StepType.ChangeState:
                    if (s.grid[1, s.y] == "" || s.grid[1, s.y] == null)
                    {
                        s.grid[1, s.y] = (0).ToString();
                        if (s.grid[2, s.y] == "" || s.grid[2, s.y] == null)
                        {
                            s.grid[1, s.y] = (0).ToString();
                        }
                        if (s.grid[3, s.y] == "" || s.grid[3, s.y] == null)
                        {
                            s.grid[3, s.y] = (0).ToString();
                        }
                    }
                    else
                    {
                        int res = roomsName.IndexOf(s.grid[1, s.y]);
                        s.grid[1, s.y] = res.ToString();
                        if (res == -1)
                        {
                            Debug.LogError(s.grid[1, s.y] + " is not a room id");
                        }
                        else
                        {
                            int res2 = zoneName[res].IndexOf(s.grid[2, s.y]);
                            s.grid[2, s.y] = res2.ToString();
                            if (res2 == -1)
                            {
                                Debug.LogError(s.grid[2, s.y] + " is not a zone id");
                            }
                            else
                            {
                                //
                                int res3 = -1;
                                for (int i = 0; i < statesName[res][res2].Length; i++)
                                {
                                    if (s.grid[3, s.y] == statesName[res][res2][i])
                                    {
                                        res3 = i;
                                    }
                                }
                                //
                                s.grid[3, s.y] = res3.ToString();
                                if (res3 == -1)
                                {
                                    Debug.LogError(s.grid[3, s.y] + " is not a state");
                                }
                            }
                        }
                    }
                    break;

                case Utils.StepType.Salle:
                    if (s.grid[1, s.y] == "" || s.grid[1, s.y] == null)
                    {
                        s.grid[1, s.y] = (0).ToString();
                    }
                    else
                    {
                        int res = roomsName.IndexOf(s.grid[1, s.y]);
                        if (res == -1)
                        {
                            Debug.LogError(s.grid[1, s.y] + " is not a room id");
                        }
                        s.grid[1, s.y] = res.ToString();
                    }
                    break;

                case Utils.StepType.Bruitage:
                    break;

                case Utils.StepType.Musique:
                    break;

                case Utils.StepType.Next:
                    //CSV path
                    break;

                case Utils.StepType.Condition:
                    //
                    //CSV path to win
                    //CSV path to not
                    break;

                case Utils.StepType.Animation:
                    int indexAnimator = AnimationHandler.animatorsName.IndexOf(s.grid[1, s.y]);
                    s.grid[1, s.y] = indexAnimator.ToString();
                    if (indexAnimator == -1)
                    {
                        Debug.Log("Animator " + s.grid[1, s.y] + " doesn't exist");
                    }
                    else
                    {
                        if (s.grid[2, s.y] == true.ToString())
                        {
                            indexAnimator  = triggerPerAnimator[indexAnimator].IndexOf(s.grid[3, s.y]);
                            s.grid[3, s.y] = indexAnimator.ToString();
                            if (indexAnimator == -1)
                            {
                                Debug.Log(s.grid[1, s.y] + "'s animator doesn't have a trigger named : " + s.grid[3, s.y]);
                            }
                        }
                        else
                        {
                            indexAnimator  = triggerPerAnimator[indexAnimator].IndexOf(s.grid[3, s.y]);
                            s.grid[3, s.y] = indexAnimator.ToString();
                            if (indexAnimator == -1)
                            {
                                Debug.Log(s.grid[1, s.y] + "'s animator doesn't have a trigger named : " + s.grid[3, s.y]);
                            }
                            //s.grid 4 doesn't change
                        }
                    }
                    break;

                case Utils.StepType.NextLine:
                case Utils.StepType.ConditionLine:
                case Utils.StepType.Decor:     //maybe like animation
                case Utils.StepType.Description:
                case Utils.StepType.AddItem:
                case Utils.StepType.RemoveItem:
                case Utils.StepType.CinematicBar:
                default:
                    break;
                }
            }
        }
    }