public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null || sprite2 == null)
        {
            throw new ArgumentException("Neither the 1st nor 2nd sprite can be EOS with CollectResourceIfHeld interaction.");
        }

        if (sprite1.is_resource)
        {
            var r = (Resource)sprite1;
            applyScore = false;

            //Check if we have the secondary resource first
            var numResourcesHeld = sprite2.getAmountResource(heldResource);
            if (numResourcesHeld < value)
            {
                return;
            }

            var numResources = sprite2.getAmountResource(r.resource_name);
            if (numResources + r.value <= game.getResourceLimit(r.resource_name))
            {
                applyScore = true;
                sprite2.modifyResource(r.resource_name, r.value);
            }

            if (killResource)
            {
                //boolean variable set to false to indicate the sprite was not transformed
                game.killSprite(sprite1, false);
            }
        }
    }
示例#2
0
    public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null || sprite2 == null)
        {
            throw new ArgumentException("Neither the 1st nor 2nd sprite can be EOS with CollectResource interaction.");
        }

        if (!sprite1.is_resource)
        {
            return;
        }

        var r = (Resource)sprite1;

        applyScore = false;

        var numResources = sprite2.getAmountResource(r.resource_name);

        if (numResources >= game.getResourceLimit(r.resource_name))
        {
            return;
        }

        var topup = Mathf.Min(r.value, game.getResourceLimit(r.resource_name) - numResources);

        applyScore = true;
        sprite2.modifyResource(r.resource_name, topup);

        if (killResource)
        {
            //boolean variable set to false to indicate the sprite was not transformed
            game.killSprite(sprite1, true);
        }
    }
示例#3
0
    public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null)
        {
            throw new ArgumentException("1st sprite can't be EOS with killIfHasMore interaction");
        }

        applyScore = false;
        if (sprite1.getAmountResource(resource) >= limit)
        {
            //boolean variable set to false to indicate the sprite was not transformed
            game.killSprite(sprite1, false);
            applyScore = true;
        }
    }
示例#4
0
    public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null)
        {
            throw new ArgumentException("1st sprite can't be EOS with SpawnIfHasLess interaction.");
        }

        applyScore = false;

        if (Random.value >= prob)
        {
            return;
        }

        if (sprite1.getAmountResource(resource) <= limit)
        {
            game.addSprite(stype, sprite1.getPosition());
            applyScore = true;
        }
    }
示例#5
0
    public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null || sprite2 == null)
        {
            throw new ArgumentException("Neither the 1st nor 2nd sprite can be EOS with KillIfOtherHasMore interaction.");
        }

        applyScore = false;
        //If 'sprite2' has more than a limit of the resource type given, sprite dies.
        if (sprite2.getAmountResource(resource) >= limit)
        {
            applyScore = true;
            //boolean variable set to false to indicate the sprite was not transformed
            game.killSprite(sprite1, false);
            if (subtract)
            {
                sprite2.subtractResource(resource, limit);
            }
        }
    }
示例#6
0
    public override void execute(VGDLSprite sprite1, VGDLSprite sprite2, VGDLGame game)
    {
        if (sprite1 == null || sprite2 == null)
        {
            throw new ArgumentException("Neither the 1st nor 2nd sprite can be EOS with ChangeResource interaction.");
        }

        var numResources = sprite1.getAmountResource(resource);

        applyScore = false;
        if (numResources + value <= game.getResourceLimit(resource))
        {
            sprite1.modifyResource(resource, value);
            applyScore = true;

            if (killResource)
            {
                //boolean variable set to true, as the sprite was transformed
                game.killSprite(sprite2, true);
            }
        }
    }