Example #1
0
    private void CreateSpellInstances()
    {
        Array <Spatial> projectileList;
        string          currentType;
        Spatial         container;
        Spatial         projectile = null;

        SCG.IEnumerator <PackedScene> it = projectilePrefabList.GetEnumerator();
        int index = 0;
        int amount;

        while (it.MoveNext())
        {
            projectileList = new Array <Spatial>();
            container      = GetChild <Spatial>(index);
            amount         = projectileAmountList[index++];

            for (int i = 0; i < amount; i++)
            {
                projectile             = it.Current.Instance() as Spatial;
                projectile.Translation = inactiveTranslation;
                projectile.Name        = this.CreateUniqueNodeName(projectile);
                projectile.Call(this.GetMethodSetManager(), this);
                projectileList.Add(projectile);
                container.CallDeferred(this.GetGDMethodAddChild(), projectile);
            }

            if (amount > 0)
            {
                currentType = this.Call <string>(projectile, this.GetMethodGetNodeType());
                availableProjectileMap.Add(currentType, projectileList);
            }
        }
    }
Example #2
0
    public void RequestResources()
    {
        if (nodeRenderScenePathList != null)
        {
            SCG.IEnumerator <string> it = nodeRenderScenePathList.GetEnumerator();
            PackedScene ps;
            Spatial     s;
            string      instanceId;
            int         index = 0;

            while (it.MoveNext())
            {
                ps         = ResourceLoader.Load <PackedScene>(it.Current);
                s          = ps.Instance() as Spatial;
                instanceId = s.GetInstanceId().ToString();
                nodeRenderSceneMap.Add(instanceId, s);
                nodeRenderIdsList.Add(index++, instanceId);

                if (OS.IsDebugBuild())
                {
                    GD.PushWarning("RequestFinished: " + s.Name);
                }
            }

            if (OS.IsDebugBuild())
            {
                GD.PushWarning("All Resources requests finished!");
            }
        }
    }
Example #3
0
    private void CreateLaserDeviceInstances()
    {
        Array <Spatial> laserDeviceList;
        string          currentType;
        Spatial         container;
        Spatial         laserDevice = null;

        SCG.IEnumerator <PackedScene> it = laserDevicePSList.GetEnumerator();
        int index       = 0;
        int finalAmount = laserDeviceAmount * specialistAmount;

        while (it.MoveNext())
        {
            laserDeviceList = new Array <Spatial>();
            container       = GetChild <Spatial>(index++);

            for (int i = 0; i < finalAmount; i++)
            {
                laserDevice             = it.Current.Instance() as Spatial;
                laserDevice.Translation = inactiveTranslation;
                laserDevice.Name        = this.CreateUniqueNodeName(laserDevice);
                laserDevice.Call(this.GetMethodSetManager(), this);
                container.CallDeferred(this.GetGDMethodAddChild(), laserDevice);
                laserDeviceList.Add(laserDevice);
            }

            currentType = this.Call <string>(laserDevice, this.GetMethodGetNodeType());
            availableLaserDeviceMap.Add(currentType, laserDeviceList);
        }
    }
Example #4
0
 public void Init()
 {
     dict      = new TreeDictionary <string, string>(new SC());
     dict["S"] = "A";
     dict["T"] = "B";
     dict["R"] = "C";
     dictenum  = dict.GetEnumerator();
 }
Example #5
0
    private void ComputeActionInputUnionMask()
    {
        SCG.IEnumerator <int> it = actionInputBufferList.GetEnumerator();
        actionInputUnionMask = PLANT_DEVICE_MASK | CHANGE_SLOT_MASK | EXECUTE_SKILL_MASK;

        while (it.MoveNext())
        {
            actionInputUnionMask &= it.Current;
        }
    }
Example #6
0
            public void DoDispose()
            {
                hashset.Add(5);
                hashset.Add(8);
                hashset.Add(5);

                SCG.IEnumerator <int> e = hashset.GetEnumerator();

                e.MoveNext();
                e.MoveNext();
                e.Dispose();
            }
Example #7
0
            public void MoveNextAfterUpdate()
            {
                hashset.Add(5);
                hashset.Add(8);
                hashset.Add(5);

                SCG.IEnumerator <int> e = hashset.GetEnumerator();

                e.MoveNext();
                hashset.Add(99);
                e.MoveNext();
            }
Example #8
0
 public void KeysEnumerator()
 {
     SCG.IEnumerator <string> keys = dict.Keys.GetEnumerator();
     Assert.AreEqual(3, dict.Keys.Count);
     Assert.IsTrue(keys.MoveNext());
     Assert.AreEqual("R", keys.Current);
     Assert.IsTrue(keys.MoveNext());
     Assert.AreEqual("S", keys.Current);
     Assert.IsTrue(keys.MoveNext());
     Assert.AreEqual("T", keys.Current);
     Assert.IsFalse(keys.MoveNext());
 }
Example #9
0
 public void ValuesEnumerator()
 {
     SCG.IEnumerator <string> values = dict.Values.GetEnumerator();
     Assert.AreEqual(3, dict.Values.Count);
     Assert.IsTrue(values.MoveNext());
     Assert.AreEqual("C", values.Current);
     Assert.IsTrue(values.MoveNext());
     Assert.AreEqual("A", values.Current);
     Assert.IsTrue(values.MoveNext());
     Assert.AreEqual("B", values.Current);
     Assert.IsFalse(values.MoveNext());
 }
Example #10
0
            public void MoveNextAfterUpdate()
            {
                hashset.Add(5);
                hashset.Add(8);
                hashset.Add(5);

                SCG.IEnumerator <int> e = hashset.GetEnumerator();

                e.MoveNext();
                hashset.Add(99);

                Assert.Throws <CollectionModifiedException>(() => e.MoveNext());
            }
Example #11
0
        /// <summary>
        /// Fills states 0 up to other.size with other's states.
        /// </summary>
        /// <param name="other"></param>
        public void FillStates(NFA other)
        {
            for (state i = 0; i < other.size; ++i)
            {
                for (state j = 0; j < other.size; ++j)
                {
                    transTable[i][j] = other.transTable[i][j];
                }
            }

            SCG.IEnumerator <input> cE = other.inputs.GetEnumerator();

            while (cE.MoveNext())
            {
                inputs.Add(cE.Current);
            }
        }
Example #12
0
    public static Array ConvertToDefaultArray <T>(
        this Godot.Object gdobj, Array <T> array)
    {
        Array defaultArray = new Array();

        if (defaultArray != null)
        {
            SCG.IEnumerator <T> it = array.GetEnumerator();

            while (it.MoveNext())
            {
                defaultArray.Add(it.Current);
            }
        }

        return(defaultArray);
    }
Example #13
0
    private void UpdateLabels()
    {
        SCG.IEnumerator <string> it = gameplayKeyList.GetEnumerator();
        int index = 0;

        while (it.MoveNext())
        {
            if (lastGameplayDataMap.Contains(it.Current))
            {
                labels[index++].Text = GetFixedLabelText(it.Current);
            }
        }

        for (int i = index; i < labels.Length; i++)
        {
            labels[i].Text = "";
        }
    }
Example #14
0
        public void Show()
        {
            Console.Write("DFA start state: {0}\n", start);
            Console.Write("DFA final state(s): ");

            SCG.IEnumerator <state> iE = final.GetEnumerator();

            while (iE.MoveNext())
            {
                Console.Write(iE.Current + " ");
            }

            Console.Write("\n\n");

            foreach (SCG.KeyValuePair <KeyValuePair <state, input>, state> kvp in transTable)
            {
                Console.Write("Trans[{0}, {1}] = {2}\n", kvp.Key.Key, kvp.Key.Value, kvp.Value);
            }
        }
Example #15
0
        protected static int countItems(SCG.IEnumerable <T> items)
        {
            ICollectionValue <T> jtems = items as ICollectionValue <T>;

            if (jtems != null)
            {
                return(jtems.Count);
            }

            int count = 0;

            using (SCG.IEnumerator <T> e = items.GetEnumerator())
                while (e.MoveNext())
                {
                    count++;
                }

            return(count);
        }
Example #16
0
        public void IList_Generic_CurrentAtEnd_AfterAdd(int count)
        {
            if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
            {
                SCG.IList <T> collection = GenericIListFactory(count);

                using (SCG.IEnumerator <T> enumerator = collection.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ;                           // Go to end of enumerator
                    }
                    T current = default(T);
                    if (Enumerator_Current_UndefinedOperation_Throws)
                    {
                        Assert.Throws <InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail
                    }
                    else
                    {
                        current = enumerator.Current;
                        Assert.Equal(default(T), current);
                    }

                    // Test after add
                    int seed = 3538963;
                    for (int i = 0; i < 3; i++)
                    {
                        collection.Add(CreateT(seed++));

                        if (Enumerator_Current_UndefinedOperation_Throws)
                        {
                            Assert.Throws <InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail
                        }
                        else
                        {
                            current = enumerator.Current;
                            Assert.Equal(default(T), current);
                        }
                    }
                }
            }
        }
Example #17
0
    public static Array <T> GetNodeList <T>(this Node gdNode,
                                            Node caller, Array <NodePath> nodePathList) where T : Godot.Object
    {
        Array <T> nodeList = new Array <T>();

        if (nodePathList != null)
        {
            SCG.IEnumerator <NodePath> it = nodePathList.GetEnumerator();

            while (it.MoveNext())
            {
                nodeList.Add(caller.GetNode <T>(it.Current));
            }
        }
        else
        {
            GD.PushWarning("NodePathList called by '" + caller.Name + "' is null");
        }

        return(nodeList);
    }
Example #18
0
    private void UpdateRankingLabels(int index)
    {
        string indexText = index.ToString();

        if (rankingMap.Contains(indexText))
        {
            rankingControls[index].Visible = true;
            Label[]    labels           = labelsMap[index];
            Dictionary dataMap          = rankingMap[indexText] as Dictionary;
            SCG.IEnumerator <string> it = rankingKeyList.GetEnumerator();
            int labelIndex = 0;

            while (it.MoveNext())
            {
                labels[labelIndex++].Text = GetFixedLabelText(dataMap, it.Current);
            }
        }
        else
        {
            rankingControls[index].Visible = false;
        }
    }
Example #19
0
    public static T[] GetNodes <T>(this Node gdNode,
                                   Node caller, Array <NodePath> nodePathList) where T : Godot.Object
    {
        if (nodePathList != null)
        {
            int index = 0;
            T[] nodes = new T[nodePathList.Count];
            SCG.IEnumerator <NodePath> it = nodePathList.GetEnumerator();

            while (it.MoveNext())
            {
                nodes[index++] = caller.GetNode <T>(it.Current);
            }

            return(nodes);
        }
        else
        {
            GD.PushWarning("NodePathList called by '" + caller.Name + "' is null");
        }

        return(new T[0]);
    }
Example #20
0
    private void LoadResources()
    {
        if (resourcePathList != null)
        {
            int      index;
            string[] split;
            SCG.IEnumerator <string> it = resourcePathList.GetEnumerator();

            while (it.MoveNext())
            {
                split = it.Current.Split("/");
                index = split.Length - 1;
                Resource res = ResourceLoader.Load(it.Current);

                if (res != null)
                {
                    globalResource.Call(this.GetMethodPut(), split[index].Split(".")[0], res);
                }
            }
        }

        loaded = true;
    }
Example #21
0
        /// <summary>
        /// Subset machine that employs the powerset construction or subset construction algorithm.
        /// It creates a DFA that recognizes the same language as the given NFA.
        /// </summary>
        public static DFA SubsetConstruct(NFA nfa)
        {
            DFA dfa = new DFA();

            // Sets of NFA states which is represented by some DFA state
            Set <Set <state> > markedStates   = new Set <Set <state> >();
            Set <Set <state> > unmarkedStates = new Set <Set <state> >();

            // Gives a number to each state in the DFA
            HashDictionary <Set <state>, state> dfaStateNum = new HashDictionary <Set <state>, state>();

            Set <state> nfaInitial = new Set <state>();

            nfaInitial.Add(nfa.initial);

            // Initially, EpsilonClosure(nfa.initial) is the only state in the DFAs states
            // and it's unmarked.
            Set <state> first = EpsilonClosure(nfa, nfaInitial);

            unmarkedStates.Add(first);

            // The initial dfa state
            state dfaInitial = GenNewState();

            dfaStateNum[first] = dfaInitial;
            dfa.start          = dfaInitial;

            while (unmarkedStates.Count != 0)
            {
                // Takes out one unmarked state and posteriorly mark it.
                Set <state> aState = unmarkedStates.Choose();

                // Removes from the unmarked set.
                unmarkedStates.Remove(aState);

                // Inserts into the marked set.
                markedStates.Add(aState);

                // If this state contains the NFA's final state, add it to the DFA's set of
                // final states.
                if (aState.Contains(nfa.final))
                {
                    dfa.final.Add(dfaStateNum[aState]);
                }

                SCG.IEnumerator <input> iE = nfa.inputs.GetEnumerator();

                // For each input symbol the NFA knows...
                while (iE.MoveNext())
                {
                    // Next state
                    Set <state> next = EpsilonClosure(nfa, nfa.Move(aState, iE.Current));

                    // If we haven't examined this state before, add it to the unmarkedStates,
                    // and make up a new number for it.
                    if (!unmarkedStates.Contains(next) && !markedStates.Contains(next))
                    {
                        unmarkedStates.Add(next);
                        dfaStateNum.Add(next, GenNewState());
                    }

                    KeyValuePair <state, input> transition = new KeyValuePair <state, input>();
                    transition.Key   = dfaStateNum[aState];
                    transition.Value = iE.Current;

                    dfa.transTable[transition] = dfaStateNum[next];
                }
            }

            return(dfa);
        }
Example #22
0
 public void Dispose()
 {
     dictenum = null;
     dict     = null;
 }
Example #23
0
            public void Empty()
            {
                SCG.IEnumerator <int> e = hashset.GetEnumerator();

                Assert.IsFalse(e.MoveNext());
            }