Exemplo n.º 1
0
    static void addCharacterSpecifiqueFeature(LevelReferences levelReferences, GameObject go, string character, string paramData, GameObject parent)
    {
        string[] param = paramData.TrimEnd(new char[] { '\n', '\r' }).Split(' ');
        string   arg   = param[1];

        if (arg.ToLower().Equals("isaspike"))
        {
            var spikeManager = go.AddComponent <SpikeManager>();
            int spawnDelay   = int.Parse(param[2]);
            spikeManager.spawnMinDelay = spawnDelay;
            spikeManager.spawnMaxDelay = spawnDelay * 4;

            levelReferences.spikeManagers.Add(spikeManager);
        }
        else if (arg.ToLower().Equals("isaspawner"))
        {
            go.AddComponent <InstructionSpawner>();
        }
        else if (arg.ToLower().Equals("compiles"))
        {
            go.AddComponent <CompileSemiColon>();
            Rigidbody2D rb = go.AddComponent <Rigidbody2D>();
            rb.gravityScale = 0;
            rb.isKinematic  = true;
        }
    }
Exemplo n.º 2
0
    public static GameObject createSpecialCharacter(LevelReferences levelReferences, GameObject parent, string character, string param, int x, float y)
    {
        GameObject go = GameObjectFactory.createGameObject(character, parent);

        go.layer = LayerMask.NameToLayer("Ignore Raycast");
        go.transform.Translate(x, y, 0);

        TextMesh tm = go.AddComponent <TextMesh>();

        TextCollider2D tc = go.AddComponent <TextCollider2D> ();

        tc.TextMesh = tm;
        tc.Text     = character;
        tc.Font     = GameConstantes.instance.currentTheme.instructionFont;

        addCharacterSpecifiqueFeature(levelReferences, go, character, param, parent);

        return(go);
    }
Exemplo n.º 3
0
    public void load(string mapText, GameObject world)
    {
        this.parameterReaders           = new Dictionary <string, ParameterReader>();
        this.instructions               = GameObjectFactory.createGameObject("Instruction", world);
        this.levelCharacters            = GameObjectFactory.createGameObject("Level Character", world);
        this.specialCharacter           = new Dictionary <string, string>();
        this.specialCharacterGameObject = new Dictionary <string, GameObject>();
        this.world           = world;
        this.levelReferences = world.GetComponent <LevelReferences>();
        this.fileLine        = 0;

        string[] lines = mapText.Split(new char[] { '\n' });
        foreach (var line in lines)
        {
            fileLine++;
            if (line.StartsWith("<"))
            {
                changeReadingMod(line);
            }
            else
            {
                switch (readingMod)
                {
                case ReadingMod.PARAM: readParam(line);
                    break;

                case ReadingMod.LEVEL: readLevelLine(line + " ");
                    break;

                case ReadingMod.SPECIAL_CHARACTER: readSpecialCharacter(line);
                    break;

                case ReadingMod.CONFIG: readConfig(line);
                    break;
                }
            }
        }
    }
Exemplo n.º 4
0
 void Awake()
 {
     LevelReferences.instance = this;
 }