Exemplo n.º 1
0
    public bool Initialize(ICommandArgs args)
    {
        ChopCommandArgs commandArgs = args as ChopCommandArgs;

        if (commandArgs == null)
        {
            successful = false;
            finished   = true;
            throw new UnityException("Wrong type of args");
        }

        node = commandArgs.node;

        GameObject tree = node.GetBlock();

        if (!tree)
        {
            Stop();
            Debug.Log("No tree to chop");
            return(false);
        }

        spriteRenderer = tree.GetComponent <SpriteRenderer>();
        TickSystem.Subscribe(Chop);

        return(true);
    }
Exemplo n.º 2
0
    public void Plant(Seed seed)
    {
        this.seed      = seed;
        numberOfStages = seed.stageSprites.Length;
        ticksPerStage  = seed.ticksToGrow / numberOfStages;

        cropRenderer.sprite  = seed.stageSprites[stage];
        cropRenderer.enabled = true;

        TickSystem.Subscribe(Grow);
    }
    public bool Initialize(ICommandArgs args)
    {
        BuildCommandArgs commandArgs = args as BuildCommandArgs;

        if (commandArgs == null)
        {
            Abort();
            throw new UnityException("Wrong type of args");
        }

        buildable = commandArgs.node.GetBlock().GetComponent <Buildable>();
        if (!buildable)
        {
            Abort();
            Debug.LogError("Tried to build a non buildable object");
            return(false);
        }

        TickSystem.Subscribe(Build);

        return(true);
    }
Exemplo n.º 4
0
    public bool Initialize(ICommandArgs args)
    {
        PlantCommandArgs commandArgs = args as PlantCommandArgs;

        if (commandArgs == null)
        {
            Abort();
            throw new UnityException("Wrong type of args");
        }

        seed       = commandArgs.seed;
        cultivable = commandArgs.node.GetBlock().GetComponent <Cultivable>();
        if (!cultivable)
        {
            Abort();
            Debug.LogError("Tried to plant a non cultivable object");
            return(false);
        }

        TickSystem.Subscribe(Plant);

        return(true);
    }