Ejemplo n.º 1
0
    public VGDLTimeEffect(VGDLTimeEffect copyFrom) : this()
    {
        timer          = copyFrom.timer;
        repeating      = copyFrom.repeating;
        targetType     = copyFrom.targetType;
        isNative       = copyFrom.isNative;
        effectDelegate = copyFrom.effectDelegate;

        //nextExecution not copied, because this() runs planExecution
        //And we also run it from addTimer
    }
Ejemplo n.º 2
0
 public void addEosEffect(string stype, VGDLEffect effect)
 {
     if (eosEffects.ContainsKey(stype))
     {
         eosEffects[stype].Add(effect);
     }
     else
     {
         eosEffects[stype] = new List <VGDLEffect> {
             effect
         };
     }
 }
Ejemplo n.º 3
0
    private void executeEffectBatch(VGDLEffect ef, VGDLSprite s1, List <VGDLSprite> s2list)
    {
        // There is a collision. Apply the effect.
        int batchCount = ef.executeBatch(s1, s2list, this);

        if (batchCount == -1)
        {
            Debug.Log("WARNING: Batch collision not or bad implemented (batchCount == -1)");
            batchCount = 0; //So the game keeps making better sense.
        }

        // Affect score:
        if (ef.applyScore)
        {
            // apply scores for all avatars
            for (int i = 0; i < no_players; i++)
            {
                var multScore = ef.getScoreChange(i) * batchCount;
                avatars[i].addScore(multScore);
            }
        }

        // Add to events history.
        if (s1 != null && s2list != null)
        {
            foreach (VGDLSprite s2 in s2list)
            {
                addEvent(s1, s2);
            }
        }

        if (ef.count)
        {
            for (int i = 0; i < no_counters; i++)
            {
                var multCounter = ef.getCounter(i) * batchCount;
                this.counters[i] += multCounter;
            }
        }

        if (ef.countElse)
        {
            for (int i = 0; i < no_counters; i++)
            {
                var multElseCounter = ef.getCounterElse(i) * batchCount;
                this.counters[i] += multElseCounter;
            }
        }
    }
Ejemplo n.º 4
0
    public void addCollisionEffect(string stype1, string stype2, VGDLEffect effect)
    {
        var pair = new KeyValuePair <string, string>(stype1, stype2);

        if (collisionEffects.ContainsKey(pair))
        {
            collisionEffects[pair].Add(effect);
        }
        else
        {
            collisionEffects[pair] = new List <VGDLEffect> {
                effect
            };
        }
    }
Ejemplo n.º 5
0
    public void executeEffect(VGDLEffect ef, VGDLSprite s1, VGDLSprite s2)
    {
        // There is a collision. Apply the effect.
        ef.execute(s1, s2, this);

        // Affect score:
        if (ef.applyScore)
        {
            // apply scores for all avatars
            for (int i = 0; i < no_players; i++)
            {
                avatars[i].addScore(ef.getScoreChange(i));
            }
        }

        // Add to events history.
        if (s1 != null && s2 != null)
        {
            addEvent(s1, s2);
        }

        if (ef.count)
        {
            for (int i = 0; i < no_counters; i++)
            {
                counters[i] += ef.getCounter(i);
            }
        }

        if (ef.countElse)
        {
            for (int i = 0; i < no_counters; i++)
            {
                counters[i] += ef.getCounterElse(i);
            }
        }
    }