Esempio n. 1
0
    public void insert(Parser.Integer index, Parser.Variable value)
    {
        list.insertValue(value, index);
        float time_animation = 2f;

        GameObject[] obj_list = new GameObject[list.length().getValue() - index.getValue() - 1];
        for (int i = index.getValue() + 1, u = 0; i < list.length().getValue(); i++, u++)
        {
            obj_list[u] = list_dict[list.atIndex(new Parser.Integer(i)).getName()];
        }

        StartCoroutine(Animation.insertAnimation(obj_list, value.getName(), new Vector3(1, 0, 0), time_animation, 1, this));
    }
Esempio n. 2
0
    public void remove(Parser.Integer index)
    {
        string name           = list.atIndex(index).getName();
        float  time_animation = 3f;

        Destroy(list_dict[name], time_animation / 2f);
        list.removeValue(index);

        GameObject[] obj_list = new GameObject[list.length().getValue() - index.getValue()];
        for (int i = index.getValue(), u = 0; i < list.length().getValue(); i++, u++)
        {
            obj_list[u] = list_dict[list.atIndex(new Parser.Integer(i)).getName()];
        }

        StartCoroutine(Animation.removeAnimation(obj_list, name, new Vector3(-1, 0, 0), time_animation, 0, this));
    }
Esempio n. 3
0
        /// <summary>
        /// Append a value to the end of a list
        /// </summary>
        /// <param name="list_expr"> The list</param>
        /// <param name="value_expr"> The value</param>
        /// <returns> <see cref="NullVar"/> (equivalent of null/void)</returns>
        private static NullVar appendValue(Expression list_expr, Expression value_expr)
        {
            // extract list
            Variable list_var = list_expr.evaluate();

            Debugging.assert(list_var is DynamicList); // TypeError
            DynamicList list = list_var as DynamicList;
            // index
            Integer    index      = list.length();
            Expression index_expr = new Expression(index.getValue().ToString()); // this should definitely be ok

            // insert
            return(insertValueAt(list_expr, index_expr, value_expr));
        }
Esempio n. 4
0
        public Variable atIndex(Integer index)
        {
            assertAssignment();
            int i = index.getValue();

            if (i < 0)
            {
                i += _list.Count;
            }
            if (i < 0)
            {
                throw new AquilaExceptions.InvalidIndexException($"Index {index} out of bounds");
            }
            return(_list.ElementAt(i));
        }
Esempio n. 5
0
        public Integer modulo(Integer other)
        {
            assertAssignment();
            int int_result = numeric_value % other.getValue();
            // source variables
            var source_variables = new Dictionary <string, NumericalValue>();

            if (!string.IsNullOrEmpty(getName()))
            {
                source_variables.Add(getName(), this);
            }
            if (!string.IsNullOrEmpty(other.getName()) && other.getName() != getName())
            {
                source_variables.Add(other.getName(), other);
            }
            source_variables = mergeDictionaries(source_variables, other.source_vars);
            return(new Integer(int_result, is_const && other.is_const, source_variables));
        }
Esempio n. 6
0
        public void removeValue(Integer index)
        {
            assertAssignment();
            int i = index.getValue();

            if (i < 0)
            {
                i += _list.Count;        // if "-1" -> last element of the list
            }
            if (i < _list.Count)
            {
                _list.RemoveAt(i);
            }
            else
            {
                throw new AquilaExceptions.InvalidIndexException($"Index {index} out of bounds");
            }
            trace("removeValue", new dynamic[] { index.getRawValue() });
        }
Esempio n. 7
0
 public void insertValue(Variable x, Integer index)
 {
     assertAssignment();
     _list.Insert(index.getValue(), x);
     trace("insertValue", new dynamic[] { index.getRawValue(), x.getRawValue() });
 }
Esempio n. 8
0
        public Integer length() => assigned ? new Integer(_list.Count) : throw new AquilaExceptions.InvalidUsageException("Unassigned variable"); // AssignmentError

        public void validateIndex(Integer index)
        {
            assertAssignment();
            Debugging.assert(index.getValue() < _list.Count); // InvalidIndexException
        }