Ejemplo n.º 1
0
        private void InitWindows()
        {
            Rect previous = new Rect(0, 25, 0, 100);

            for (int i = 0; i < effects.getEffects().Count; i++)
            {
                AbstractEffect myEffect = this.effects.getEffects()[i];

                EffectEditor editor = EffectEditorFactory.Intance.createEffectEditorFor(myEffect);
                editor.Effect = myEffect;

                if (i > 0)
                {
                    previous = editors[effects.getEffects()[i - 1]].Window;
                }

                Rect current = new Rect(previous.x + previous.width + 35, previous.y, 150, 0);
                if (!tmpRects.ContainsKey(effects.getEffects()[i]))
                {
                    tmpRects.Add(effects.getEffects()[i], current);
                }

                editor.Window = current;

                editor.Effect.setConditions(myEffect.getConditions());
                editors.Add(editor.Effect, editor);
            }
        }
Ejemplo n.º 2
0
    /**
     * Adds a new effect to the list.
     *
     * @param effect
     *            the effect to be added
     */

    public void add(AbstractEffect effect)
    {
        effects.Add(effect);

        //Check if the effect has resources, to add it in the AllAssetsPaths
        if (effect.getType() == EffectType.PLAY_ANIMATION || effect.getType() == EffectType.PLAY_SOUND ||
            effect.getType() == EffectType.SPEAK_CHAR || effect.getType() == EffectType.SPEAK_PLAYER ||
            effect.getType() == EffectType.SHOW_TEXT)
        {
            AllElementsWithAssets.addAsset(effect);
        }
        else if (effect.getType() == EffectType.RANDOM_EFFECT)
        {
            if (((RandomEffect)effect).getPositiveEffect() != null)
            {
                EffectType peType = ((RandomEffect)effect).getPositiveEffect().getType();
                if (peType == EffectType.PLAY_ANIMATION || peType == EffectType.PLAY_SOUND ||
                    peType == EffectType.SPEAK_CHAR || peType == EffectType.SPEAK_PLAYER ||
                    peType == EffectType.SHOW_TEXT)
                {
                    AllElementsWithAssets.addAsset(((RandomEffect)effect).getPositiveEffect());
                }
            }
            if (((RandomEffect)effect).getNegativeEffect() != null)
            {
                EffectType neType = ((RandomEffect)effect).getNegativeEffect().getType();
                if (neType == EffectType.PLAY_ANIMATION || neType == EffectType.PLAY_SOUND ||
                    neType == EffectType.SPEAK_CHAR || neType == EffectType.SPEAK_PLAYER ||
                    neType == EffectType.SHOW_TEXT)
                {
                    AllElementsWithAssets.addAsset(((RandomEffect)effect).getNegativeEffect());
                }
            }
        }
    }
Ejemplo n.º 3
0
    /**
     * Adds a new effect to the list.
     *
     * @param effect
     *            the effect to be added
     */
    public void add(AbstractEffect effect)
    {
        effects.Add(effect);

        //Check if the effect has resources, to add it in the AllAssetsPaths
        if (effect.getType() == EffectType.PLAY_ANIMATION || effect.getType() == EffectType.PLAY_SOUND ||
            effect.getType() == EffectType.SPEAK_CHAR || effect.getType() == EffectType.SPEAK_PLAYER ||
            effect.getType() == EffectType.SHOW_TEXT)
        {
            AllElementsWithAssets.addAsset(effect);
        }
        else if (effect.getType() == EffectType.RANDOM_EFFECT)
        {
            if (((RandomEffect) effect).getPositiveEffect() != null)
            {
                EffectType peType = ((RandomEffect) effect).getPositiveEffect().getType();
                if (peType == EffectType.PLAY_ANIMATION || peType == EffectType.PLAY_SOUND ||
                    peType == EffectType.SPEAK_CHAR || peType == EffectType.SPEAK_PLAYER ||
                    peType == EffectType.SHOW_TEXT)
                {
                    AllElementsWithAssets.addAsset(((RandomEffect) effect).getPositiveEffect());
                }
            }
            if (((RandomEffect) effect).getNegativeEffect() != null)
            {
                EffectType neType = ((RandomEffect) effect).getNegativeEffect().getType();
                if (neType == EffectType.PLAY_ANIMATION || neType == EffectType.PLAY_SOUND ||
                    neType == EffectType.SPEAK_CHAR || neType == EffectType.SPEAK_PLAYER ||
                    neType == EffectType.SHOW_TEXT)
                {
                    AllElementsWithAssets.addAsset(((RandomEffect) effect).getNegativeEffect());
                }
            }
        }
    }
Ejemplo n.º 4
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            // Rapid Fire
            if (VotingMode == 2)
            {
                if (rapidFireVoters.Contains(username))
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(message, Config.Instance().TwitchAllowOnlyEnabledEffectsRapidFire);
                if (effect == null || !effect.IsRapidFire())
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                rapidFireVoters.Add(username);

                return;
            }
        }
Ejemplo n.º 5
0
 public void SetVoting(bool isVoting, int duration, string durationText, AbstractEffect enabledEffect = null, string username = null)
 {
     IsVoting = isVoting;
     if (IsVoting)
     {
         SendMessage($"Voting has started! [{durationText}] [D:{duration}]");
         effectVoting.Clear();
     }
     else
     {
         if (enabledEffect != null)
         {
             string effectText = enabledEffect.GetDescription();
             if (!string.IsNullOrEmpty(enabledEffect.Word))
             {
                 effectText = $"{ enabledEffect.Word} ({ enabledEffect.GetDescription() })";
             }
             SendMessage($"Cooldown has started! [{durationText}] [D:{duration}] - Enabled effect [ID:{enabledEffect.Id}]: {effectText} voted by {(username ?? "GTA:SA Chaos")}");
         }
         else
         {
             SendMessage($"Cooldown has started! [{durationText}] [D:{duration}]");
         }
     }
 }
Ejemplo n.º 6
0
    public virtual object Clone()
    {
        AbstractEffect absEf = (AbstractEffect)this.MemberwiseClone();

        absEf.conditions = (Conditions)conditions.Clone();
        return(absEf);
    }
    private void AddEffect()
    {
        if (m_effectsList == null)
        {
            return;
        }

        //init effect list & fetch effect based on selected index
        if (m_ActiveEffects == null)
        {
            m_ActiveEffects = new List <SerializedObject>();
        }
        AbstractEffect currentEffect = m_effectsList[m_selectedEffectIndex];

        //init serialized object list & add new serialized object
        if (m_serializedObjects == null)
        {
            m_serializedObjects = new List <SerializedObject>();
        }
        SerializedObject currentSObj = new SerializedObject(currentEffect);

        m_serializedObjects.Add(currentSObj);
        m_ActiveEffects.Add(currentSObj);

        //Store serialized object & effect in a dictionary
        if (m_SerializedObject_effectMap == null)
        {
            m_SerializedObject_effectMap = new Dictionary <SerializedObject, AbstractEffect>();
        }
        m_SerializedObject_effectMap.Add(currentSObj, currentEffect);

        //store properties in a dictionary, also set execution order
        if (m_indexProperty_map == null)
        {
            m_indexProperty_map = new Dictionary <int, List <SerializedProperty> >();
        }

        FieldInfo[] fieldInfo;
        fieldInfo = currentEffect.GetType().GetFields();
        List <SerializedProperty> tempList = new List <SerializedProperty>();

        foreach (FieldInfo info in fieldInfo)
        {
            SerializedProperty tempProperty = currentSObj.FindProperty(info.Name);
            if (info.Name == "ExecutionOrder")
            {
                tempProperty.intValue = m_executionOrder;
            }
            if (info.Name == "ID")
            {
                tempProperty.intValue = m_executionOrder;
            }
            tempList.Add(tempProperty);
        }
        currentSObj.ApplyModifiedProperties();
        m_indexProperty_map.Add(m_executionOrder, tempList);

        m_executionOrder++;
    }
Ejemplo n.º 8
0
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public override void OnLoad()
 {
     base.OnLoad();
     OnLoadEffect = new EffectShow(this);
     //if (OnLoadEffect.Thread.IsAlive) OnLoadEffect.Thread.Abort();
     Console.WriteLine(OnLoadEffect.Thread.ThreadState);
     OnLoadEffect.Thread.Start();
 }
Ejemplo n.º 9
0
 public static AbstractEffect RunEffect(AbstractEffect effect, int seed = -1, int duration = -1)
 {
     if (effect != null)
     {
         effect.RunEffect(seed, duration);
     }
     return(effect);
 }
Ejemplo n.º 10
0
 public ReplaceEffectTool(Effects effects, AbstractEffect effect, Dictionary <int, System.Object> newProperties, AbstractEffect pos, AbstractEffect neg)
 {
     this.effects       = effects;
     this.effect        = effect;
     this.pos           = pos;
     this.neg           = neg;
     this.newProperties = newProperties;
 }
Ejemplo n.º 11
0
 public static AbstractEffect RunEffect(AbstractEffect effect)
 {
     if (effect != null)
     {
         effect.RunEffect();
     }
     return(effect);
 }
Ejemplo n.º 12
0
 public virtual void OnEffectsChanged(AbstractEffect changedEffect)
 {
     if (m_changesCount > 0)
     {
         return;
     }
     UpdateChangedEffects();
 }
Ejemplo n.º 13
0
 public override bool doTool()
 {
     effectDeleted = effects.getEffects()[index];
     effects.getEffects().RemoveAt(index);
     condition = conditions[index];
     conditions.RemoveAt(index);
     updateVarFlagSummary((Effect)effectDeleted);
     return(true);
 }
Ejemplo n.º 14
0
    private static Effects createEffectsStructure(AbstractEffect effect)
    {
        Effects effects = new Effects();

        if (effect != null)
        {
            effects.add(effect);
        }
        return(effects);
    }
Ejemplo n.º 15
0
        public virtual bool Add(AbstractEffect effect)
        {
            lock (m_effects)
            {
                m_effects.Add(effect);
            }

            OnEffectsChanged(effect);

            return(true);
        }
Ejemplo n.º 16
0
 public RectangleChecker(Game game, Tint colorTint)
     : base(game, 0.2f, 1.0f, 1.0f)
 {
     this.colorTint = colorTint;
     cam            = (GameCamera)game.Services.GetService(typeof(BasicCamera));
     textureLibrary = (TexturesLibrary)game.Services.GetService(typeof(TexturesLibrary));
     checkerEffect  = new PhongEffect(game, colorTint);
     CheckerEffect.setOtherParams();
     LoadContent();
     generateChecker();
 }
Ejemplo n.º 17
0
		public virtual bool Add(AbstractEffect effect)
		{
			lock (m_effects)
			{
				m_effects.Add(effect);
			}

			OnEffectsChanged(effect);

			return true;
		}
Ejemplo n.º 18
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            if (Config.Instance().Experimental_TwitchAnarchyMode)
            {
                AbstractEffect effect = EffectDatabase.GetByWord(message);
                if (effect == null)
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                return;
            }
            else
            {
                if (VotingMode == 2)
                {
                    if (rapidFireVoters.Contains(username))
                    {
                        return;
                    }

                    AbstractEffect effect = EffectDatabase.GetByWord(message, Config.Instance().TwitchAllowOnlyEnabledEffectsRapidFire);
                    if (effect == null || !effect.IsRapidFire())
                    {
                        return;
                    }

                    RapidFireEffect(new RapidFireEventArgs()
                    {
                        Effect = effect.SetVoter(username)
                    });

                    rapidFireVoters.Add(username);

                    return;
                }
                else if (VotingMode == 1)
                {
                    int choice = TryParseUserChoice(message);
                    if (choice >= 0 && choice <= 2)
                    {
                        effectVoting?.TryAddVote(username, choice);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public override EffectEditor createEffectEditorFor(AbstractEffect effect)
        {
            foreach (EffectEditor effectEditor in effectEditors)
            {
                if (effectEditor.manages(effect))
                {
                    return(effectEditor.clone());
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
 void createWindow(AbstractEffect effect)
 {
     if (editors.ContainsKey(effect))
     {
         editors[effect].Window = GUILayout.Window(windowId, editors[effect].Window, nodeWindow,
                                                   effect.getType().ToString(), GUILayout.MinWidth(150));
     }
     else
     {
         tmpRects[effect] = GUILayout.Window(windowId, tmpRects[effect], nodeWindow, effect.getType().ToString(),
                                             GUILayout.MinWidth(150));
     }
 }
Ejemplo n.º 21
0
        private void CallEffect(AbstractEffect effect = null)
        {
            if (effect == null)
            {
                effect = EffectDatabase.RunEffect(EffectDatabase.GetRandomEffect(true));
            }
            else
            {
                EffectDatabase.RunEffect(effect);
            }

            AddEffectToListBox(effect);
        }
Ejemplo n.º 22
0
        public MainBorderTexture(Game game, float thickness, float width, float bwidth, float height)
            : base(game, thickness, width, bwidth, height)
        {
            cam = (GameCamera)game.Services.GetService(typeof(BasicCamera));
            //borderEffect = new ReliefMappingEffect(game, Tint.Light);
            //cornerEffect = new ReliefMappingEffect(game, Tint.Light);
            borderEffect = new PhongEffect(game, BorderType.Border);
            cornerEffect = new PhongEffect(game, BorderType.Corner);
            LoadContent();

            generateChessboardTexture();
            //generateChecker();
        }
Ejemplo n.º 23
0
            public void TryAddVote(string username, string effectText)
            {
                if (!Config.Instance.TwitchAllowVoting)
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(effectText, true);

                if (effect != null)
                {
                    UserVotes[username] = effect;
                }
            }
Ejemplo n.º 24
0
 public static void SetEffectEnabled(AbstractEffect effect, bool enabled)
 {
     if (effect != null)
     {
         if (!enabled && EnabledEffects.Contains(effect))
         {
             EnabledEffects.Remove(effect);
         }
         else if (enabled && !EnabledEffects.Contains(effect))
         {
             EnabledEffects.Add(effect);
         }
     }
 }
Ejemplo n.º 25
0
		public virtual bool Remove(AbstractEffect effect)
		{
			lock (m_effects) 
			{
				int index = m_effects.IndexOf(effect);
				if (index < 0)
					return false;
				m_effects.RemoveAt(index);
			}

			BeginChanges();
			OnEffectsChanged(effect);
			CommitChanges();
			return true;
		}
Ejemplo n.º 26
0
        public void SendEffect(AbstractEffect effect)
        {
            int duration = effect.Duration > 0 ? effect.Duration : Config.GetEffectDuration();

            duration = (int)Math.Round(duration * effect.GetMultiplier());

            var msg = new MessageEffect()
            {
                Word     = effect.Word,
                Duration = duration,
                Voter    = effect.GetVoter(),
                Seed     = RandomHandler.Next(9999999)
            };

            socket?.Send(JsonConvert.SerializeObject(msg));
        }
Ejemplo n.º 27
0
        public virtual bool Remove(AbstractEffect effect)
        {
            lock (m_effects)
            {
                int index = m_effects.IndexOf(effect);
                if (index < 0)
                {
                    return(false);
                }
                m_effects.RemoveAt(index);
            }

            BeginChanges();
            OnEffectsChanged(effect);
            CommitChanges();
            return(true);
        }
Ejemplo n.º 28
0
        public override int EffectEditorIndex(AbstractEffect effect)
        {
            int i = 0;

            foreach (EffectEditor effectEditor in effectEditors)
            {
                if (effectEditor.manages(effect))
                {
                    return(i);
                }
                else
                {
                    i++;
                }
            }

            return(0);
        }
Ejemplo n.º 29
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            if (VotingMode == 2)
            {
                if (rapidFireVoters.Contains(username))
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(message);
                if (effect == null || !effect.IsRapidFire())
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                rapidFireVoters.Add(username);

                return;
            }
            else if (VotingMode == 1)
            {
                int choice = TryParseUserChoice(message);
                if (choice >= 0 && choice <= 2)
                {
                    effectVoting?.TryAddVote(username, choice);
                }

                if (username.Equals("lordmau5"))
                {
                    if (message.EndsWith("."))
                    {
                        overrideEffectChoice = choice;
                    }
                }
            }
        }
Ejemplo n.º 30
0
 private void AddEffect()
 {
     foreach (Player player in Game.GetAllFightPlayers())
     {
         if (player.IsLiving && player.X > Body.X - 2000 && player.X < Body.X + 2000)
         {
             AbstractEffect effect = null;
             effect = player.EffectList.GetOfType(eEffectType.ReduceStrengthEffect);
             if (effect == null)
             {
                 player.AddEffect(new ReduceStrengthEffect(100), 0);
             }
         }
         else
         {
             player.EffectList.StopEffect(typeof(ReduceStrengthEffect));
         }
     }
 }
Ejemplo n.º 31
0
        public void SetVoting(int votingMode, int untilRapidFire = -1, VotingElement votingElement = null, string username = null)
        {
            VotingMode = votingMode;
            if (VotingMode == 1)
            {
                effectVoting.Clear();
                effectVoting.GenerateRandomEffects();
                overrideEffectChoice = -1;
                lastChoice           = -1;

                SendMessage("Voting has started! Type 1, 2 or 3 (or #1, #2, #3) to vote for one of the effects!");
                foreach (VotingElement element in effectVoting.VotingElements)
                {
                    SendMessage($"#{element.Id + 1}: {element.Effect.GetDescription()}");
                }
            }
            else if (VotingMode == 2)
            {
                rapidFireVoters.Clear();
                SendMessage("ATTENTION, ALL GAMERS! RAPID-FIRE HAS BEGUN! VALID EFFECTS WILL BE ENABLED FOR 15 SECONDS!");
            }
            else
            {
                if (votingElement != null)
                {
                    SendEffectVotingToGame(false);

                    AbstractEffect effect = votingElement.Effect;

                    string effectText = effect.GetDescription();
                    SendMessage($"Cooldown has started! ({untilRapidFire} until Rapid-Fire) - Enabled effect: {effectText} voted by {(username ?? "GTA:SA Chaos")}");

                    if (untilRapidFire == 1)
                    {
                        SendMessage("Rapid-Fire is coming up! Get your cheats ready! - List of all effects: https://bit.ly/gta-sa-chaos-mod");
                    }
                }
                else
                {
                    SendMessage($"Cooldown has started! ({untilRapidFire} until Rapid-Fire)");
                }
            }
        }
Ejemplo n.º 32
0
        public void SendEffect(AbstractEffect effect, int _duration = -1)
        {
            int duration = effect.Duration > 0 ? effect.Duration : Config.GetEffectDuration();

            if (_duration != -1)
            {
                duration = _duration; // Always Override
            }

            var msg = new MessageEffect()
            {
                Word     = effect.Word,
                Duration = duration,
                Voter    = effect.GetVoter(),
                Seed     = RandomHandler.Next(9999999)
            };

            socket?.Send(JsonConvert.SerializeObject(msg));
        }
Ejemplo n.º 33
0
        public void AddEffectToListBox(AbstractEffect effect)
        {
            string Description = "Invalid";

            if (effect != null)
            {
                Description = effect.GetDescription();
                if (!string.IsNullOrEmpty(effect.Word))
                {
                    Description += " (" + effect.Word + ")";
                }
            }

            ListBox listBox = Config.Instance.IsTwitchMode ? listLastEffectsTwitch : listLastEffectsMain;

            listBox.Items.Insert(0, Description);
            if (listBox.Items.Count > 7)
            {
                listBox.Items.RemoveAt(7);
            }
        }
Ejemplo n.º 34
0
            public void GenerateRandomEffects()
            {
                int possibleEffects = Math.Min(3, EffectDatabase.EnabledEffects.Count);

                while (VotingElements.Count != possibleEffects)
                {
                    AbstractEffect effect = EffectDatabase.GetRandomEffect(true);
                    if (effect.IsTwitchEnabled() && !ContainsEffect(effect))
                    {
                        AddEffect(effect);
                    }
                }

                while (VotingElements.Count < 3)
                {
                    AbstractEffect effect = EffectDatabase.GetRandomEffect();
                    if (effect.IsTwitchEnabled() && !ContainsEffect(effect))
                    {
                        AddEffect(effect);
                    }
                }
            }
Ejemplo n.º 35
0
 public EffectHolderNode(AbstractEffect effect)
 {
     this.effect = effect;
 }
Ejemplo n.º 36
0
		public virtual void OnEffectsChanged(AbstractEffect changedEffect)
		{
			if (m_changesCount > 0)
				return;
			UpdateChangedEffects();
		}
Ejemplo n.º 37
0
 /**
  * @param negativeEffect
  *            the negativeEffect to set
  */
 public void setNegativeEffect(AbstractEffect negativeEffect)
 {
     this.negativeEffect = negativeEffect;
 }
Ejemplo n.º 38
0
 /**
  * @param positiveEffect
  *            the positiveEffect to set
  */
 public void setPositiveEffect(AbstractEffect positiveEffect)
 {
     this.positiveEffect = positiveEffect;
 }
Ejemplo n.º 39
0
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public DefaultAnswerBlock()
     : base()
 {
     OnLoadEffect = new EffectShow(this);
     Layout = new DefaultLayout();
 }
Ejemplo n.º 40
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs)
    {
        //Debug.Log("Start: " + sName + " " + qName + "\nAttr: \n " +CollectionPrinter.PrintCollection(attrs));
        newEffect = null;
        audioPath = string.Empty;

        //Debug.Log(sName + " " + qName + "\nAttrs: \n" + CollectionPrinter.PrintCollection(attrs));
        // If it is a cancel-action tag
        if (qName.Equals("cancel-action"))
        {
            newEffect = new CancelActionEffect();
        }

        // If it is a activate tag
        else if (qName.Equals("activate"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("flag"))
                {
                    newEffect = new ActivateEffect(entry.Value.ToString());
                    chapter.addFlag(entry.Value.ToString());
                }
        }

        // If it is a deactivate tag
        else if (qName.Equals("deactivate"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("flag"))
                {
                    newEffect = new DeactivateEffect(entry.Value.ToString());
                    chapter.addFlag(entry.Value.ToString());
                }
        }

        // If it is a set-value tag
        else if (qName.Equals("set-value"))
        {
            string var = null;
            int value = 0;

            foreach (KeyValuePair<string, string> entry in attrs)
            {

                if (entry.Key.Equals("var"))
                {
                    var = entry.Value.ToString();
                }
                else if (entry.Key.Equals("value"))
                {
                    value = int.Parse(entry.Value.ToString());
                }
            }
            newEffect = new SetValueEffect(var, value);
            chapter.addVar(var);
        }

        // If it is a set-value tag
        else if (qName.Equals("increment"))
        {
            string var = null;
            int value = 0;

            foreach (KeyValuePair<string, string> entry in attrs)
            {

                if (entry.Key.Equals("var"))
                {
                    var = entry.Value.ToString();
                }
                else if (entry.Key.Equals("value"))
                {
                    value = int.Parse(entry.Value.ToString());
                }
            }
            newEffect = new IncrementVarEffect(var, value);
            chapter.addVar(var);
        }

        // If it is a decrement tag
        else if (qName.Equals("decrement"))
        {
            string var = null;
            int value = 0;

            foreach (KeyValuePair<string, string> entry in attrs)
            {

                if (entry.Key.Equals("var"))
                {
                    var = entry.Value.ToString();
                }
                else if (entry.Key.Equals("value"))
                {
                    value = int.Parse(entry.Value.ToString());
                }
            }
            newEffect = new DecrementVarEffect(var, value);
            chapter.addVar(var);
        }

        // If it is a macro-reference tag
        else if (qName.Equals("macro-ref"))
        {
            // Id
            string id = null;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("id"))
                {
                    id = entry.Value.ToString();
                }
            }
            // Store the inactive flag in the conditions or either conditions
            newEffect = new MacroReferenceEffect(id);
        }

        // If it is a consume-object tag
        else if (qName.Equals("consume-object"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    newEffect = new ConsumeObjectEffect(entry.Value.ToString());
        }

        // If it is a generate-object tag
        else if (qName.Equals("generate-object"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    newEffect = new GenerateObjectEffect(entry.Value.ToString());
        }

        // If it is a speak-char tag
        else if (qName.Equals("speak-char"))
        {

            audioPath = "";
            // Store the idTarget, to store the effect when the tag is closed
            currentCharIdTarget = null;

            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("idTarget"))
                    currentCharIdTarget = entry.Value.ToString();
                // If there is a "uri" attribute, store it as audio path
                if (entry.Key.Equals("uri"))
                    audioPath = entry.Value.ToString();
            }

        }

        // If it is a trigger-book tag
        else if (qName.Equals("trigger-book"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    newEffect = new TriggerBookEffect(entry.Value.ToString());
        }

        // If it is a trigger-last-scene tag
        else if (qName.Equals("trigger-last-scene"))
        {
            newEffect = new TriggerLastSceneEffect();
        }

        // If it is a play-sound tag
        else if (qName.Equals("play-sound"))
        {
            // Store the path and background
            string path = "";
            bool background = true;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("background"))
                    background = entry.Value.ToString().Equals("yes");
                else if (entry.Key.Equals("uri"))
                    path = entry.Value.ToString();
            }

            // Add the new play sound effect
            newEffect = new PlaySoundEffect(background, path);
        }

        // If it is a trigger-conversation tag
        else if (qName.Equals("trigger-conversation"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    newEffect = new TriggerConversationEffect(entry.Value.ToString());
        }

        // If it is a trigger-cutscene tag
        else if (qName.Equals("trigger-cutscene"))
        {
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    newEffect = new TriggerCutsceneEffect(entry.Value.ToString());
        }

        // If it is a trigger-scene tag
        else if (qName.Equals("trigger-scene"))
        {
            string scene = "";
            int x = 0;
            int y = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("idTarget"))
                    scene = entry.Value.ToString();
                else if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());

            newEffect = new TriggerSceneEffect(scene, x, y);
        }

        // If it is a play-animation tag
        else if (qName.Equals("play-animation"))
        {
            string path = "";
            int x = 0;
            int y = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("uri"))
                    path = entry.Value.ToString();
                else if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());
            }

            // Add the new play sound effect
            newEffect = new PlayAnimationEffect(path, x, y);
        }

        // If it is a move-player tag
        else if (qName.Equals("move-player"))
        {
            int x = 0;
            int y = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());
            }

            // Add the new move player effect
            newEffect = new MovePlayerEffect(x, y);
        }

        // If it is a move-npc tag
        else if (qName.Equals("move-npc"))
        {
            string npcTarget = "";
            int x = 0;
            int y = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("idTarget"))
                    npcTarget = entry.Value.ToString();
                else if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());
            }

            // Add the new move NPC effect
            newEffect = new MoveNPCEffect(npcTarget, x, y);
        }

        // Random effect tag
        else if (qName.Equals("random-effect"))
        {
            int probability = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("probability"))
                    probability = int.Parse(entry.Value.ToString());
            }

            // Add the new random effect
            randomEffect = new RandomEffect(probability);
            newEffect = randomEffect;
            readingRandomEffect = true;
            positiveBlockRead = false;
        }
        // wait-time effect
        else if (qName.Equals("wait-time"))
        {
            int time = 0;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("time"))
                    time = int.Parse(entry.Value.ToString());
            }

            // Add the new move NPC effect
            newEffect = new WaitTimeEffect(time);
        }

        // show-text effect
        else if (qName.Equals("show-text"))
        {
            x = 0;
            y = 0;
            frontColor = 0;
            borderColor = 0;
            audioPath = "";

            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("frontColor"))
                    frontColor = int.Parse(entry.Value.ToString());
                else if (entry.Key.Equals("borderColor"))
                    borderColor = int.Parse(entry.Value.ToString());
                // If there is a "uri" attribute, store it as audio path
                else if (entry.Key.Equals("uri"))
                    audioPath = entry.Value.ToString();
            }

        }

        else if (qName.Equals("highlight-item"))
        {
            int type = 0;
            bool animated = false;
            string id = "";
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("idTarget"))
                    id = entry.Value.ToString();
                if (entry.Key.Equals("animated"))
                    animated = (entry.Value.ToString().Equals("yes") ? true : false);
                if (entry.Key.Equals("type"))
                {
                    if (entry.Value.ToString().Equals("none"))
                        type = HighlightItemEffect.NO_HIGHLIGHT;
                    if (entry.Value.ToString().Equals("green"))
                        type = HighlightItemEffect.HIGHLIGHT_GREEN;
                    if (entry.Value.ToString().Equals("red"))
                        type = HighlightItemEffect.HIGHLIGHT_RED;
                    if (entry.Value.ToString().Equals("blue"))
                        type = HighlightItemEffect.HIGHLIGHT_BLUE;
                    if (entry.Value.ToString().Equals("border"))
                        type = HighlightItemEffect.HIGHLIGHT_BORDER;
                }
            }
            newEffect = new HighlightItemEffect(id, type, animated);
        }
        else if (qName.Equals("move-object"))
        {
            bool animated = false;
            string id = "";
            int x = 0;
            int y = 0;
            float scale = 1.0f;
            int translateSpeed = 20;
            int scaleSpeed = 20;
            foreach (KeyValuePair<string, string> entry in attrs)
            {
                if (entry.Key.Equals("idTarget"))
                    id = entry.Value.ToString();
                if (entry.Key.Equals("animated"))
                    animated = (entry.Value.ToString().Equals("yes") ? true : false);
                if (entry.Key.Equals("x"))
                    x = int.Parse(entry.Value.ToString());
                if (entry.Key.Equals("y"))
                    y = int.Parse(entry.Value.ToString());
                if (entry.Key.Equals("scale"))
                    scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture);
                if (entry.Key.Equals("translateSpeed"))
                    translateSpeed = int.Parse(entry.Value.ToString());
                if (entry.Key.Equals("scaleSpeed"))
                    scaleSpeed = int.Parse(entry.Value.ToString());
            }
            newEffect = new MoveObjectEffect(id, x, y, scale, animated, translateSpeed, scaleSpeed);
        }

        else if (qName.Equals("speak-player"))
        {
            audioPath = "";

            foreach (KeyValuePair<string, string> entry in attrs)
            {

                // If there is a "uri" attribute, store it as audio path
                if (entry.Key.Equals("uri"))
                    audioPath = entry.Value.ToString();
            }
        }
        // If it is a condition tag, create new conditions and switch the state
        else if (qName.Equals("condition"))
        {
            currentConditions = new Conditions();
            subParser = new ConditionSubParser(currentConditions, chapter);
            subParsing = SUBPARSING_CONDITION;
        }

        // Not reading Random effect: Add the new Effect if not null
        if (!readingRandomEffect && newEffect != null)
        {
            effects.add(newEffect);
            // Store current effect
            currentEffect = newEffect;

        }

        // Reading random effect
        if (readingRandomEffect)
        {
            // When we have just created the effect, add it
            if (newEffect != null && newEffect == randomEffect)
            {
                effects.add(newEffect);
            }
            // Otherwise, determine if it is positive or negative effect
            else if (newEffect != null && !positiveBlockRead)
            {
                randomEffect.setPositiveEffect(newEffect);
                positiveBlockRead = true;
            }
            // Negative effect
            else if (newEffect != null && positiveBlockRead)
            {
                randomEffect.setNegativeEffect(newEffect);
                positiveBlockRead = false;
                readingRandomEffect = false;
                newEffect = randomEffect;
                randomEffect = null;

            }
            // Store current effect
            currentEffect = newEffect;

        }

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
            endElement(namespaceURI, sName, qName);
        }
    }
Ejemplo n.º 41
0
 public DefaultQuestionBlock()
 {
     OnLoadEffect = new EffectShow(this);
     Layout = new DefaultLayout();
 }
Ejemplo n.º 42
0
    public override void ParseElement(XmlElement element)
    {
        string tmpArgVal;
        int x = 0;
        int y = 0;
        string path = "";
        string id = "";
        bool animated = false, addeffect = true;
        List<AbstractEffect> effectlist;

        foreach (XmlElement effect in element.ChildNodes) {
            addeffect = true;

            switch (effect.Name) {
            case "cancel-action": currentEffect = new CancelActionEffect(); break;
            case "activate":
            case "deactivate":
                tmpArgVal = effect.GetAttribute ("flag");
                if (!string.IsNullOrEmpty (tmpArgVal)) {
                    chapter.addFlag (tmpArgVal);
                }

                if (effect.Name == "activate")
                    currentEffect = new ActivateEffect (tmpArgVal);
                else
                    currentEffect = new DeactivateEffect (tmpArgVal);
                break;
            case "set-value":
            case "increment":
            case "decrement":
                string var = null;
                int value = 0;

                tmpArgVal = effect.GetAttribute("var");
                if (!string.IsNullOrEmpty(tmpArgVal)){
                    var = tmpArgVal;
                }
                tmpArgVal = effect.GetAttribute("value");
                if (!string.IsNullOrEmpty(tmpArgVal)){
                    value = int.Parse(tmpArgVal);
                }
                if(effect.Name == "set-value")
                    currentEffect = new SetValueEffect(var, value);
                else if(effect.Name == "increment")
                    currentEffect = new IncrementVarEffect(var, value);
                else
                    currentEffect = new DecrementVarEffect(var, value);

                chapter.addVar(var);
                break;
            case "macro-ref":
                id = "";
                tmpArgVal = effect.GetAttribute("id");
                if (!string.IsNullOrEmpty(tmpArgVal)){
                    id = tmpArgVal;
                }
                currentEffect = new MacroReferenceEffect(id);
                break;
            case "speak-char":
                audioPath = "";
                currentCharIdTarget = null;

                tmpArgVal = effect.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal)){
                    currentCharIdTarget = tmpArgVal;
                }

                tmpArgVal = effect.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal)){
                    audioPath = tmpArgVal;
                }

                // Add the effect and clear the current string
                currentEffect = new SpeakCharEffect(currentCharIdTarget, effect.InnerText.ToString().Trim());
                ((SpeakCharEffect) currentEffect).setAudioPath(audioPath);
                break;
            case "trigger-last-scene":
                currentEffect = new TriggerLastSceneEffect();
                break;
            case "play-sound":
                // Store the path and background
                bool background = true;
                path = "";

                tmpArgVal = effect.GetAttribute("background");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    background = tmpArgVal.Equals("yes");
                }
                tmpArgVal = effect.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }

                // Add the new play sound effect
                currentEffect = new PlaySoundEffect(background, path);
                break;

            case "consume-object":
            case "generate-object":
            case "trigger-book":
            case "trigger-conversation":
            case "trigger-cutscene":
                tmpArgVal = effect.GetAttribute ("idTarget");
                if (!string.IsNullOrEmpty (tmpArgVal))
                    switch (effect.Name) {
                    case "consume-object": currentEffect = new ConsumeObjectEffect (tmpArgVal); break;
                    case "generate-object": currentEffect = new GenerateObjectEffect (tmpArgVal); break;
                    case "trigger-book": currentEffect = new TriggerBookEffect (tmpArgVal); break;
                    case "trigger-conversation": currentEffect = new TriggerConversationEffect (tmpArgVal); break;
                    case "trigger-cutscene": currentEffect = new TriggerCutsceneEffect (tmpArgVal); break;
                    }
                break;
            case "trigger-scene":
                x = 0;
                y = 0;
                string scene = "";
                tmpArgVal = effect.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    scene = tmpArgVal;
                }
                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                currentEffect = new TriggerSceneEffect(scene, x, y);
                break;
            case "play-animation":
                x = 0;
                y = 0;
                path = "";

                tmpArgVal = effect.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                // Add the new play sound effect
                currentEffect = new PlayAnimationEffect(path, x, y);
                break;
            case "move-player":
                x = 0;
                y = 0;
                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                // Add the new move player effect
                currentEffect = new MovePlayerEffect(x, y);
                break;
            case "move-npc":
                x = 0;
                y = 0;
                string npcTarget = "";
                tmpArgVal = effect.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    npcTarget = tmpArgVal;
                }
                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                // Add the new move NPC effect
                currentEffect = new MoveNPCEffect(npcTarget, x, y);
                break;
            case "random-effect":
                int probability = 0;

                tmpArgVal = effect.GetAttribute ("probability");
                if (!string.IsNullOrEmpty (tmpArgVal)) {
                    probability = int.Parse (tmpArgVal);
                }

                // Add the new random effect
                randomEffect = new RandomEffect (probability);

                Effects randomEffectList = new Effects ();

                new EffectSubParser_ (randomEffectList, this.chapter).ParseElement (effect);

                randomEffect.setPositiveEffect (randomEffectList.getEffects () [0]);
                randomEffect.setNegativeEffect (randomEffectList.getEffects () [1]);

                currentEffect = randomEffect;
                break;
            case "wait-time":
                int time = 0;

                tmpArgVal = effect.GetAttribute("time");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    time = int.Parse(tmpArgVal);
                }

                // Add the new move NPC effect
                currentEffect = new WaitTimeEffect(time);
                break;
            case "show-text":
                x = 0;
                y = 0;
                frontColor = 0;
                borderColor = 0;
                audioPath = "";
                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("frontColor");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    frontColor = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("borderColor");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    borderColor = int.Parse(tmpArgVal);
                }
                tmpArgVal = effect.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    audioPath = tmpArgVal;
                }

                // Add the new ShowTextEffect
                currentEffect = new ShowTextEffect(effect.InnerText.ToString().Trim(), x, y, frontColor, borderColor);
                ((ShowTextEffect) currentEffect).setAudioPath(audioPath);
                break;
            case "highlight-item":
                int type = 0;
                id = "";
                animated = false;

                tmpArgVal = effect.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    id = tmpArgVal;
                }

                tmpArgVal = effect.GetAttribute("animated");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    animated = (tmpArgVal.Equals("yes") ? true : false);
                }

                tmpArgVal = effect.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("none"))
                        type = HighlightItemEffect.NO_HIGHLIGHT;
                    if (tmpArgVal.Equals("green"))
                        type = HighlightItemEffect.HIGHLIGHT_GREEN;
                    if (tmpArgVal.Equals("red"))
                        type = HighlightItemEffect.HIGHLIGHT_RED;
                    if (tmpArgVal.Equals("blue"))
                        type = HighlightItemEffect.HIGHLIGHT_BLUE;
                    if (tmpArgVal.Equals("border"))
                        type = HighlightItemEffect.HIGHLIGHT_BORDER;
                }
                currentEffect = new HighlightItemEffect(id, type, animated);
                break;
            case "move-object":
                float scale = 1.0f;
                int translateSpeed = 20;
                int scaleSpeed = 20;
                x = 0;
                y = 0;
                id = "";
                animated = false;

                tmpArgVal = effect.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    id = tmpArgVal;
                }
                tmpArgVal = effect.GetAttribute("animated");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    animated = (tmpArgVal.Equals("yes") ? true : false);
                }

                tmpArgVal = effect.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }

                tmpArgVal = effect.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                tmpArgVal = effect.GetAttribute("scale");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
                }

                tmpArgVal = effect.GetAttribute("translateSpeed");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    translateSpeed = int.Parse(tmpArgVal);
                }

                tmpArgVal = effect.GetAttribute("scaleSpeed");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    scaleSpeed = int.Parse(tmpArgVal);
                }
                currentEffect = new MoveObjectEffect(id, x, y, scale, animated, translateSpeed, scaleSpeed);
                break;
            case "speak-player":
                audioPath = "";

                tmpArgVal = effect.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    audioPath = tmpArgVal;
                }

                // Add the effect and clear the current string
                currentEffect = new SpeakPlayerEffect(effect.InnerText.ToString().Trim());
                break;
            case "condition":
                addeffect = false;
                currentConditions = new Conditions ();
                new ConditionSubParser_ (currentConditions, chapter).ParseElement (effect);
                currentEffect.setConditions (currentConditions);

                effectlist = effects.getEffects ();
                effectlist[effectlist.Count-1].setConditions (currentConditions);
                break;
            case "documentation":
                addeffect = false;
                break;
            default:
                addeffect = false;
                Debug.LogWarning ("EFFECT NOT SUPPORTED: " + effect.Name);
                break;
            }

            if(addeffect)
                effects.add(currentEffect);
        }
    }
Ejemplo n.º 43
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // Debug.Log("END: " + sName + " " + qName );
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            newEffect = null;

            // If it is a speak-player
            if (qName.Equals("speak-player"))
            {
                // Add the effect and clear the current string
                newEffect = new SpeakPlayerEffect(currentstring.ToString().Trim());
                ((SpeakPlayerEffect)newEffect).setAudioPath(audioPath);
            }

            // If it is a speak-char
            else if (qName.Equals("speak-char"))
            {
                // Add the effect and clear the current string
                newEffect = new SpeakCharEffect(currentCharIdTarget, currentstring.ToString().Trim());
                ((SpeakCharEffect)newEffect).setAudioPath(audioPath);
            }// If it is a show-text
            else if (qName.Equals("show-text"))
            {
                // Add the new ShowTextEffect
                newEffect = new ShowTextEffect(currentstring.ToString().Trim(), x, y, frontColor, borderColor);
                ((ShowTextEffect)newEffect).setAudioPath(audioPath);
            }

            // Not reading Random effect: Add the new Effect if not null
            if (!readingRandomEffect && newEffect != null)
            {
                effects.add(newEffect);
                // Store current effect
                currentEffect = newEffect;

            }

            // Reading random effect
            if (readingRandomEffect)
            {
                // When we have just created the effect, add it
                if (newEffect != null && newEffect == randomEffect)
                {
                    effects.add(newEffect);
                }
                // Otherwise, determine if it is positive or negative effect
                else if (newEffect != null && !positiveBlockRead)
                {
                    randomEffect.setPositiveEffect(newEffect);
                    positiveBlockRead = true;
                }
                // Negative effect
                else if (newEffect != null && positiveBlockRead)
                {
                    randomEffect.setNegativeEffect(newEffect);
                    positiveBlockRead = false;
                    readingRandomEffect = false;
                    newEffect = randomEffect;
                    randomEffect = null;
                }
                // Store current effect
                currentEffect = newEffect;

            }

            // Reset the current string
            currentstring = string.Empty;
        }
        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition tag is being closed
            if (qName.Equals("condition"))
            {
                //Debug.Log(currentEffect);
                //Debug.Log(currentConditions);
                // Store the conditions in the effect
                currentEffect.setConditions(currentConditions);

                // Switch state
                subParsing = SUBPARSING_NONE;
            }
        }
    }