/// <summary>
        /// Commits all objects in the passed list of SQLiteEnabled
        /// </summary>
        /// <param name="sqliteConnection">The SQLiteConnection object which points to the SQLite database.</param>
        /// <param name="dataSet">List of SQLiteEnabled objects to commit to the database.</param>
        /// <param name="sqliteEnabledType">Type of objects contained within dataSet.</param>
        /// <returns>True upon completion.</returns>
        public static bool CommitData(SQLiteConnection sqliteConnection, List <dynamic> dataSet, Type sqliteEnabledType)
        {
            // Will only work with classes that are sqliteEnabledType.
            if (sqliteEnabledType.BaseType != typeof(SQLiteEnabled))
            {
                return(false);
            }

            // Wrap the entire process in a transaction for performance and to make this function atomic.
            var TransactionCommand = sqliteConnection.CreateCommand();

            TransactionCommand.CommandText = "BEGIN TRANSACTION";
            TransactionCommand.ExecuteNonQuery();

            foreach (var ThisObject in dataSet)
            {
                // Insert new records and update
                if (sqliteEnabledType.GetProperty("ID").GetValue(ThisObject) == 0)
                {
                    InsertObject(sqliteConnection, ThisObject, sqliteEnabledType);
                }
                else
                {
                    // Only update is the object has changed.
                    if (!Enumerable.SequenceEqual <byte>(ThisObject.RetreivedValue, ThisObject.ComputeByteArrayValue()))
                    {
                        UpdateObject(sqliteConnection, ThisObject, sqliteEnabledType);
                    }
                }
            }

            TransactionCommand.CommandText = "END TRANSACTION";
            TransactionCommand.ExecuteNonQuery();
            return(true);
        }
Beispiel #2
0
    void Update()
    {
        if (PlayerPrefs.HasKey(ItemName + "StartTime"))
        {
            StartTime = System.DateTime.Parse(PlayerPrefs.GetString(ItemName + "StartTime"));                   //load
        }
        if (StartTime == zeroTime)
        {
            StartTime = System.DateTime.Now;
            PlayerPrefs.SetString(ItemName + "StartTime", StartTime.ToString());
        }

        UpdatedTime  = System.DateTime.Now;
        BoughtNumber = PlayerPrefs.GetInt(ItemName + "BoughtNumber");
        AllTime      = TimeSpan.FromTicks(ItemHour.Ticks * BoughtNumber);
        PassedTime   = UpdatedTime - StartTime;
        RemainTime   = AllTime - PassedTime;
//		RemainHour = RemainTime.Days * 24 + RemainTime.Hours;

        if (RemainTime <= zeroTimeSpan)
        {
            PlayerPrefs.SetString(ItemName + "StartTime", zeroTime.ToString());
            ShopObject.GetComponent <Item> ().BoughtNumber = 0;
            PlayerPrefs.SetInt(ItemName + "BoughtNumber", 0);
            RemainTime = zeroTimeSpan;
            ThisObject.SetActive(false);
        }
    }
Beispiel #3
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        Init(property, label);

        ThisObject t = properties[property.propertyPath];

        return(t.list.GetHeight());
    }
Beispiel #4
0
    // Draw the int as a list popup
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        Init(property, label);

        ThisObject t = properties[property.propertyPath];

        property.serializedObject.Update();
        EditorGUI.BeginProperty(position, label, property);

        t.list.DoList(position);

        EditorGUI.EndProperty();
        property.serializedObject.ApplyModifiedProperties();
    }
Beispiel #5
0
 protected override void Awake()
 {
     base.Awake();
     if (_firePorts != null)
     {
         _firePoints = new Transform[(int)EnumEquipSlot.MAX];
         for (int i = 0; i < _firePoints.Length; i++)
         {
             string node = "a";
             char   b    = (char)('a' + i);
             node = node.Replace('a', b);
             GameObject gb = Utils.GetNode(node, ThisObject);
             if (gb != null)
             {
                 _firePoints[i] = gb.transform;
             }
         }
     }
     ObjectID.ObjectType = FC_OBJECT_TYPE.OBJ_BULLET;
     _bulletDisplayers   = ThisObject.GetComponents <BulletDisplayer>();
     if (_agents != null)
     {
         _moveAgent = _agents.GetComponent <MoveAgent>();
         if (_moveAgent != null)
         {
             _moveAgent.Init(this);
         }
     }
     _attackInfo._hitType    = AttackHitType.HurtTiny;
     _attackInfo._damageType = FC_DAMAGE_TYPE.NONE;
     _attackInfo._effectTime = 4f;
     if (_firePorts != null)
     {
         int i = 0;
         foreach (RangerAgent.FirePort fr in _firePorts)
         {
             fr.RefreshPorts(this);
             if (fr._portName == _firePortLifeOver)
             {
                 _firePortLifeOverIdx = i;
             }
             if (fr._portName == _firePortLifeIn)
             {
                 _firePortLifeInIdx = i;
             }
             i++;
         }
     }
 }
Beispiel #6
0
    public override void AddGorengan(Gorengan gorengan)
    {
        CookingItem item     = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.placement);
        ToolAction  t_action = ThisObject.GetComponent <ToolAction>();

        if (t_action != null && item != null)
        {
            if (item.Level < t_action.UnlockLevel)
            {
                // can't use wajan because level
                return;
            }

            if (_gorengan == null)
            {
                _gorengan = gorengan;
                GameObject g_object = GameManagement.GorenganObjectList.Find(x => x.name == gorengan.ids);
                ChildGorengan = MonoBehaviour.Instantiate(g_object, ThisObject.transform.position, ThisObject.transform.rotation, ThisObject.transform);
                ChildGorengan.transform.GetChild(0).Find("GorenganName").GetComponent <Text>().text = _gorengan.Name;
            }
            this.total += gorengan.TotalResult;
            ChildGorengan.transform.GetChild(0).Find("GorenganNumber").GetComponent <Text>().text = this.total.ToString();
        }
    }
Beispiel #7
0
    void Init(SerializedProperty property, GUIContent label)
    {
        string path = property.propertyPath;

        if (!properties.ContainsKey(path))
        {
            ThisObject t = new ThisObject()
            {
                propPlayOnce = property.FindPropertyRelative("playOnce"),
                propMessages = property.FindPropertyRelative("messages"),
                list         = null
            };

            t.list = new ReorderableList(t.propMessages.serializedObject, t.propMessages, true, true, true, true);

            t.list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
                if (!t.list.serializedProperty.isExpanded)
                {
                    return;
                }
                EditorGUI.PropertyField(rect, t.propMessages.GetArrayElementAtIndex(index));
            };

            t.list.elementHeight = t.list.serializedProperty.isExpanded ? (t.list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
            //t.list.elementHeightCallback = (int index) => {
            //	return EditorGUI.GetPropertyHeight(t.list.serializedProperty.GetArrayElementAtIndex(index));
            //};

            t.list.drawHeaderCallback = (Rect rect) => {
                //EditorGUI.LabelField(rect, "Dialog");
                Rect rectLabel    = new Rect(rect.x, rect.y, rect.width / 2f, rect.height);
                Rect rectPlayOnce = new Rect(rect.x + rect.width / 2f, rect.y, rect.width / 2, rect.height);

                EditorGUI.indentLevel++;
                t.list.serializedProperty.isExpanded = EditorGUI.Foldout(rectLabel, t.list.serializedProperty.isExpanded, "Dialog");
                EditorGUI.indentLevel--;

                var playOnceLabel = new GUIContent(t.propPlayOnce.displayName);
                EditorGUI.BeginProperty(rectPlayOnce, playOnceLabel, t.propPlayOnce);
                //EditorGUI.PropertyField(rectPlayOnce, t.propPlayOnce);
                t.propPlayOnce.boolValue = EditorGUI.ToggleLeft(rectPlayOnce, playOnceLabel, t.propPlayOnce.boolValue);
                EditorGUI.EndProperty();

                t.list.draggable             =
                    t.list.displayAdd        =
                        t.list.displayRemove = t.list.serializedProperty.isExpanded;

                t.list.elementHeight = t.list.serializedProperty.isExpanded ? (t.list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
            };

            t.list.onAddCallback = (ReorderableList list) => {
                var prop  = list.serializedProperty;
                int index = prop.arraySize;

                prop.InsertArrayElementAtIndex(index);

                // Reset the values
                var sub = prop.GetArrayElementAtIndex(index);
                sub.FindPropertyRelative("text").stringValue   = string.Empty;
                sub.FindPropertyRelative("turnHead").boolValue = false;
            };

            t.list.onRemoveCallback = (ReorderableList list) => {
                if (list.count > 0)
                {
                    list.serializedProperty.DeleteArrayElementAtIndex(list.index >= 0 ? list.index : list.count - 1);
                    list.elementHeight = list.serializedProperty.isExpanded ? (list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
                }
            };

            properties[path] = t;
        }
    }
 public void SetActive(bool temp)
 {
     ThisObject.SetActive(temp);
 }
Beispiel #9
0
    void Init(SerializedProperty property, GUIContent label)
    {
        string path = property.propertyPath;

        if (!properties.ContainsKey(path)) {
            ThisObject t = new ThisObject() {
                propPlayOnce = property.FindPropertyRelative("playOnce"),
                propMessages = property.FindPropertyRelative("messages"),
                list = null
            };

            t.list = new ReorderableList(t.propMessages.serializedObject, t.propMessages, true, true, true, true);

            t.list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
                if (!t.list.serializedProperty.isExpanded) return;
                EditorGUI.PropertyField(rect, t.propMessages.GetArrayElementAtIndex(index));
            };

            t.list.elementHeight = t.list.serializedProperty.isExpanded ? (t.list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
            //t.list.elementHeightCallback = (int index) => {
            //	return EditorGUI.GetPropertyHeight(t.list.serializedProperty.GetArrayElementAtIndex(index));
            //};

            t.list.drawHeaderCallback = (Rect rect) => {
                //EditorGUI.LabelField(rect, "Dialog");
                Rect rectLabel = new Rect(rect.x, rect.y, rect.width / 2f, rect.height);
                Rect rectPlayOnce = new Rect(rect.x + rect.width / 2f, rect.y, rect.width / 2, rect.height);

                EditorGUI.indentLevel++;
                t.list.serializedProperty.isExpanded = EditorGUI.Foldout(rectLabel, t.list.serializedProperty.isExpanded, "Dialog");
                EditorGUI.indentLevel--;

                var playOnceLabel = new GUIContent(t.propPlayOnce.displayName);
                EditorGUI.BeginProperty(rectPlayOnce, playOnceLabel, t.propPlayOnce);
                //EditorGUI.PropertyField(rectPlayOnce, t.propPlayOnce);
                t.propPlayOnce.boolValue = EditorGUI.ToggleLeft(rectPlayOnce, playOnceLabel, t.propPlayOnce.boolValue);
                EditorGUI.EndProperty();

                t.list.draggable =
                t.list.displayAdd =
                t.list.displayRemove = t.list.serializedProperty.isExpanded;

                t.list.elementHeight = t.list.serializedProperty.isExpanded ? (t.list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
            };

            t.list.onAddCallback = (ReorderableList list) => {
                var prop = list.serializedProperty;
                int index = prop.arraySize;

                prop.InsertArrayElementAtIndex(index);

                // Reset the values
                var sub = prop.GetArrayElementAtIndex(index);
                sub.FindPropertyRelative("text").stringValue = string.Empty;
                sub.FindPropertyRelative("turnHead").boolValue = false;
            };

            t.list.onRemoveCallback = (ReorderableList list) => {
                if (list.count > 0) {
                    list.serializedProperty.DeleteArrayElementAtIndex(list.index >= 0 ? list.index : list.count - 1);
                    list.elementHeight = list.serializedProperty.isExpanded ? (list.count == 0 ? EditorGUIUtility.singleLineHeight : 64) : 0;
                }
            };

            properties[path] = t;

        }
    }