Exemple #1
0
        /**
         * <summary>Copies the value of another variable onto itself.</summary>
         * <param name = "oldVar">The variable to copy from</param>
         * <param name = "oldLocation">The location of the variable to copy (Global, Local)</param>
         */
        public void CopyFromVariable(GVar oldVar, VariableLocation oldLocation)
        {
            if (oldLocation == VariableLocation.Global)
            {
                oldVar.Download();
            }

            if (type == VariableType.Integer || type == VariableType.Boolean || type == VariableType.PopUp)
            {
                int oldValue = oldVar.val;

                if (oldVar.type == VariableType.Float)
                {
                    oldValue = (int)oldVar.floatVal;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float oldValueAsFloat = 0f;
                    float.TryParse(oldVar.textVal, out oldValueAsFloat);
                    oldValue = (int)oldValueAsFloat;
                }

                if (type == VariableType.PopUp && oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }

                SetValue(oldValue, SetVarMethod.SetValue);
            }
            else if (type == VariableType.Float)
            {
                float oldValue = oldVar.floatVal;

                if (oldVar.type == VariableType.Integer || oldVar.type == VariableType.Boolean || oldVar.type == VariableType.PopUp)
                {
                    oldValue = (float)oldVar.val;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float.TryParse(oldVar.textVal, out oldValue);
                }

                SetFloatValue(oldValue, AC.SetVarMethod.SetValue);
            }
            else if (type == VariableType.String)
            {
                string oldValue = oldVar.GetValue();
                textVal = oldValue;

                if (oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }
            }
            else if (type == VariableType.Vector3)
            {
                Vector3 oldValue = oldVar.vector3Val;
                vector3Val = oldValue;
            }
        }
Exemple #2
0
        /**
         * <summary>Copies the value of another variable onto itself.</summary>
         * <param name = "oldVar">The variable to copy from</param>
         * <param name = "oldLocation">The location of the variable to copy (Global, Local)</param>
         */
        public void CopyFromVariable(GVar oldVar, VariableLocation oldLocation)
        {
            if (oldLocation == VariableLocation.Global)
            {
                oldVar.Download(oldLocation);
            }

            switch (type)
            {
            case VariableType.Float:
            {
                float oldValue = oldVar.FloatValue;

                if (oldVar.type == VariableType.Integer || oldVar.type == VariableType.Boolean || oldVar.type == VariableType.PopUp)
                {
                    oldValue = (float)oldVar.IntegerValue;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float.TryParse(oldVar.textVal, out oldValue);
                }

                FloatValue = oldValue;
                break;
            }

            case VariableType.String:
            {
                string oldValue = oldVar.GetValue();
                textVal = oldValue;

                if (oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }
                break;
            }

            case VariableType.Vector3:
            {
                Vector3 oldValue = oldVar.vector3Val;
                Vector3Value = oldValue;
                break;
            }

            default:
            {
                int oldValue = oldVar.val;

                if (oldVar.type == VariableType.Float)
                {
                    oldValue = (int)oldVar.floatVal;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float oldValueAsFloat = 0f;
                    float.TryParse(oldVar.textVal, out oldValueAsFloat);
                    oldValue = (int)oldValueAsFloat;
                }

                if (type == VariableType.PopUp && oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }

                IntegerValue = oldValue;
                break;
            }
            }
        }