コード例 #1
0
    private void HandleCurrentTarget()
    {
        // If current target is a collectible, call Collect() on it (free for you, cheap for them (tm) )
        Collectible collectible = target.GetComponent <Collectible>();

        if (collectible)
        {
            collectible.CollectIfPossible();
        }

        // If current target is a PlantableZone, water it
        PlantableZone plantableZone = target.GetComponent <PlantableZone>();

        if (plantableZone != null)
        {
            plantableZone.Water();
        }

        // If current target is a Strikable, strike it up
        IStrikeable strikable = target.GetComponent <IStrikeable>();

        if (strikable != null)
        {
            strikable.Strike(this.transform.position, null);
        }

        // If we went to water, Fill'r up
        if ((1 << target.layer) == AI.WaterLayermask)
        {
            inventory.FillWaterLevel();
        }
    }