public void StartFishing(Vector3 position, FishPool fishPool, Player player)
    {
        FishSize    newFishSize = fishPool.RandomFishSize;
        Fish        fish        = fishFactory.CreateFish(newFishSize, GetFishTemplate(newFishSize));
        PlayerStats stats       = player.GetPlayerStats();
        Inventory   inventory   = player.GetPlayerInventory();

        GameObject    fishingTargetPrefab = GameObject.Instantiate(_fishingTargetPrefab, position, Quaternion.identity);
        FishingTarget fishingTarget       = fishingTargetPrefab.GetComponent <FishingTarget>();

        if (fishingTarget != null)
        {
        }

        bool canPlayerCatchFish = CanPlayerCatchFish(fish, stats);

        Debug.Log("Start Fishing :: FishName: " + fish.Size + ", CaughtFish: " + canPlayerCatchFish);
        if (canPlayerCatchFish)
        {
            stats.AddExperience(FishingHelper.calculateFishExperience(fishPool, fish, stats));
            InventoryObject fishInventoryObject  = new InventoryObject(fish);
            bool            collectedCollectable = inventory.AddItem(fishInventoryObject);
            Debug.Log(collectedCollectable ? "Success for inventoryplacement" : "Failure for inventoryplacement");
        }
    }
Esempio n. 2
0
    //TODO - awfull
    private void _onRightButtonClick(GameObject clickedGO, Vector3 point)
    {
        GameObject    player        = GameObject.FindGameObjectWithTag("PlayerSelf");
        FishPool      fishPool      = clickedGO.GetComponent <FishPool>();
        FishingTarget fishingTarget = clickedGO.GetComponent <FishingTarget>();

        if (FishingHelper.canStartFishing(fishingController.throwDistance, player.transform.position, point, clickedGO) && fishPool)
        {
            // TODO - Fix This
            fishingController.StartFishing(point, fishPool, player.GetComponent <Player>());
        }
        else if (fishingTarget != null)
        {
            fishingTarget.TriggerFishOn();
        }
        else if (UnitSelection.IsSelected(player))
        {
            player.GetComponent <Player>().MoveTo(point);
        }
    }