コード例 #1
0
    void Spawn()
    {
        if (nodes.Length <= 0)
        {
            Debug.LogWarning("There's no nodes!");
            return;
        }
        int nodeIndex = nodeRand.Range(0, nodes.Length - 1, true);

        while (nodeList.Contains(nodeIndex))
        {
            nodeIndex = nodeRand.Range(0, nodes.Length - 1, true);
        }
        nodeList.Add(nodeIndex);
        if (nodeList.Count >= nodes.Length - 1)
        {
            nodeList.RemoveAt(0);
        }

        int instIndex = timeRand.Range(0, instructionLines.Length - 1, true);

        List <string> parameters  = instructionLines[instIndex].Clone <List <string> >();
        int           randomValue = values[Random.Range(0, values.Length - 1)];

        parameters[0] = parameters[0].Replace("%v", randomValue + "");

        Instruction newDude = InstructionFactory.createInstruction(instructionText[instIndex], 1, 1, gameObject, parameters);

        newDude.GetComponent <GameText>().invulnerable = true;
        newDude.transform.position = nodes[nodeIndex].transform.position;
        newDude.AddComponent <InstructionCrawl>();

        generatorTimer = GetNewTime();
    }
コード例 #2
0
    static void addCompileSpotMethod(Instruction instruction, ParameterReader parameterReader)
    {
        string method        = parameterReader.readWord();
        string methodLowered = method.ToLower();

        if (methodLowered.Equals("debuglog"))
        {
            DebugLog dl = instruction.AddComponent <DebugLog>();
            dl.textToLog = parameterReader.readString();
            instruction.observers.Add(dl);
        }
        else if (methodLowered.Equals("compile"))
        {
        }
        else if (methodLowered.Equals("dropspikes"))
        {
            DropSpikes ds = instruction.AddComponent <DropSpikes>();
            if (parameterReader.nextWordContains("%"))
            {
                int childIndex = parameterReader.readIndexPosition();
                ds.nbSpikesToDropParameter = instruction.GetChild(childIndex).GetComponent <IntegerParameter>();
                if (ds.nbSpikesToDropParameter == null)
                {
                    log("Instruction doesnt not contain a IntegerParameter at index " + childIndex);
                }
            }
            else
            {
                ds.nbSpikesToDrop = parameterReader.readInt();
            }

            ds.timeBetweenCallMin    = parameterReader.readFloat();
            ds.timeBetweenCallMax    = parameterReader.readFloat();
            ds.spawningOrderAlgoName = parameterReader.readWord();
            instruction.observers.Add(ds);
        }
        else
        {
            Debug.LogError("MAPLOADER - ERROR : Unknown Function type for compile spot " + method);
        }
    }