Esempio n. 1
0
    private void load()
    {
        InEditMode = gamestate.Instance.GetInEditMode();

        if (File.Exists(Application.persistentDataPath + "/combo.gd"))
        {
            try {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Open(Application.persistentDataPath + "/combo.gd", FileMode.Open);
                combinationObjectsList = (List <CombinationObject>)bf.Deserialize(file);
                file.Close();
            } catch (System.Exception ex) {
                Debug.LogError(ex.Message);
            }
        }
        else         //there is no file - create a default file and combo
        {
            //default combo is the first target on the top row
            CombinationObject combinationObject = new CombinationObject(1, 1);
            combinationObjectsList.Add(combinationObject);
            save();
        }
    }
Esempio n. 2
0
    public bool RemoveObject(Transform trans)
    {
        foreach (MovingObject obj in objectsList)
        {
            int selectedRowCounter = -1;

            if (obj.transform == trans)
            {
                //add row counter
                switch (obj.Row)
                {
                case (int)RowEnum.Top:
                    rowTopCount++;
                    selectedRowCounter = rowTopCount;
                    break;

                case (int)RowEnum.Middle:
                    rowMiddleCount++;
                    selectedRowCounter = rowMiddleCount;
                    break;

                case (int)RowEnum.Bottom:
                    rowBottomCount++;
                    selectedRowCounter = rowBottomCount;
                    break;
                }

                //the selected object
                CombinationObject combinationObject = new CombinationObject(obj.Row, selectedRowCounter);

                switch (InEditMode)
                {
                case (false):
                    score++;
                    objectsList.Remove(obj);
                    Destroy(obj.transform.gameObject);

                    //check the selected target to the first combinationObjectsList object to see if we have a match
                    if (successfulCombination && combinationObjectsList != null && combinationObjectsList.Count > 0 && combinationObjectsList[0].Row == combinationObject.Row && combinationObjectsList[0].RowCounter == combinationObject.RowCounter)
                    {
                        combinationObjectsList.RemoveAt(0);

                        if (combinationObjectsList.Count == 0)                       //we successfully have our combination - unlock the screen
                        {
                            Application.LoadLevel("BlankScene");
                            //Application.Quit();
                        }
                    }
                    else                    //this is the wrong combination
                    {
                        Debug.Log("Wrong Combination");
                        successfulCombination = false;
                    }

                    break;

                case (true):
                    combinationObjectsList.Add(combinationObject);

                    objectsList.Remove(obj);
                    Destroy(obj.transform.gameObject);
                    break;
                }

                return(true);
            }
        }
        Debug.LogError("ERROR: Couldn't find target!");
        return(false);
    }