Exemple #1
0
    /// <summary>
    /// Creates a new SetNamedColor based on the specified input text.
    /// </summary>
    /// <param name="input">The input text to get a match for. For example, "a.color = red".</param>
    /// <returns>Returns the new SetNamedColor, or null if a no matches were found for the specified input.</returns>
    public static SetNamedColor Create(string input)
    {
        const string pattern = @"^(?<vectorName>\w+).color\s*=\s*(?<colorName>\w+)$";

        Regex           regex   = new Regex(pattern);
        MatchCollection matches = regex.Matches(input);

        if (matches.Count == 0)
        {
            return(null);
        }

        SetNamedColor setNamedColor = new SetNamedColor();

        setNamedColor.vectorName = RegexHelper.GetValue <string>(matches, "vectorName");
        setNamedColor.colorName  = RegexHelper.GetValue <string>(matches, "colorName");
        return(setNamedColor);
    }
Exemple #2
0
    private void ExecuteCommandLine(string text)
    {
        SuperVector superVector = SuperVector.Create(text);

        if (superVector != null)
        {
            CreateOrUpdateSuperVector(superVector);
            return;
        }

        SetColor setColor = SetColor.Create(text);

        if (setColor != null)
        {
            ChangeVectorColor(setColor.vectorName, setColor.hexCode);
            return;
        }

        SetNamedColor setNamedColor = SetNamedColor.Create(text);

        if (setNamedColor != null)
        {
            string hexCode;
            if (colorLookups.ContainsKey(setNamedColor.colorName))
            {
                hexCode = colorLookups[setNamedColor.colorName];
                ChangeVectorColor(setNamedColor.vectorName, hexCode);
            }
            else
            {
                Debug.LogError($"\"{setNamedColor.colorName}\" needs to be defined first!!!");
            }
            return;
        }

        DefineColor defineColor = DefineColor.Create(text);

        if (defineColor != null)
        {
            DefineColorName(defineColor.colorName, defineColor.hexCode);
            return;
        }

        MoveVector moveVector = MoveVector.Create(text);

        if (moveVector != null)
        {
            MoveVectorTo(moveVector.vector1, moveVector.vector2);
            return;
        }

        SumVectors sumVectors = SumVectors.Create(text);

        if (sumVectors != null)
        {
            SumAllVectors(sumVectors.newVectorName, sumVectors.vector1, sumVectors.vector2, sumVectors.vector3, sumVectors.vector4, sumVectors.vector5);
            return;
        }

        NegativeVector negativeVector = NegativeVector.Create(text);

        if (negativeVector != null)
        {
            MakeVectorNegative(negativeVector.vectorName);
            return;
        }

        AssignNegativeVector assignNegativeVector = AssignNegativeVector.Create(text);

        if (assignNegativeVector != null)
        {
            CreateNegativeVector(assignNegativeVector.existingVectorName, assignNegativeVector.newVectorName);
            return;
        }

        VectorCommand vectorCommand = VectorCommand.Create(text);

        if (vectorCommand != null)
        {
            HandleVectorCommand(vectorCommand.command, vectorCommand.vectorName);
            return;
        }
        OffsetVector offsetVector = OffsetVector.Create(text);

        if (offsetVector != null)
        {
            OffsetVectorBy(offsetVector.vectorName, offsetVector.offsetX, offsetVector.offsetY, offsetVector.offsetZ);
            return;
        }
    }