2851 lines
71 KiB
C#
2851 lines
71 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BehaviorDesigner.Runtime;
|
|
using BitStrap;
|
|
using UltimateWater;
|
|
using UnityEngine;
|
|
|
|
public class Fish : MonoBehaviour
|
|
{
|
|
public class TerrainMod
|
|
{
|
|
public string terrainType;
|
|
|
|
public float utility;
|
|
|
|
public TerrainMod(string terrainType, float utility)
|
|
{
|
|
this.terrainType = terrainType;
|
|
this.utility = utility;
|
|
}
|
|
}
|
|
|
|
public enum DepthStyle
|
|
{
|
|
FREE = 0,
|
|
WATER_LEVEL = 1,
|
|
GROUND_LEVEL = 2
|
|
}
|
|
|
|
public enum HuntStyle
|
|
{
|
|
NORMAL = 0,
|
|
PREDATOR = 1
|
|
}
|
|
|
|
public enum CatchStyle
|
|
{
|
|
SWIM = 0,
|
|
STOP = 1,
|
|
DOWN = 2
|
|
}
|
|
|
|
public enum WatchStyle
|
|
{
|
|
HOOK_LIGHT = 0,
|
|
HOOK_HEAVY = 1,
|
|
HANDS = 2,
|
|
BOAT = 3
|
|
}
|
|
|
|
public enum Species
|
|
{
|
|
RAINBOW_TROUT = 0,
|
|
BROWN_TROUT = 1,
|
|
LAKE_TROUT = 2,
|
|
BROOK_TROUT = 3,
|
|
BULL_TROUT = 4,
|
|
LAKE_WHITEFISH = 5,
|
|
MOUNTAIN_WHITEFISH = 6,
|
|
old_SAILFISH = 7,
|
|
BLACK_MARLIN = 8,
|
|
BLUE_MARLIN = 9,
|
|
STRIPED_MARLIN = 10,
|
|
WHITE_MARLIN = 11,
|
|
DORADO = 12,
|
|
AMBERJACK = 13,
|
|
RAINBOW_RUNNER = 14,
|
|
BARRACUDA = 15,
|
|
PIKE = 16,
|
|
PERCH = 17,
|
|
BAIKAL_OMUL = 18,
|
|
old_BLACK_GRAYLING = 19,
|
|
old_WHITE_GRAYLING = 20,
|
|
BLUEGILL = 21,
|
|
CHANNEL_CATFISH = 22,
|
|
BLACK_CRAPPIE = 23,
|
|
WALLEYE = 24,
|
|
LARGEMOUTH_BASS = 25,
|
|
SMALLMOUTH_BASS = 26,
|
|
STRIPPED_BASS = 27,
|
|
SPOTTED_BASS = 28,
|
|
BREAM = 29,
|
|
CHUB = 30,
|
|
GRASS_CARP = 31,
|
|
MIRROR_CARP = 32,
|
|
CRUCIAN_CARP = 33,
|
|
STURGEON = 34,
|
|
CUTTHROAT_TROUT = 35,
|
|
old_YELLOWFIN_TUNA = 36,
|
|
ROOSTERFISH = 37,
|
|
old_GIANT_TREVALLY = 38,
|
|
old_SEA_BREAM = 39,
|
|
ZANDER = 40,
|
|
BARBEL = 41,
|
|
HUCHEN = 42,
|
|
NASE = 43,
|
|
SAUGER = 44,
|
|
YELLOW_PERCH = 45,
|
|
GOLDEN_TROUT = 46,
|
|
TIGER_TROUT = 47,
|
|
AFRICAN_TIGERFISH = 48,
|
|
ELECTRIC_CATFISH = 49,
|
|
VUNDU_CATFISH = 50,
|
|
AFRICAN_CATFISH = 51,
|
|
REDBREASTED_TILAPIA = 52,
|
|
KARIBA_TILAPIA = 53,
|
|
THREESPOT_TILAPIA = 54,
|
|
GREEN_BREAM = 55,
|
|
PINK_BREAM = 56,
|
|
RAINBOW_BREAM = 57,
|
|
ZAMBEZI_BREAM = 58,
|
|
AFRICAN_BARB = 59,
|
|
PURPLE_LABEO = 60,
|
|
LARGESCALED_YELLOWFISH = 61,
|
|
KAFUE_KILLIFISH = 62,
|
|
CAPRIVI_KILLIFISH = 63,
|
|
ATLANTIC_SALMON = 64,
|
|
ATLANTIC_COD = 65,
|
|
GREENLAND_COD = 66,
|
|
ATLANTIC_HALIBUT = 67,
|
|
GREENLAND_HALIBUT = 68,
|
|
FOURHORNED_SCULPIN = 69,
|
|
CAPELIN = 70,
|
|
ATLANTIC_WOLFFISH = 71,
|
|
GREENLAND_SHARK = 72,
|
|
GOBLIN_SHARK = 73,
|
|
LUMPFISH = 74,
|
|
DEEPWATER_REDFISH = 75,
|
|
NARWAHL = 76,
|
|
ALIGATOR_GAR = 77,
|
|
AMAZON_WOLFFISH = 78,
|
|
APAPA = 79,
|
|
ARAPAIMA = 80,
|
|
AROWANA = 81,
|
|
BARBA_CHATA_CATFISH = 82,
|
|
ELECTRIC_EEL = 83,
|
|
JAU_CATFISH = 84,
|
|
JUNDIRA_CATFISH = 85,
|
|
OSCAR = 86,
|
|
PAYARA = 87,
|
|
PEACOCK_BASS = 88,
|
|
PIRAIBA_CATFISH = 89,
|
|
PIRANHA = 90,
|
|
REDTAIL_CATFISH = 91,
|
|
SURUBIM = 92,
|
|
TAMBAQUI = 93,
|
|
VAMPIRE_FISH = 94,
|
|
CARP_KOI = 95,
|
|
GIANT_BARB = 96,
|
|
JAPANESE_EEL = 97,
|
|
SNAKEHEAD = 98,
|
|
SOCKEYE_SALMON = 99,
|
|
SPOTTED_SEATROUT = 100,
|
|
TENCH = 101,
|
|
WAKASAGI = 102,
|
|
WELS_CATFISH = 103,
|
|
BEAKED_CORAL_FISH = 104,
|
|
BLACKTIP_REEF_SHARK = 105,
|
|
COMMON_LIONFISH = 106,
|
|
CROCODILE_NEEDLEFISH = 107,
|
|
GIANT_GROUPER = 108,
|
|
GREAT_BARRACUDA = 109,
|
|
GREYFACE_MORAY_EEL = 110,
|
|
GREY_SNAPER = 111,
|
|
INDIAN_THREADFISH = 112,
|
|
LONGFIN_BANNERFISH = 113,
|
|
MALABAR_GROUPER = 114,
|
|
YELLOWTAIL_BARRACUDA = 115,
|
|
ASP = 116,
|
|
BLACK_GRAYLING = 117,
|
|
BLEAK = 118,
|
|
BURBOT = 119,
|
|
FLATHEAD_CATFISH = 120,
|
|
GIANT_TRAVELLY = 121,
|
|
IDE = 122,
|
|
PUMPKINSEED = 123,
|
|
ROACH = 124,
|
|
SAILFISH = 125,
|
|
SEA_BREAM = 126,
|
|
SILVER_BREAM = 127,
|
|
SILVER_CARP = 128,
|
|
WHITE_CRAPPIE = 129,
|
|
WHITE_GRAYLING = 130,
|
|
YELLOWFIN_TUNA = 131,
|
|
TENCH_B = 132,
|
|
RUDD = 133,
|
|
KOI_CARP = 134,
|
|
FLATHEAD_GREY_MULLET = 135,
|
|
RAINBOW_TROUT_B = 136,
|
|
BROWN_TROUT_B = 137,
|
|
BROOK_TROUT_B = 138,
|
|
GIANT_KOKOPU = 139,
|
|
BROWN_BULLHEAD_CATFISH = 140,
|
|
SOCKEYE_SALMON_B = 141,
|
|
LONGFIN_EEL = 142,
|
|
CHINOOK_SALMON = 143,
|
|
COUNT = 144
|
|
}
|
|
|
|
public string jkmFishLogs = string.Empty;
|
|
|
|
public int jkmFishId;
|
|
|
|
private bool firstUpdate = true;
|
|
|
|
private bool initialized;
|
|
|
|
public static float MAX_FIGHT_DISTANCE = 20f;
|
|
|
|
public static bool useAvoidance = true;
|
|
|
|
public bool useCollisionRaycasts = true;
|
|
|
|
public bool allowSearch = true;
|
|
|
|
public bool isBaitUpdate;
|
|
|
|
public bool isBoatUpdate;
|
|
|
|
private Vector3 boatAttachPosition = Vector3.zero;
|
|
|
|
public static bool disableLogic;
|
|
|
|
public static bool disableLogic2;
|
|
|
|
public Species species = Species.COUNT;
|
|
|
|
[HideInInspector]
|
|
public FishSpawner fishSpawner;
|
|
|
|
public GameObject modelNormal;
|
|
|
|
public GameObject modelRig;
|
|
|
|
public SkinnedMeshRenderer rigRenderer;
|
|
|
|
public int mainMaterialId;
|
|
|
|
public Material mainMaterial;
|
|
|
|
public List<Material> additionalMainMaterials = new List<Material>();
|
|
|
|
public Material watchMaterial;
|
|
|
|
public Material transparentMaterial;
|
|
|
|
public float vrMaterialSmoothness = 0.8f;
|
|
|
|
[Header("Helpers")]
|
|
public bool isSaltwater;
|
|
|
|
public bool useFishingNet;
|
|
|
|
public bool canBeYoung = true;
|
|
|
|
[ReadOnly]
|
|
public bool isYoung;
|
|
|
|
[ReadOnly]
|
|
public Vector3 prevPosition = Vector3.zero;
|
|
|
|
[HideInInspector]
|
|
public bool isAttracted;
|
|
|
|
[ReadOnly]
|
|
public bool isJerked;
|
|
|
|
[ReadOnly]
|
|
public bool isReleasing;
|
|
|
|
[ReadOnly]
|
|
public bool isInNetArea;
|
|
|
|
[ReadOnly]
|
|
public bool isOnGround;
|
|
|
|
[ReadOnly]
|
|
public bool isTryingBait;
|
|
|
|
[ReadOnly]
|
|
public bool isNearBait;
|
|
|
|
public static float jerkDuration = 5f;
|
|
|
|
public static float jerkDurationThreshold = 3.5f;
|
|
|
|
[ReadOnly]
|
|
public float jerkTimer;
|
|
|
|
[HideInInspector]
|
|
public bool fastDurabilityDrain;
|
|
|
|
public bool canFillet = true;
|
|
|
|
[HideInInspector]
|
|
public Vector3 pullOutPosition = Vector3.zero;
|
|
|
|
[HideInInspector]
|
|
public bool isAvoiding;
|
|
|
|
[HideInInspector]
|
|
public bool withinSightBug;
|
|
|
|
[ReadOnly]
|
|
[Header("Jump")]
|
|
public bool isJumping;
|
|
|
|
[ReadOnly]
|
|
public float jumpTimer = -1f;
|
|
|
|
[ReadOnly]
|
|
public Vector3 jumpTarget = Vector3.zero;
|
|
|
|
public bool useJumps = true;
|
|
|
|
public bool useFightJumps;
|
|
|
|
public float jumpMaxHeight = 1f;
|
|
|
|
public Vector2 jumpDelay = new Vector2(5f, 6f);
|
|
|
|
public float jumpGravity = 4f;
|
|
|
|
public Vector2 jumpRotateSpeed = new Vector2(5f, 5f);
|
|
|
|
[ReadOnly]
|
|
public bool jumpedOverWater;
|
|
|
|
public int indexInFishSpawner = -1;
|
|
|
|
public List<TerrainMod> terrainModifiers = new List<TerrainMod>();
|
|
|
|
[Header("Swim Style")]
|
|
public DepthStyle normalDepthStyle;
|
|
|
|
public float normalDepthLevel = 1f;
|
|
|
|
public DepthStyle fightDepthStyle;
|
|
|
|
public float fightDepthLevel = 1f;
|
|
|
|
public HuntStyle huntStyle;
|
|
|
|
[Header("Styles")]
|
|
public CatchStyle catchStyleCurrent;
|
|
|
|
public CatchStyle catchStyleNormal;
|
|
|
|
public CatchStyle catchStyleFloat = CatchStyle.STOP;
|
|
|
|
public CatchStyle catchStyleGround = CatchStyle.STOP;
|
|
|
|
public CatchStyle catchStyleFly;
|
|
|
|
public WatchStyle watchStyle;
|
|
|
|
[ReadOnly]
|
|
public bool useDifferentWatchStyles;
|
|
|
|
[HideInInspector]
|
|
public Renderer stateIndicator;
|
|
|
|
[HideInInspector]
|
|
public Color idleColor = Color.blue;
|
|
|
|
[HideInInspector]
|
|
public Color hungryColor = Color.grey;
|
|
|
|
[HideInInspector]
|
|
public Color fightColor = Color.red;
|
|
|
|
[HideInInspector]
|
|
public Color followColor = Color.green;
|
|
|
|
[HideInInspector]
|
|
public Color boilieColor = new Color(0.7058824f, 1f, 0.7058824f);
|
|
|
|
[HideInInspector]
|
|
public Color plantColor = new Color(32f / 51f, 32f / 51f, 1f);
|
|
|
|
[HideInInspector]
|
|
public Color caughtColor = Color.black;
|
|
|
|
public Transform mouth;
|
|
|
|
public Vector3 vectorToMouth = Vector3.zero;
|
|
|
|
public BoxCollider boxCollider;
|
|
|
|
[HideInInspector]
|
|
public float minDepth;
|
|
|
|
[Header("Fight")]
|
|
public Vector2 DurabilityStartRange = new Vector2(3f, 5f);
|
|
|
|
[ReadOnly]
|
|
public float DurabilityStart = 4f;
|
|
|
|
[ReadOnly]
|
|
public float DurabilityCurrent = 1f;
|
|
|
|
public static float DurabilityMin = 0.1f;
|
|
|
|
[ReadOnly]
|
|
public float DurabilityCurrentRatio = 1f;
|
|
|
|
[HideInInspector]
|
|
public float DurabilityFightSpeed = 1f;
|
|
|
|
[ReadOnly]
|
|
public float DurabilityIdleSpeed = 0.15f;
|
|
|
|
[ReadOnly]
|
|
public float DurabilityJerkFactor = 0.1f;
|
|
|
|
[HideInInspector]
|
|
public float DurabilityJerkSpeed = 2f;
|
|
|
|
[HideInInspector]
|
|
public float DurabilityHandsRotationFactor = 0.3f;
|
|
|
|
public int DurabilityBoostAmountCurrent = 1;
|
|
|
|
[ReadOnly]
|
|
public float DurabilityBoostDistance = 10f;
|
|
|
|
[ReadOnly]
|
|
public float notPullingTimer = 1f;
|
|
|
|
[ReadOnly]
|
|
public bool notPulling;
|
|
|
|
[ReadOnly]
|
|
public bool isBeingPulled;
|
|
|
|
[Header("Params")]
|
|
[ReadOnly]
|
|
public float Weight = 5f;
|
|
|
|
public Vector2 WeightMinMax = new Vector2(4f, 6f);
|
|
|
|
[ReadOnly]
|
|
public float Length = 1f;
|
|
|
|
public Vector2 LengthMinMax = new Vector2(1f, 2f);
|
|
|
|
[ReadOnly]
|
|
public float HungerLevel = 0.5f;
|
|
|
|
[HideInInspector]
|
|
public static float HungerLevelSpeed = 0.002f;
|
|
|
|
[HideInInspector]
|
|
public float Aggressiveness = 0.5f;
|
|
|
|
public float AggressivenessFight = 0.5f;
|
|
|
|
public float DepthAggressiveness = 0.5f;
|
|
|
|
public float DepthAggressivenessFight = 0.5f;
|
|
|
|
public float FromPlayerAggressiveness = 0.5f;
|
|
|
|
public float Strength = 1f;
|
|
|
|
[ReadOnly]
|
|
public float StrengthForceState;
|
|
|
|
[ReadOnly]
|
|
public float StartStrength = 1f;
|
|
|
|
[ReadOnly]
|
|
public float PrefabStrength = 1f;
|
|
|
|
[ReadOnly]
|
|
public float StrengthForceTimer;
|
|
|
|
[ReadOnly]
|
|
public float StrengthForce;
|
|
|
|
[ReadOnly]
|
|
public int SizeLevel;
|
|
|
|
[ReadOnly]
|
|
public int baitSize = 3;
|
|
|
|
public float fishSpieceSpeed = 0.5f;
|
|
|
|
[ReadOnly]
|
|
public Vector3 fishSpeed = Vector3.one;
|
|
|
|
[ReadOnly]
|
|
public float targetSpeed;
|
|
|
|
[ReadOnly]
|
|
public float currentSpeed;
|
|
|
|
[ReadOnly]
|
|
public float TurnRate = 0.5f;
|
|
|
|
[ReadOnly]
|
|
public float ViewAngle = 90f;
|
|
|
|
[ReadOnly]
|
|
public float ViewDistance = 5f;
|
|
|
|
[HideInInspector]
|
|
public Vector3 Origin = Vector3.zero;
|
|
|
|
public BehaviorTree bt;
|
|
|
|
[ReadOnly]
|
|
public LayerMask collisionMask = -1;
|
|
|
|
[HideInInspector]
|
|
public Vector3 lastTargetPosition = Vector3.zero;
|
|
|
|
[HideInInspector]
|
|
public float lastTargetTime = -10f;
|
|
|
|
[ReadOnly]
|
|
public float pullForce;
|
|
|
|
[HideInInspector]
|
|
public Vector3 pullDirection = Vector3.zero;
|
|
|
|
[HideInInspector]
|
|
public bool pullingUp;
|
|
|
|
[ReadOnly]
|
|
public float fightForce;
|
|
|
|
[HideInInspector]
|
|
public float fightLevel;
|
|
|
|
[HideInInspector]
|
|
public static Fish ticket;
|
|
|
|
public static int ticketCount;
|
|
|
|
[HideInInspector]
|
|
public bool outOfWater;
|
|
|
|
[HideInInspector]
|
|
public float waterDepth = 666f;
|
|
|
|
[HideInInspector]
|
|
public Vector3 terrainLevel = Vector3.zero;
|
|
|
|
[ReadOnly]
|
|
public bool isSeeingBait;
|
|
|
|
[HideInInspector]
|
|
public float fishHalfHeight = 0.5f;
|
|
|
|
[ReadOnly]
|
|
public bool isWatchingFish;
|
|
|
|
[ReadOnly]
|
|
public bool isWatchingFishReady;
|
|
|
|
[ReadOnly]
|
|
public bool isInBoilieTrigger;
|
|
|
|
[ReadOnly]
|
|
public bool isInPlantTrigger;
|
|
|
|
[ReadOnly]
|
|
public GameObject currentTarget;
|
|
|
|
[ReadOnly]
|
|
public Vector3 targetDirection = Vector3.forward;
|
|
|
|
private vp_SurfaceIdentifier surfaceType;
|
|
|
|
private Transform terrainTransform;
|
|
|
|
private float nextTerrainCheck = -1f;
|
|
|
|
private float terrainCheckFrequency = 2f;
|
|
|
|
private float nextBaitEvaluation = -1f;
|
|
|
|
[ReadOnly]
|
|
public bool lastBaitTest = true;
|
|
|
|
public static float baitEvaluationFrequency;
|
|
|
|
private vp_FootstepManager footstepManager;
|
|
|
|
[HideInInspector]
|
|
public string terrainType;
|
|
|
|
[ReadOnly]
|
|
public Bait storedBait;
|
|
|
|
[ReadOnly]
|
|
public float distanceToBait = -1f;
|
|
|
|
[ReadOnly]
|
|
public bool isFighting;
|
|
|
|
[Space(10f)]
|
|
public float moneyFactor = 1f;
|
|
|
|
public float expFactor = 1f;
|
|
|
|
public string fishName = string.Empty;
|
|
|
|
public string fishDescription = string.Empty;
|
|
|
|
private static float minBaitDepth = -10f;
|
|
|
|
private static float maxBaitDepth;
|
|
|
|
private static float minTemperature = -30f;
|
|
|
|
private static float maxTemperature = 50f;
|
|
|
|
private static float minWind;
|
|
|
|
private static float maxWind = 100f;
|
|
|
|
private static float minPressure = 950f;
|
|
|
|
private static float maxPressure = 1050f;
|
|
|
|
[Header("Terrain preferences")]
|
|
[Space(10f)]
|
|
public float GravelChance = 1f;
|
|
|
|
public float GrassChance = 0.5f;
|
|
|
|
public float RockChance;
|
|
|
|
[Header("Bait variables")]
|
|
[Space(10f)]
|
|
public float timeWeight = 1f;
|
|
|
|
public float hungerWeight = 1f;
|
|
|
|
public float baitDepthWeight = 1f;
|
|
|
|
public float temperatureWeight = 1f;
|
|
|
|
public float windWeight = 1f;
|
|
|
|
public float pressureWeight = 1f;
|
|
|
|
public float cloudinessWeight = 1f;
|
|
|
|
public float rainWeight = 1f;
|
|
|
|
public float baitSpeedWeight = 1f;
|
|
|
|
public AnimationCurve timeCurve = AnimationCurve.EaseInOut(0f, 0f, 24f, 0f);
|
|
|
|
public AnimationCurve hungerCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
|
|
|
|
public AnimationCurve baitDepthCurve = AnimationCurve.EaseInOut(minBaitDepth, 0f, maxBaitDepth, 1f);
|
|
|
|
public AnimationCurve temperatureCurve = AnimationCurve.EaseInOut(minTemperature, 0f, maxTemperature, 1f);
|
|
|
|
public AnimationCurve windCurve = AnimationCurve.EaseInOut(minWind, 0f, maxWind, 1f);
|
|
|
|
public AnimationCurve pressureCurve = AnimationCurve.EaseInOut(minPressure, 0f, maxPressure, 1f);
|
|
|
|
public AnimationCurve cloudinessCurve = AnimationCurve.EaseInOut(0f, 0f, 4f, 1f);
|
|
|
|
public AnimationCurve rainCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
|
|
|
|
public AnimationCurve baitSpeedCurve = AnimationCurve.EaseInOut(0f, 0f, 4f, 1f);
|
|
|
|
public AnimationCurve waterPlant = AnimationCurve.EaseInOut(0f, 0f, 24f, 0f);
|
|
|
|
public List<float> spinningMethodFactor = new List<float>();
|
|
|
|
public float floatMethodFactor = 0.5f;
|
|
|
|
private FishBaitEvaluator fbe = new FishBaitEvaluator();
|
|
|
|
[Header("Animation")]
|
|
[Space(10f)]
|
|
public WaterForce waterRipples;
|
|
|
|
public WaterInteractive waterInteractive;
|
|
|
|
public FishAnimationController animController;
|
|
|
|
[ReadOnly]
|
|
public Vector2 targetLookRotation = Vector2.zero;
|
|
|
|
[ReadOnly]
|
|
public Vector2 currentLookRotation = Vector2.zero;
|
|
|
|
public float fishAngleSpeed = 2f;
|
|
|
|
public float fishMaxAngle = 100f;
|
|
|
|
[HideInInspector]
|
|
public LTDescr swimTween;
|
|
|
|
[HideInInspector]
|
|
public float currentSwimAngle;
|
|
|
|
public Vector2 swimSpeedFactor = Vector2.one;
|
|
|
|
public Vector2 swimAngleFactor = Vector2.one;
|
|
|
|
[HideInInspector]
|
|
public ParticleSystem particleSwim;
|
|
|
|
public float changeDirectionDelay = 0.2f;
|
|
|
|
[ReadOnly]
|
|
public float changeDirectionTimer;
|
|
|
|
public bool debugLog;
|
|
|
|
[HideInInspector]
|
|
public GameController gameController;
|
|
|
|
[HideInInspector]
|
|
public FishingPlayer fishingPlayer;
|
|
|
|
public Rigidbody rigidbody;
|
|
|
|
[HideInInspector]
|
|
public KGFMapIcon fishMapIcon;
|
|
|
|
[HideInInspector]
|
|
public FishFight fishFight;
|
|
|
|
private RaycastHit hit = default(RaycastHit);
|
|
|
|
[HideInInspector]
|
|
public new Transform transform;
|
|
|
|
private static int jkmNumFish;
|
|
|
|
public FishDebugMarker debugMarker;
|
|
|
|
private float depthSensorCheckTimer;
|
|
|
|
[ReadOnly]
|
|
public string jkmDontLike = string.Empty;
|
|
|
|
public string logColor = "black";
|
|
|
|
private static bool jkmIgnorPopularExit = true;
|
|
|
|
public static float minimumDepth = -15f;
|
|
|
|
private bool isToSmoll;
|
|
|
|
[SerializeField]
|
|
private bool useConstansDurabilityStartRange;
|
|
|
|
public bool isInitialized
|
|
{
|
|
get
|
|
{
|
|
return initialized;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
Validata();
|
|
transform = GetComponent<Transform>();
|
|
PrefabStrength = Strength;
|
|
}
|
|
|
|
private void Validata()
|
|
{
|
|
if (!mouth)
|
|
{
|
|
Debug.LogError("No mouth in fish " + base.name);
|
|
Debug.Break();
|
|
}
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
jkmNumFish++;
|
|
jkmFishId = jkmNumFish;
|
|
if (!transform)
|
|
{
|
|
Debug.LogError("No transform in " + base.name);
|
|
}
|
|
if (transform.parent == null)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
if (!initialized)
|
|
{
|
|
gameController = GameController.Instance;
|
|
fishingPlayer = gameController.fishingPlayer;
|
|
if (rigidbody == null)
|
|
{
|
|
rigidbody = GetComponent<Rigidbody>();
|
|
}
|
|
allowSearch = true;
|
|
ChangeMaterial(false);
|
|
}
|
|
if ((bool)gameController.hudManager && (bool)gameController.hudManager.kgfMapSystem && !initialized)
|
|
{
|
|
fishMapIcon = UnityEngine.Object.Instantiate(gameController.hudManager.fishMapIconPrefab);
|
|
fishMapIcon.transform.parent = transform;
|
|
fishMapIcon.transform.localPosition = Vector3.zero;
|
|
ShowIcon(false);
|
|
}
|
|
if (!initialized)
|
|
{
|
|
AmplifyMotionObjectBase[] componentsInChildren = GetComponentsInChildren<AmplifyMotionObjectBase>(true);
|
|
if (componentsInChildren != null)
|
|
{
|
|
AmplifyMotionObjectBase[] array = componentsInChildren;
|
|
foreach (AmplifyMotionObjectBase amplifyMotionObjectBase in array)
|
|
{
|
|
AmplifyMotionEffect.Instance.Unregister(amplifyMotionObjectBase.gameObject);
|
|
amplifyMotionObjectBase.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
isYoung = canBeYoung && UnityEngine.Random.Range(0f, 1f) < gameController.youngFishChance;
|
|
isYoung = false;
|
|
if (isYoung)
|
|
{
|
|
watchStyle = WatchStyle.HOOK_LIGHT;
|
|
}
|
|
float num = 0f;
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
Vector2 fishLevelSize = GlobalSettings.Instance.fishManager.GetFishLevelSize(species);
|
|
if (gameController.iceLevel)
|
|
{
|
|
float num2 = 1.4f;
|
|
if (Mathf.Lerp(LengthMinMax.x, LengthMinMax.y, fishLevelSize.y) > num2)
|
|
{
|
|
fishLevelSize.y = num2 / LengthMinMax.y;
|
|
}
|
|
}
|
|
num = UnityEngine.Random.Range(fishLevelSize.x, fishLevelSize.y);
|
|
}
|
|
else if (isYoung)
|
|
{
|
|
num = UnityEngine.Random.Range(0f, 0.2f);
|
|
}
|
|
else
|
|
{
|
|
Vector2 vector = new Vector2(0f, 1f);
|
|
if (gameController.iceLevel)
|
|
{
|
|
float num3 = 1.2f;
|
|
if (Mathf.Lerp(LengthMinMax.x, LengthMinMax.y, vector.y) > num3)
|
|
{
|
|
vector.y = num3 / LengthMinMax.y;
|
|
}
|
|
}
|
|
num = UnityEngine.Random.Range(vector.x, vector.y);
|
|
}
|
|
if (!isYoung)
|
|
{
|
|
num *= gameController.fishSizeMultiplier;
|
|
num *= fishSpawner.fishSizeMultiplier;
|
|
}
|
|
num = Mathf.Clamp(num, 0f, 1f);
|
|
if (num > 0.66f)
|
|
{
|
|
SizeLevel = 3;
|
|
}
|
|
else if (num > 0.33f)
|
|
{
|
|
SizeLevel = 2;
|
|
}
|
|
else
|
|
{
|
|
SizeLevel = 1;
|
|
}
|
|
Length = Mathf.Lerp(LengthMinMax.x, LengthMinMax.y, num);
|
|
Weight = Mathf.Lerp(WeightMinMax.x, WeightMinMax.y, num * num * num);
|
|
Strength = PrefabStrength * Mathf.InverseLerp(0.1f, 2f, Length);
|
|
if (Length > 2f)
|
|
{
|
|
Strength += Mathf.InverseLerp(2f, 5.5f, Length);
|
|
}
|
|
if (Length < 0.4f || isYoung)
|
|
{
|
|
baitSize = 1;
|
|
}
|
|
else if (Length < 0.7f)
|
|
{
|
|
baitSize = 2;
|
|
}
|
|
else if (Length < 1.3f)
|
|
{
|
|
baitSize = 3;
|
|
}
|
|
else if (Length < 2.6f)
|
|
{
|
|
baitSize = 4;
|
|
}
|
|
else
|
|
{
|
|
baitSize = 5;
|
|
}
|
|
if (baitSize == 1)
|
|
{
|
|
}
|
|
if (watchStyle != WatchStyle.BOAT)
|
|
{
|
|
watchStyle = ((Weight > 8f || gameController.fishingNetTest) ? WatchStyle.HANDS : WatchStyle.HOOK_LIGHT);
|
|
}
|
|
else if (Weight < 8f && Length < 1f)
|
|
{
|
|
watchStyle = WatchStyle.HOOK_LIGHT;
|
|
}
|
|
else if (Length < 1.8f)
|
|
{
|
|
watchStyle = WatchStyle.HANDS;
|
|
}
|
|
if (gameController.iceLevel)
|
|
{
|
|
watchStyle = WatchStyle.HOOK_LIGHT;
|
|
}
|
|
if (!GlobalSettings.Instance)
|
|
{
|
|
}
|
|
if (isYoung)
|
|
{
|
|
Weight *= gameController.youngSizeFactor;
|
|
Length *= gameController.youngSizeFactor;
|
|
Strength *= gameController.youngSizeFactor;
|
|
}
|
|
fishMapIcon.itsDataMapIcon.itsIconScale = Mathf.Lerp(0.02f, 0.085f, Length / 3.5f);
|
|
StartStrength = Strength;
|
|
transform.localScale = Vector3.one * Length;
|
|
stateIndicator.transform.localScale *= 0.2f / stateIndicator.transform.lossyScale.x;
|
|
if (isYoung)
|
|
{
|
|
stateIndicator.transform.localScale *= gameController.youngSizeFactor;
|
|
}
|
|
if (!useConstansDurabilityStartRange)
|
|
{
|
|
DurabilityStartRange = Vector2.one * Mathf.Lerp(4f, 190f, Mathf.InverseLerp(0.1f, 5f, Length));
|
|
}
|
|
if (fastDurabilityDrain)
|
|
{
|
|
DurabilityStart = 0.1f;
|
|
}
|
|
else
|
|
{
|
|
DurabilityStart = UnityEngine.Random.Range(DurabilityStartRange.x, DurabilityStartRange.y);
|
|
}
|
|
if (isYoung)
|
|
{
|
|
DurabilityStart *= gameController.youngSizeFactor;
|
|
}
|
|
if ((bool)GlobalSettings.Instance && !GlobalSettings.Instance.playerSettings.IsCasual())
|
|
{
|
|
DurabilityStart *= 1.2f;
|
|
}
|
|
fishSpeed.x = 2f;
|
|
fishSpeed.y = 8f;
|
|
fishSpeed.z = 6f;
|
|
fishSpeed *= fishSpieceSpeed;
|
|
if (isYoung)
|
|
{
|
|
fishSpeed *= gameController.youngSizeFactor;
|
|
}
|
|
else
|
|
{
|
|
fishSpeed *= Mathf.Lerp(0.4f, 1f, num);
|
|
}
|
|
HungerLevel = UnityEngine.Random.value * 0.5f;
|
|
if (baitSize == 1)
|
|
{
|
|
HungerLevel *= 0.5f;
|
|
}
|
|
HungerLevel = 0f;
|
|
if (GameController.Instance.jumpTest)
|
|
{
|
|
jumpTimer = UnityEngine.Random.Range(5f, 6f);
|
|
}
|
|
else
|
|
{
|
|
jumpTimer = UnityEngine.Random.Range(120f, 360f);
|
|
}
|
|
jumpGravity = 2f;
|
|
jumpRotateSpeed.x = 5f;
|
|
jumpRotateSpeed.y = 0f;
|
|
notPulling = true;
|
|
notPullingTimer = 20f;
|
|
DurabilityFightSpeed = 1f;
|
|
DurabilityJerkFactor = 0.009f;
|
|
DurabilityJerkSpeed = 1.5f;
|
|
DurabilityHandsRotationFactor = 0.3f;
|
|
changeDirectionDelay = 0.1f;
|
|
if (!initialized)
|
|
{
|
|
terrainModifiers.Add(new TerrainMod("Gravel", GravelChance));
|
|
terrainModifiers.Add(new TerrainMod("Grass", GrassChance));
|
|
terrainModifiers.Add(new TerrainMod("Rock", RockChance));
|
|
}
|
|
if (!initialized)
|
|
{
|
|
fbe.AddElement("time", timeCurve, 0f, 24f, timeWeight);
|
|
fbe.AddElement("hunger", hungerCurve, 0f, 1f, hungerWeight);
|
|
fbe.AddElement("baitDepth", baitDepthCurve, minBaitDepth, maxBaitDepth, baitDepthWeight);
|
|
fbe.AddElement("temperature", temperatureCurve, minTemperature, maxTemperature, temperatureWeight);
|
|
fbe.AddElement("wind", windCurve, minWind, maxWind, windWeight);
|
|
fbe.AddElement("pressure", pressureCurve, minPressure, maxPressure, pressureWeight);
|
|
fbe.AddElement("clouds", cloudinessCurve, 0f, 1f, cloudinessWeight);
|
|
fbe.AddElement("rain", rainCurve, 0f, 1f, rainWeight);
|
|
fbe.AddElement("baitSpeed", baitSpeedCurve, 0f, 4f, baitSpeedWeight);
|
|
}
|
|
if ((int)collisionMask == -1)
|
|
{
|
|
collisionMask = LayerMask.GetMask("Terrain", "Default", "Boat", "MovingPlatform");
|
|
}
|
|
if (boxCollider == null)
|
|
{
|
|
boxCollider = GetComponent<BoxCollider>();
|
|
}
|
|
minDepth = (0f - boxCollider.size.y) * 1f;
|
|
if (gameController.iceLevel)
|
|
{
|
|
minDepth -= 0.65f;
|
|
}
|
|
Transform parent = mouth.parent;
|
|
mouth.parent = transform;
|
|
vectorToMouth = mouth.localPosition;
|
|
mouth.parent = parent;
|
|
if (!initialized)
|
|
{
|
|
Origin = transform.position;
|
|
targetDirection = transform.forward;
|
|
}
|
|
nextBaitEvaluation = Time.time + baitEvaluationFrequency + UnityEngine.Random.Range(0f, 4f);
|
|
if (AggressivenessFight < 0.3f)
|
|
{
|
|
AggressivenessFight = 0.1f;
|
|
}
|
|
else if (AggressivenessFight < 0.7f)
|
|
{
|
|
AggressivenessFight = 0.5f;
|
|
}
|
|
else
|
|
{
|
|
AggressivenessFight = 1f;
|
|
}
|
|
if (DepthAggressivenessFight < 0.3f)
|
|
{
|
|
DepthAggressivenessFight = 0.1f;
|
|
}
|
|
else if (DepthAggressivenessFight < 0.7f)
|
|
{
|
|
DepthAggressivenessFight = 0.5f;
|
|
}
|
|
else
|
|
{
|
|
DepthAggressivenessFight = 1f;
|
|
}
|
|
FromPlayerAggressiveness = 1f - AggressivenessFight;
|
|
if (normalDepthStyle == DepthStyle.WATER_LEVEL && normalDepthLevel > 0f)
|
|
{
|
|
normalDepthLevel = 0f;
|
|
}
|
|
else if (normalDepthStyle == DepthStyle.GROUND_LEVEL && normalDepthLevel < 0.5f)
|
|
{
|
|
normalDepthLevel = 0.5f;
|
|
}
|
|
if (fightDepthStyle == DepthStyle.WATER_LEVEL && fightDepthLevel > 0f)
|
|
{
|
|
fightDepthLevel = 0f;
|
|
}
|
|
else if (fightDepthStyle == DepthStyle.GROUND_LEVEL && fightDepthLevel < 1f)
|
|
{
|
|
fightDepthLevel = 1f;
|
|
}
|
|
if (!initialized)
|
|
{
|
|
if (bt == null)
|
|
{
|
|
bt = transform.GetComponent<BehaviorTree>();
|
|
}
|
|
ViewDistance = gameController.fishViewDistance;
|
|
bt.SetVariable("ViewDistance", (SharedFloat)ViewDistance);
|
|
bt.SetVariable("ViewAngle", (SharedFloat)ViewAngle);
|
|
bt.SetVariable("TurnRate", (SharedFloat)TurnRate);
|
|
bt.SetVariable("Origin", (SharedVector3)Origin);
|
|
bt.SetVariable("IsFighting", (SharedBool)false);
|
|
bt.SetVariable("TargetDirection", (SharedVector3)transform.forward);
|
|
bt.SetVariable("ArriveDistance", (SharedFloat)0.05f);
|
|
stateIndicator.material.color = idleColor;
|
|
if (animController == null)
|
|
{
|
|
animController = GetComponent<FishAnimationController>();
|
|
}
|
|
animController.Initialize();
|
|
ShowRigged(false);
|
|
}
|
|
if ((bool)gameController)
|
|
{
|
|
stateIndicator.gameObject.SetActive(gameController.showFishIndicator);
|
|
if (gameController.iceLevel)
|
|
{
|
|
float num4 = 0.7f;
|
|
num4 = 1f;
|
|
DurabilityStart *= num4;
|
|
Strength *= num4;
|
|
Aggressiveness *= num4;
|
|
AggressivenessFight *= num4;
|
|
DepthAggressiveness *= num4;
|
|
DepthAggressivenessFight *= num4;
|
|
fishSpeed *= num4;
|
|
useJumps = false;
|
|
useFightJumps = false;
|
|
}
|
|
}
|
|
DurabilityCurrent = DurabilityStart;
|
|
lastTargetTime = -10f;
|
|
if (!initialized)
|
|
{
|
|
particleSwim = UnityEngine.Object.Instantiate(GameController.Instance.waterEffectsManager.GetSwimParticlePrefab(WaterEffectsManager.SplashSize.SMALL));
|
|
}
|
|
particleSwim.Stop();
|
|
particleSwim.transform.parent = mouth;
|
|
particleSwim.transform.localPosition = Vector3.zero;
|
|
if (!initialized)
|
|
{
|
|
GameController.Instance.waterEffectsManager.InitParticleDisplacement(particleSwim);
|
|
}
|
|
if (waterInteractive == null)
|
|
{
|
|
waterInteractive = GetComponentInChildren<WaterInteractive>();
|
|
}
|
|
waterInteractive.Multiplier = 2.5f;
|
|
if ((bool)waterRipples)
|
|
{
|
|
waterRipples.gameObject.SetActive(false);
|
|
}
|
|
if ((bool)waterInteractive && !initialized)
|
|
{
|
|
waterInteractive.GetComponent<MeshRenderer>().material = gameController.waterInteractiveMaterial;
|
|
if (GameController.Instance.iceLevel)
|
|
{
|
|
waterInteractive.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
if (!initialized)
|
|
{
|
|
Utilities.SetLayerRecursively(base.gameObject, "Fish");
|
|
Utilities.SetLayerRecursively(stateIndicator.gameObject, "Debug");
|
|
footstepManager = fishingPlayer.ufpsFootstepManager;
|
|
}
|
|
UpdateDepthSensor();
|
|
initialized = true;
|
|
}
|
|
|
|
public void InitializeTrophyRoom(FishManager.FishDefinition fishDefinition)
|
|
{
|
|
if (!initialized)
|
|
{
|
|
if (rigidbody == null)
|
|
{
|
|
rigidbody = GetComponent<Rigidbody>();
|
|
}
|
|
allowSearch = true;
|
|
ChangeMaterial(false);
|
|
}
|
|
if (!initialized)
|
|
{
|
|
AmplifyMotionObjectBase[] componentsInChildren = GetComponentsInChildren<AmplifyMotionObjectBase>(true);
|
|
if (componentsInChildren != null)
|
|
{
|
|
AmplifyMotionObjectBase[] array = componentsInChildren;
|
|
foreach (AmplifyMotionObjectBase amplifyMotionObjectBase in array)
|
|
{
|
|
AmplifyMotionEffect.Instance.Unregister(amplifyMotionObjectBase.gameObject);
|
|
amplifyMotionObjectBase.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
isYoung = false;
|
|
float num = 0.5f;
|
|
if (fishDefinition != null)
|
|
{
|
|
Length = fishDefinition.length;
|
|
Weight = fishDefinition.weight;
|
|
num = Mathf.InverseLerp(LengthMinMax.x, LengthMinMax.y, Length);
|
|
}
|
|
else
|
|
{
|
|
Length = Mathf.Lerp(LengthMinMax.x, LengthMinMax.y, num);
|
|
Weight = Mathf.Lerp(WeightMinMax.x, WeightMinMax.y, num * num * num);
|
|
}
|
|
transform.localScale = Vector3.one * Length;
|
|
stateIndicator.transform.localScale *= 0.2f / stateIndicator.transform.lossyScale.x;
|
|
fishSpeed.x = 2f;
|
|
fishSpeed.y = 8f;
|
|
fishSpeed.z = 6f;
|
|
fishSpeed *= fishSpieceSpeed;
|
|
fishSpeed *= Mathf.Lerp(0.4f, 1f, num);
|
|
changeDirectionDelay = 0.1f;
|
|
if ((int)collisionMask == -1)
|
|
{
|
|
collisionMask = LayerMask.GetMask("Terrain", "Default", "Boat", "MovingPlatform");
|
|
}
|
|
if (boxCollider == null)
|
|
{
|
|
boxCollider = GetComponent<BoxCollider>();
|
|
}
|
|
minDepth = (0f - boxCollider.size.y) * 1f;
|
|
Transform parent = mouth.parent;
|
|
mouth.parent = transform;
|
|
vectorToMouth = mouth.localPosition;
|
|
mouth.parent = parent;
|
|
if (!initialized)
|
|
{
|
|
Origin = transform.position;
|
|
targetDirection = transform.forward;
|
|
}
|
|
nextBaitEvaluation = Time.time + baitEvaluationFrequency + UnityEngine.Random.Range(0f, 4f);
|
|
if (normalDepthStyle == DepthStyle.WATER_LEVEL && normalDepthLevel > 0f)
|
|
{
|
|
normalDepthLevel = 0f;
|
|
}
|
|
else if (normalDepthStyle == DepthStyle.GROUND_LEVEL && normalDepthLevel < 0.5f)
|
|
{
|
|
normalDepthLevel = 0.5f;
|
|
}
|
|
if (fightDepthStyle == DepthStyle.WATER_LEVEL && fightDepthLevel > 0f)
|
|
{
|
|
fightDepthLevel = 0f;
|
|
}
|
|
else if (fightDepthStyle == DepthStyle.GROUND_LEVEL && fightDepthLevel < 1f)
|
|
{
|
|
fightDepthLevel = 1f;
|
|
}
|
|
if (!initialized)
|
|
{
|
|
if (bt == null)
|
|
{
|
|
bt = transform.GetComponent<BehaviorTree>();
|
|
}
|
|
bt.SetVariable("ViewDistance", (SharedFloat)ViewDistance);
|
|
bt.SetVariable("ViewAngle", (SharedFloat)ViewAngle);
|
|
bt.SetVariable("TurnRate", (SharedFloat)TurnRate);
|
|
bt.SetVariable("Origin", (SharedVector3)Origin);
|
|
bt.SetVariable("IsFighting", (SharedBool)false);
|
|
bt.SetVariable("TargetDirection", (SharedVector3)transform.forward);
|
|
bt.SetVariable("ArriveDistance", (SharedFloat)0.05f);
|
|
stateIndicator.material.color = idleColor;
|
|
if (animController == null)
|
|
{
|
|
animController = GetComponent<FishAnimationController>();
|
|
}
|
|
animController.Initialize();
|
|
ShowRigged(false);
|
|
}
|
|
lastTargetTime = -10f;
|
|
if (waterInteractive == null)
|
|
{
|
|
waterInteractive = GetComponentInChildren<WaterInteractive>();
|
|
}
|
|
waterInteractive.Multiplier = 2.5f;
|
|
if ((bool)waterRipples)
|
|
{
|
|
waterRipples.gameObject.SetActive(false);
|
|
}
|
|
waterInteractive.gameObject.SetActive(false);
|
|
if (!initialized)
|
|
{
|
|
Utilities.SetLayerRecursively(base.gameObject, "Fish");
|
|
Utilities.SetLayerRecursively(stateIndicator.gameObject, "Debug");
|
|
}
|
|
ShowRigged(true);
|
|
bt.enabled = true;
|
|
boxCollider.enabled = true;
|
|
allowSearch = true;
|
|
initialized = true;
|
|
}
|
|
|
|
[Button]
|
|
public void ChangeSize()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if ((bool)gameController)
|
|
{
|
|
stateIndicator.gameObject.SetActive(false);
|
|
ShowIcon(false);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!TrophyRoomManager.Instance)
|
|
{
|
|
if (gameController == null)
|
|
{
|
|
base.enabled = false;
|
|
bt = transform.GetComponent<BehaviorTree>();
|
|
DisableAI();
|
|
stateIndicator.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
if (fishingPlayer == null)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
if ((bool)gameController && ViewDistance != gameController.fishViewCurrentDistance)
|
|
{
|
|
ViewDistance = gameController.fishViewCurrentDistance;
|
|
bt.SetVariable("ViewDistance", (SharedFloat)ViewDistance);
|
|
}
|
|
if ((bool)modelRig && modelRig.activeSelf)
|
|
{
|
|
animController.SwimAnimationUpdate();
|
|
}
|
|
if (isWatchingFishReady && watchStyle == WatchStyle.HOOK_LIGHT && VRManager.Instance.IsVRHoldRod())
|
|
{
|
|
Vector3 vRBaitHoldPosition = fishingPlayer.currentHands.fishingRod.GetVRBaitHoldPosition(true);
|
|
float num = Vector3.Distance(transform.position, vRBaitHoldPosition);
|
|
transform.position = Vector3.MoveTowards(transform.position, vRBaitHoldPosition, ((!gameController.iceLevel) ? 6f : 10f) * num * Time.deltaTime);
|
|
}
|
|
if (!bt.enabled)
|
|
{
|
|
return;
|
|
}
|
|
if (isFighting)
|
|
{
|
|
CalcSpeedForce();
|
|
}
|
|
if ((bool)storedBait)
|
|
{
|
|
if (storedBait.fishingHands.fishingPlayer.IsTrolling() && storedBait.fishingHands.fishingPlayer.boatSimulator.HasRodsOnPod())
|
|
{
|
|
catchStyleCurrent = catchStyleNormal;
|
|
}
|
|
else if (storedBait.HasAnyLiveBait())
|
|
{
|
|
catchStyleCurrent = catchStyleNormal;
|
|
}
|
|
else if ((bool)storedBait.fishingHands.fishingFloat)
|
|
{
|
|
catchStyleCurrent = catchStyleFloat;
|
|
}
|
|
else if (storedBait.fishingHands.isGroundRig)
|
|
{
|
|
catchStyleCurrent = catchStyleGround;
|
|
}
|
|
else
|
|
{
|
|
catchStyleCurrent = catchStyleNormal;
|
|
}
|
|
}
|
|
if ((bool)particleSwim)
|
|
{
|
|
if (!gameController.iceLevel && !isWatchingFish && !isInNetArea && !isTryingBait && isFighting && transform.position.y >= -0.5f)
|
|
{
|
|
particleSwim.transform.position = new Vector3(mouth.position.x, mouth.position.y + 0.7f, mouth.position.z);
|
|
particleSwim.transform.position += transform.forward * 0.4f;
|
|
particleSwim.transform.eulerAngles = new Vector3(-90f, 0f, 0f);
|
|
if (!particleSwim.isPlaying && !isInNetArea)
|
|
{
|
|
particleSwim.Play();
|
|
AudioController.Play("SplashFish_01", Mathf.Lerp(0.5f, 1f, Mathf.InverseLerp(0.1f, 5f, Length)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
particleSwim.Stop();
|
|
}
|
|
}
|
|
if (isFighting)
|
|
{
|
|
gameController.waterEffectsManager.SplashWakeLoopeEffect(particleSwim.isPlaying && !isInNetArea, particleSwim.transform.position, 9f);
|
|
}
|
|
UpdateWaterRipples();
|
|
if (isBaitUpdate)
|
|
{
|
|
return;
|
|
}
|
|
if (isBoatUpdate)
|
|
{
|
|
transform.localPosition = boatAttachPosition;
|
|
transform.position = new Vector3(transform.position.x, -1f, transform.position.z);
|
|
return;
|
|
}
|
|
if (isSeeingBait || ((SharedGameObject)bt.GetVariable("Target")).Value != null)
|
|
{
|
|
distanceToBait = Vector3.Distance(fishingPlayer.currentHands.bait.transform.position, transform.position);
|
|
if ((bool)fishingPlayer.fish)
|
|
{
|
|
StopSeeingBait();
|
|
jkmFishPanel.AddFishText(this, string.Concat("StopSeeingBait(playerHasFish[", fishingPlayer.fish, "])"), logColor);
|
|
}
|
|
else if (!fishingPlayer.currentHands.bait.isOnWater && (!FishingHands.rodStand || FishingHands.rodStand.rodPlacesOccupied == 0))
|
|
{
|
|
StopSeeingBait();
|
|
jkmFishPanel.AddFishText(this, "StopSeeingBait(baitNotIsOnWater)", logColor);
|
|
}
|
|
else if ((bool)ticket && ticket != this && ticket.distanceToBait > 0f && ticket.distanceToBait < 7f)
|
|
{
|
|
Debug.Log("StopSeeingBait");
|
|
jkmFishPanel.AddFishText(this, "StopSeeingBait(ticket.distanceToBait=" + ticket.distanceToBait + ")", logColor);
|
|
StopSeeingBait();
|
|
}
|
|
}
|
|
UpdateStateIndicator();
|
|
if (useAvoidance)
|
|
{
|
|
UpdateDepthSensor();
|
|
}
|
|
UpdateTargetPosition();
|
|
if (isAttracted)
|
|
{
|
|
}
|
|
if (firstUpdate)
|
|
{
|
|
firstUpdate = false;
|
|
}
|
|
if (!GlobalSettings.Instance)
|
|
{
|
|
}
|
|
if (((useJumps && !isFighting) || (useFightJumps && isFighting)) && jumpTimer > 0f)
|
|
{
|
|
jumpTimer -= Time.deltaTime;
|
|
if (jumpTimer <= 0f)
|
|
{
|
|
Jump();
|
|
}
|
|
}
|
|
if (!isFighting && !isWatchingFish)
|
|
{
|
|
HungerLevel -= HungerLevelSpeed * Time.deltaTime;
|
|
if (HungerLevel < 0f)
|
|
{
|
|
HungerLevel = 0f;
|
|
}
|
|
}
|
|
if (changeDirectionTimer > 0f)
|
|
{
|
|
changeDirectionTimer -= Time.deltaTime;
|
|
}
|
|
if (isFighting && !modelRig.activeSelf)
|
|
{
|
|
Utilities.LogError("isFighting && modelRig.activeSelf == false", "orange");
|
|
ShowRigged(true);
|
|
}
|
|
}
|
|
|
|
public void UpdateStateIndicator()
|
|
{
|
|
GameObject gameObject = null;
|
|
if (bt != null)
|
|
{
|
|
gameObject = ((SharedGameObject)bt.GetVariable("Target")).Value;
|
|
}
|
|
if (!gameController || !gameController.showFishIndicator)
|
|
{
|
|
return;
|
|
}
|
|
if (bt == null || !bt.enabled)
|
|
{
|
|
stateIndicator.material.color = caughtColor;
|
|
}
|
|
else if (isFighting)
|
|
{
|
|
stateIndicator.material.color = Color.Lerp(Color.yellow, fightColor, fightForce);
|
|
}
|
|
else if ((bool)gameObject || SeenTargetRecently())
|
|
{
|
|
if ((bool)gameObject && gameObject.HasTag("BOILIE"))
|
|
{
|
|
stateIndicator.material.color = boilieColor;
|
|
}
|
|
else if (ticket == this)
|
|
{
|
|
stateIndicator.material.color = Color.cyan;
|
|
}
|
|
else
|
|
{
|
|
stateIndicator.material.color = followColor;
|
|
}
|
|
}
|
|
else if (isSeeingBait)
|
|
{
|
|
if (!isToSmoll)
|
|
{
|
|
stateIndicator.material.color = Color.white;
|
|
}
|
|
else
|
|
{
|
|
stateIndicator.material.color = Color.black;
|
|
}
|
|
}
|
|
else if (HungerLevel > 0.3f)
|
|
{
|
|
stateIndicator.material.color = hungryColor;
|
|
}
|
|
else if (!isAttracted && stateIndicator.material.color == Color.magenta)
|
|
{
|
|
stateIndicator.material.color = caughtColor;
|
|
}
|
|
else
|
|
{
|
|
stateIndicator.material.color = idleColor;
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (fishingPlayer == null)
|
|
{
|
|
return;
|
|
}
|
|
if (isBaitUpdate && !isWatchingFish)
|
|
{
|
|
if (storedBait.transform.position.y > -0.1f)
|
|
{
|
|
storedBait.transform.position = new Vector3(storedBait.transform.position.x, -0.1f, storedBait.transform.position.z);
|
|
Debug.LogError("Bait over water");
|
|
}
|
|
transform.position = storedBait.catchPosition.position + (transform.position - mouth.position);
|
|
Vector3 eulerAngles = storedBait.catchPosition.eulerAngles;
|
|
eulerAngles.x = Mathf.Clamp(0f - eulerAngles.x, -20f, 20f);
|
|
eulerAngles.y += 180f;
|
|
transform.eulerAngles = eulerAngles;
|
|
}
|
|
if (isInNetArea && !isWatchingFish)
|
|
{
|
|
transform.position = storedBait.catchPosition.position + (transform.position - mouth.position);
|
|
transform.position = Vector3.MoveTowards(transform.position, storedBait.catchPosition.position + (transform.position - mouth.position), 0.2f);
|
|
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, (!animController.fishAnimSwim.useXAxisForSwim) ? (-90f) : 0f)), 1.5f);
|
|
return;
|
|
}
|
|
if (!isOnGround || !isWatchingFish)
|
|
{
|
|
}
|
|
if (!isNearBait || !storedBait || storedBait.fishingHands.isGroundRig)
|
|
{
|
|
}
|
|
if (!isWatchingFishReady || watchStyle != WatchStyle.HOOK_LIGHT || VRManager.Instance.IsVRHoldRod())
|
|
{
|
|
}
|
|
if (!bt.enabled)
|
|
{
|
|
return;
|
|
}
|
|
if (!isWatchingFish)
|
|
{
|
|
if (isBaitUpdate)
|
|
{
|
|
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0f)), 2f);
|
|
}
|
|
else
|
|
{
|
|
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0f)), 2f);
|
|
}
|
|
}
|
|
DurabilityCurrentRatio = DurabilityCurrent / DurabilityStart;
|
|
}
|
|
|
|
public void UpdateWaterRipples()
|
|
{
|
|
}
|
|
|
|
private void UpdateTargetPosition()
|
|
{
|
|
if (isFighting || isWatchingFish)
|
|
{
|
|
return;
|
|
}
|
|
GameObject value = ((SharedGameObject)bt.GetVariable("Target")).Value;
|
|
Bait bait = null;
|
|
if ((bool)value)
|
|
{
|
|
bait = value.GetComponent<Bait>();
|
|
}
|
|
if (ticket == this && (!SeenTargetRecently() || !bait || !bait.isOnWater || bait.isNearPlayer || bait.transform.position.y > 0.05f || isWatchingFish))
|
|
{
|
|
lastTargetTime = -1f;
|
|
storedBait = null;
|
|
ticket = null;
|
|
if ((bool)fishSpawner)
|
|
{
|
|
fishSpawner.HideOtherDuringFight(this, false);
|
|
}
|
|
UpdateTargetSpeed();
|
|
}
|
|
else
|
|
{
|
|
if (!bait || !bait.isOnWater || !(bait.transform.position.y <= 0.05f))
|
|
{
|
|
return;
|
|
}
|
|
lastTargetPosition = bait.transform.position;
|
|
lastTargetTime = Time.time;
|
|
bool flag = ticket == null;
|
|
if (ticket != null)
|
|
{
|
|
if (ticket.distanceToBait > 5f && distanceToBait < ticket.distanceToBait)
|
|
{
|
|
Debug.Log("Change Fish Ticket: " + distanceToBait);
|
|
ticket.storedBait = null;
|
|
flag = true;
|
|
}
|
|
else if (!(ticket != this))
|
|
{
|
|
}
|
|
}
|
|
if (flag)
|
|
{
|
|
storedBait = bait;
|
|
ticket = this;
|
|
if ((bool)fishSpawner)
|
|
{
|
|
fishSpawner.HideOtherDuringFight(this, true);
|
|
}
|
|
UpdateTargetSpeed();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowRigged(bool show)
|
|
{
|
|
if ((bool)modelRig && modelRig.activeSelf != show)
|
|
{
|
|
modelNormal.SetActive(!show);
|
|
modelRig.SetActive(show);
|
|
animController.fishAnimSwim.enabled = show;
|
|
}
|
|
}
|
|
|
|
public int GetMoneyPrize()
|
|
{
|
|
if ((bool)gameController.fisheryEditorGame)
|
|
{
|
|
return 0;
|
|
}
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
return GlobalSettings.Instance.playerSettings.GetFishToMoney(Weight, moneyFactor);
|
|
}
|
|
return Mathf.RoundToInt(Weight);
|
|
}
|
|
|
|
public int GetExpPrize()
|
|
{
|
|
if ((bool)gameController && (bool)gameController.fisheryEditorGame)
|
|
{
|
|
return 0;
|
|
}
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
return GlobalSettings.Instance.playerSettings.GetFishToExp(Weight, expFactor);
|
|
}
|
|
return Mathf.RoundToInt(Weight);
|
|
}
|
|
|
|
public bool SeenTargetRecently()
|
|
{
|
|
return lastTargetTime + 2.5f > Time.time;
|
|
}
|
|
|
|
public void UpdateDepthSensor()
|
|
{
|
|
depthSensorCheckTimer -= Time.deltaTime;
|
|
if (isFighting || depthSensorCheckTimer <= 0f)
|
|
{
|
|
depthSensorCheckTimer = 0.2f;
|
|
Vector3 position = transform.position;
|
|
position.y = 10f;
|
|
if (Physics.Raycast(position, -Vector3.up, out hit, 50f, LayerMask.GetMask("Terrain", "Default")))
|
|
{
|
|
waterDepth = hit.distance - position.y;
|
|
terrainLevel = hit.point;
|
|
terrainTransform = hit.transform;
|
|
}
|
|
else
|
|
{
|
|
waterDepth = 666f;
|
|
terrainLevel.y = -50f;
|
|
terrainTransform = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UpdateTerrainType()
|
|
{
|
|
if (!(nextTerrainCheck < Time.time) || !(terrainTransform != null))
|
|
{
|
|
return;
|
|
}
|
|
Terrain component = terrainTransform.GetComponent<Terrain>();
|
|
Texture2D texture2D = null;
|
|
if (component != null)
|
|
{
|
|
int mainTerrainTexture = vp_FootstepManager.GetMainTerrainTexture(transform.position, component);
|
|
if (mainTerrainTexture <= component.terrainData.splatPrototypes.Length - 1)
|
|
{
|
|
texture2D = component.terrainData.splatPrototypes[mainTerrainTexture].texture;
|
|
if ((bool)footstepManager)
|
|
{
|
|
foreach (vp_FootstepManager.vp_SurfaceTypes surfaceType in footstepManager.SurfaceTypes)
|
|
{
|
|
foreach (Texture texture in surfaceType.Textures)
|
|
{
|
|
if (texture == texture2D)
|
|
{
|
|
terrainType = surfaceType.SurfaceName;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
nextTerrainCheck = Time.time + terrainCheckFrequency;
|
|
}
|
|
|
|
public bool IsUnderGround()
|
|
{
|
|
return transform.position.y < terrainLevel.y + 0.3f;
|
|
}
|
|
|
|
public void CorrectDirection()
|
|
{
|
|
if (!isJumping && targetDirection.y > 0f)
|
|
{
|
|
targetDirection = new Vector3(targetDirection.x, 0f, targetDirection.z);
|
|
}
|
|
}
|
|
|
|
public void BreakFree()
|
|
{
|
|
ChangeUpdateToBait(false);
|
|
outOfWater = false;
|
|
isJerked = false;
|
|
isInNetArea = false;
|
|
isOnGround = false;
|
|
if ((bool)storedBait)
|
|
{
|
|
storedBait.collider.enabled = true;
|
|
storedBait = null;
|
|
}
|
|
jkmFishPanel.AddFishText(this, "StopSeeingBait(BreakFree)", logColor);
|
|
StopSeeingBait();
|
|
pullForce = 0f;
|
|
isFighting = false;
|
|
isBaitUpdate = false;
|
|
notPullingTimer = 20f;
|
|
withinSightBug = false;
|
|
if ((bool)bt)
|
|
{
|
|
bt.SetVariableValue("Bait", null);
|
|
DurabilityCurrent = DurabilityStart;
|
|
ticket = null;
|
|
pullingUp = false;
|
|
}
|
|
targetDirection = (Origin - transform.position).normalized;
|
|
fishMapIcon.SetColor(gameController.hudManager.fishMapIconPrefab.GetColor());
|
|
UpdateTargetSpeed();
|
|
transform.parent = fishSpawner.transform;
|
|
if ((bool)fishSpawner)
|
|
{
|
|
fishSpawner.HideOtherDuringFight(this, false);
|
|
}
|
|
animController.ChangeAnimation(FishAnimationController.AnimType.SWIM);
|
|
animController.fishAnimSwim.FishTryingFeeder(false);
|
|
CheckBehaviorDistance();
|
|
}
|
|
|
|
public void CatchBait()
|
|
{
|
|
fishingPlayer.OnCatchBait(this, storedBait.fishingHands);
|
|
isFighting = true;
|
|
storedBait.collider.enabled = false;
|
|
HungerLevel = 2f;
|
|
if (!GlobalSettings.Instance && gameController.tireAtCatch)
|
|
{
|
|
DurabilityCurrent = DurabilityMin;
|
|
}
|
|
fishMapIcon.SetColor(Color.red);
|
|
UpdateTargetSpeed();
|
|
}
|
|
|
|
public void FirstJerk()
|
|
{
|
|
TutorialManager.Instance.ShowTutorial(TutorialManager.TutorialsId.FIGHT_01, 1f);
|
|
if ((bool)storedBait.fishingHands.fishingFloat || storedBait.fishingHands.isGroundRig)
|
|
{
|
|
fishingPlayer.underwaterCamera.SetDistanceAway(Mathf.Clamp(Length, 0f, 3f) * 1.5f, 1f);
|
|
}
|
|
animController.ChangeAnimation(FishAnimationController.AnimType.SWIM);
|
|
isJerked = true;
|
|
gameController.hudManager.UpdateControls();
|
|
Debug.Log("Proper Jerk");
|
|
}
|
|
|
|
public void ReleaseFish(bool atSpawnPoint, Vector3 releasePosition, Vector3 releaseRotation)
|
|
{
|
|
if (fishSpawner == null)
|
|
{
|
|
return;
|
|
}
|
|
transform.SetParent(fishSpawner.transform);
|
|
bool flag = false;
|
|
if (!atSpawnPoint)
|
|
{
|
|
RaycastHit hitInfo = default(RaycastHit);
|
|
if (Physics.Raycast(releasePosition, Vector3.down, out hitInfo, 2f + releasePosition.y, collisionMask.value))
|
|
{
|
|
float num = hitInfo.distance - releasePosition.y;
|
|
if (num < 0.75f)
|
|
{
|
|
atSpawnPoint = true;
|
|
Debug.LogError("Fish release tooShallow atSpawnPoint: " + num);
|
|
}
|
|
else if (num < 1.25f || num < Length * 1.25f)
|
|
{
|
|
flag = true;
|
|
releasePosition.y = -0.1f;
|
|
releaseRotation.x = 0f;
|
|
Debug.LogError("Fish release tooShallow: " + num);
|
|
}
|
|
}
|
|
}
|
|
if (atSpawnPoint)
|
|
{
|
|
transform.localPosition = Vector3.zero;
|
|
}
|
|
else
|
|
{
|
|
transform.position = releasePosition;
|
|
}
|
|
transform.eulerAngles = releaseRotation;
|
|
Utilities.SetLayerRecursively(base.gameObject, "Fish");
|
|
Utilities.SetLayerRecursively(stateIndicator.gameObject, "Debug");
|
|
EnableAI();
|
|
BreakFree();
|
|
ChangeSize();
|
|
isReleasing = !flag && !atSpawnPoint;
|
|
}
|
|
|
|
public void Jump()
|
|
{
|
|
if (isWatchingFish || isInNetArea || isReleasing || isTryingBait || isJumping || isSeeingBait || (bool)currentTarget || isYoung)
|
|
{
|
|
JumpEnd();
|
|
return;
|
|
}
|
|
if (transform.position.y > -0.5f || transform.position.y < -3f)
|
|
{
|
|
JumpEnd();
|
|
return;
|
|
}
|
|
jumpedOverWater = false;
|
|
bool flag = true;
|
|
Vector3 vector = new Vector3(transform.forward.x, 0f, transform.forward.z);
|
|
Vector3 normalized = vector.normalized;
|
|
float t = UnityEngine.Random.Range(0.4f, 1f);
|
|
float num = Mathf.Lerp(-0f, fishSpeed.y * 0.75f, t);
|
|
num = Mathf.Clamp((3f - Mathf.Abs(transform.position.y)) * 3f, 3f, 5f);
|
|
if (num < 0f)
|
|
{
|
|
Debug.LogError("jumpLength < 0.0f");
|
|
JumpEnd();
|
|
return;
|
|
}
|
|
jumpTarget = transform.position + normalized * num;
|
|
jumpTarget.y = Mathf.Clamp(1f * Mathf.Abs(transform.position.y), 0.8f, 1f);
|
|
jumpTarget.y = 0.6f;
|
|
Vector3 vector2 = jumpTarget + normalized * num * 3f;
|
|
vector2.y = -1.5f;
|
|
if (!GlobalSettings.Instance)
|
|
{
|
|
Debug.DrawLine(transform.position, jumpTarget, Color.red, 8f);
|
|
Debug.DrawLine(jumpTarget, vector2, Color.blue, 8f);
|
|
}
|
|
RaycastHit hitInfo = default(RaycastHit);
|
|
if (Physics.CheckCapsule(transform.position, jumpTarget, boxCollider.size.y, collisionMask.value) || Physics.Raycast(transform.position, jumpTarget - transform.position, out hitInfo, Vector3.Distance(jumpTarget, transform.position), collisionMask.value))
|
|
{
|
|
flag = false;
|
|
}
|
|
else if (Physics.CheckCapsule(jumpTarget, vector2, boxCollider.size.y, collisionMask.value) || Physics.Raycast(jumpTarget, vector2 - jumpTarget, out hitInfo, Vector3.Distance(vector2, jumpTarget), collisionMask.value))
|
|
{
|
|
flag = false;
|
|
}
|
|
if (flag)
|
|
{
|
|
isJumping = true;
|
|
targetSpeed = Mathf.Clamp(fishSpeed.y * 1.3f, 2f, 4.5f);
|
|
if (!GlobalSettings.Instance && isFighting)
|
|
{
|
|
Debug.Log("Jump");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
JumpEnd();
|
|
}
|
|
}
|
|
|
|
public void JumpEnd()
|
|
{
|
|
isJumping = false;
|
|
if (GameController.Instance.jumpTest)
|
|
{
|
|
jumpTimer = UnityEngine.Random.Range(5f, 6f);
|
|
}
|
|
else
|
|
{
|
|
jumpTimer = UnityEngine.Random.Range(120f, 360f);
|
|
}
|
|
}
|
|
|
|
public void JumpUpdate()
|
|
{
|
|
if (jumpedOverWater)
|
|
{
|
|
float y = jumpTarget.y;
|
|
jumpTarget = transform.position + transform.forward * 1.7f;
|
|
jumpTarget.y = y - Time.deltaTime * jumpRotateSpeed.x;
|
|
}
|
|
if (jumpTarget.y < 0f && transform.position.y < -0f)
|
|
{
|
|
UpdateTargetSpeed();
|
|
}
|
|
if (jumpTarget.y < 0f && transform.position.y < -0.7f)
|
|
{
|
|
JumpEnd();
|
|
UpdateTargetSpeed();
|
|
}
|
|
else if (transform.position.y > ((!isFighting) ? boxCollider.size.y : 0f) || jumpedOverWater)
|
|
{
|
|
jumpedOverWater = true;
|
|
float num = ((!(transform.position.y > 0f)) ? 0f : transform.position.y);
|
|
num = 1f;
|
|
transform.position += Vector3.down * Time.deltaTime * jumpGravity * num;
|
|
}
|
|
if (!GlobalSettings.Instance)
|
|
{
|
|
Debug.DrawLine(transform.position, jumpTarget, Color.green, 0.1f);
|
|
}
|
|
if (prevPosition.y < 0f && transform.position.y >= 0f)
|
|
{
|
|
WaterSplash();
|
|
}
|
|
else if (prevPosition.y > 0f && transform.position.y <= 0f)
|
|
{
|
|
WaterSplash();
|
|
}
|
|
}
|
|
|
|
public void SetPulling(bool isPulling)
|
|
{
|
|
if (notPulling && isPulling)
|
|
{
|
|
notPulling = false;
|
|
}
|
|
else if (!notPulling && !isPulling)
|
|
{
|
|
notPulling = true;
|
|
notPullingTimer = UnityEngine.Random.Range(18f, 22f);
|
|
}
|
|
}
|
|
|
|
public void SetPullForce(Vector3 pullDirection, float pullForce, bool inPullRadius)
|
|
{
|
|
this.pullForce = pullForce;
|
|
this.pullDirection = pullDirection;
|
|
}
|
|
|
|
public bool TerrainCollision()
|
|
{
|
|
return waterDepth < 0.5f;
|
|
}
|
|
|
|
public bool AllowPlantTest()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public bool LikesPlant(GameObject go)
|
|
{
|
|
if (isJumping)
|
|
{
|
|
return false;
|
|
}
|
|
if ((bool)go)
|
|
{
|
|
WaterPlant component = go.GetComponent<WaterPlant>();
|
|
if ((bool)component)
|
|
{
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool LikesBoilie(GameObject go)
|
|
{
|
|
if (isJumping)
|
|
{
|
|
return false;
|
|
}
|
|
if ((bool)go)
|
|
{
|
|
Boilie componentInParent = go.GetComponentInParent<Boilie>();
|
|
if ((bool)componentInParent)
|
|
{
|
|
if (componentInParent.fishCounter >= componentInParent.maxFishes)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("no bollie script");
|
|
}
|
|
Debug.Log("LikesBoilie");
|
|
if (GameController.Instance.alwaysWantBait)
|
|
{
|
|
return true;
|
|
}
|
|
return componentInParent.GetFishInterest(species) >= 0.5f;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool LikesTerrain()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public bool LikesBait(GameObject g)
|
|
{
|
|
if (logColor == "black")
|
|
{
|
|
logColor = GetRandomColor();
|
|
}
|
|
jkmFishPanel.AddFishText(this, string.Empty, logColor, true);
|
|
if (isJumping)
|
|
{
|
|
StopSeeingBait();
|
|
jkmFishPanel.AddFishText(this, "FALSE(isJumping)", logColor);
|
|
return false;
|
|
}
|
|
if (g == null || TutorialManager.Instance.helpDontCatchAnything)
|
|
{
|
|
StopSeeingBait();
|
|
jkmFishPanel.AddFishText(this, "FALSE(noBaitObject/helpDontCatchAnything)", logColor);
|
|
return false;
|
|
}
|
|
Bait component = g.GetComponent<Bait>();
|
|
if (!component)
|
|
{
|
|
StopSeeingBait();
|
|
Debug.LogWarning("<color=" + logColor + ">LIKESBAIT : no bait component in bait game object</color>");
|
|
jkmFishPanel.AddFishText(this, "FALSE(noBaitComponent)", logColor);
|
|
return false;
|
|
}
|
|
if (!component.isOnWater || component.isNearPlayer || component.fish != null || fishingPlayer.junk != null)
|
|
{
|
|
StopSeeingBait();
|
|
Debug.LogWarning("JKM LikesBait " + base.name + " " + g.name + " !bait.isOnWater " + !component.isOnWater + " bait.isNearPlayer " + component.isNearPlayer + " bait.fish != null(" + component.fish != string.Concat(") fishingPlayer.junk != null(", fishingPlayer.junk, ")"));
|
|
string text = "FALSE(";
|
|
if (!component.isOnWater)
|
|
{
|
|
text += "BitOutOfWater,";
|
|
}
|
|
if (component.isNearPlayer)
|
|
{
|
|
text += "baitIsNearPlayer,";
|
|
}
|
|
if (component.fish != null)
|
|
{
|
|
text += "bait.fish=null,";
|
|
}
|
|
if (fishingPlayer.junk != null)
|
|
{
|
|
text += "junk=null";
|
|
}
|
|
text += ")";
|
|
jkmFishPanel.AddFishText(this, text, logColor);
|
|
return false;
|
|
}
|
|
if (component.CheckFishSize(this) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
if ((bool)ticket && ticket != this && (ticket.distanceToBait < 7f || distanceToBait < 5f))
|
|
{
|
|
StopSeeingBait();
|
|
if (ticket.distanceToBait < 7f)
|
|
{
|
|
jkmFishPanel.AddFishText(this, "FALSE(Fish.ticket.distanceToBait < 7.0f)", logColor);
|
|
}
|
|
else
|
|
{
|
|
jkmFishPanel.AddFishText(this, "FALSE(this.distanceToBait < 5.0f)", logColor);
|
|
}
|
|
return false;
|
|
}
|
|
if (!jkmIgnorPopularExit && component.isVisibleToFishTimer > 0f && !gameController.alwaysWantBait)
|
|
{
|
|
StopSeeingBait();
|
|
jkmFishPanel.AddFishText(this, "FALSE(bait.isVisibleToFishTimer > " + component.isVisibleToFishTimer + " )", logColor);
|
|
return false;
|
|
}
|
|
if (nextBaitEvaluation > Time.time)
|
|
{
|
|
jkmFishPanel.AddFishText(this, "FALSE(nextBaitEvaluation = " + nextBaitEvaluation + " lastBaitTest = " + lastBaitTest + ")", logColor);
|
|
return lastBaitTest;
|
|
}
|
|
isSeeingBait = true;
|
|
if (ticket == this && distanceToBait < 15f)
|
|
{
|
|
jkmFishPanel.AddFishText(this, "!!! TRUE !!! Fish.ticket=this, this.distanceToBait = " + distanceToBait, logColor);
|
|
return true;
|
|
}
|
|
if (!jkmIgnorPopularExit && FishingController.baitHitWaterTimer > 0f && fishingPlayer.currentState != FishingPlayer.PlayerState.DRIVING_BOAT)
|
|
{
|
|
StopSeeingBait();
|
|
jkmDontLike = "StopSeeingBait";
|
|
jkmFishPanel.AddFishText(this, "FALSE(StopSeeingBait[baitHitWaterTimer])", logColor);
|
|
return false;
|
|
}
|
|
if (fishingPlayer.IsTrolling())
|
|
{
|
|
if (component.fishingHands.isFloatRig || component.fishingHands.isGroundRig || component.fishingHands.isFlyRig)
|
|
{
|
|
}
|
|
if (fishSpeed.y < fishingPlayer.boatSimulator.minFishTrollingSpeed)
|
|
{
|
|
Debug.LogError("<color=" + logColor + ">LIKESBAIT : Trolling fish too slow</color>");
|
|
jkmFishPanel.AddFishText(this, "FALSE(Trolling fish too slow)", logColor);
|
|
return false;
|
|
}
|
|
}
|
|
bool flag = true;
|
|
int num = component.CheckFishSize(this);
|
|
isToSmoll = num != 0;
|
|
Debug.LogWarning("JKM LikesBait " + base.name + " " + g.name + " size " + num);
|
|
jkmFishPanel.AddFishText(this, "BaitSize(" + num + ")", logColor);
|
|
if (num == 0 && HUDManager.Instance.hookSizeInfoCounter != 0)
|
|
{
|
|
HUDManager.Instance.hookSizeInfoCounter += ((HUDManager.Instance.hookSizeInfoCounter <= 0) ? 2 : (-2));
|
|
}
|
|
else if ((bool)component.fishingHands.fishingFloat && component.baitParts.Count == 0 && !gameController.alwaysWantBait)
|
|
{
|
|
jkmDontLike = "bait.fishingHands.fishingFloat && bait.baitParts.Count == 0";
|
|
flag = false;
|
|
}
|
|
else
|
|
{
|
|
fbe.Clear();
|
|
fbe.SetCurveTime("time", gameController.weatherLevelManager.GetFullTime());
|
|
fbe.SetCurveTime("rain", gameController.weatherLevelManager.GetPercipitation());
|
|
fbe.SetCurveTime("wind", gameController.weatherLevelManager.GetWindSpeed());
|
|
fbe.SetCurveTime("clouds", gameController.weatherLevelManager.GetCloudiness());
|
|
float num2 = fbe.Evaluate();
|
|
num2 *= component.CheckTaste(this);
|
|
jkmFishPanel.AddFishText(this, "Eval0(" + num2 + ")", logColor);
|
|
if (!component.fishingHands.fishingFloat)
|
|
{
|
|
if (component.fishingHands.isGroundRig)
|
|
{
|
|
if ((bool)component.fishingHands.feeder.boilie)
|
|
{
|
|
num2 += component.fishingHands.feeder.boilie.GetFishInterest(species) * 0.2f;
|
|
}
|
|
jkmFishPanel.AddFishText(this, "Eval1(" + num2 + ")", logColor);
|
|
}
|
|
else if (!gameController.iceLevel)
|
|
{
|
|
SpinningMethodController.SpinningMethod currentSpinningMethod = component.fishingHands.spinningMethodController.currentSpinningMethod;
|
|
float num3 = 0f;
|
|
num3 = ((currentSpinningMethod == SpinningMethodController.SpinningMethod.NONE) ? 0f : ((component.fishingHands.spinningMethodController.currentSpinningLevel >= SizeLevel) ? spinningMethodFactor[(int)currentSpinningMethod] : (spinningMethodFactor[(int)currentSpinningMethod] * 0.8f)));
|
|
num2 *= num3;
|
|
Debug.Log("<color=" + logColor + ">LIKESBAIT : multiplier: " + num3 + " fishCatchMethodLevel: " + component.fishingHands.spinningMethodController.currentSpinningLevel + " SizeLevel: " + SizeLevel + " method: " + SpinningMethodController.GetSpinningMethodName(currentSpinningMethod) + " " + fishName + "</color>");
|
|
jkmFishPanel.AddFishText(this, "Eval2(" + num2 + "),SpinningMethod(" + currentSpinningMethod.ToString() + ")", logColor);
|
|
}
|
|
}
|
|
FishingLine fishingLine = component.fishingHands.fishingLine;
|
|
float num4 = Mathf.Lerp(0.6f, 1f, 1f - fishingLine.scareFactor);
|
|
if (fishingLine.lineType == FishingLine.LineType.FLY)
|
|
{
|
|
Debug.Log("<color=" + logColor + ">LIKESBAIT : Line eval: " + num2 + " scareMultiplier: " + num4 + " new eval: " + num2 * num4 + "</color>");
|
|
num2 *= num4;
|
|
}
|
|
jkmFishPanel.AddFishText(this, "Eval3(" + num2 + ")", logColor);
|
|
if (num2 < ((!GlobalSettings.Instance || GlobalSettings.Instance.playerSettings.IsCasual()) ? 0.29f : 0.4f))
|
|
{
|
|
jkmDontLike = "evalToLow";
|
|
flag = false;
|
|
}
|
|
if (gameController.alwaysWantBait || TutorialManager.Instance.helpCatchAnything)
|
|
{
|
|
flag = true;
|
|
}
|
|
Debug.Log("<color=" + logColor + ">LIKESBAIT : " + fishName + " Bait Fish Interest: " + flag + " eval: " + num2 + "</color>");
|
|
jkmFishPanel.AddFishText(this, "LIKESBAIT: " + fishName + " Bait Fish Interest: " + flag + " eval: " + num2, logColor);
|
|
}
|
|
lastBaitTest = flag;
|
|
nextBaitEvaluation = Time.time + baitEvaluationFrequency + UnityEngine.Random.Range(0f, 4f);
|
|
if (flag)
|
|
{
|
|
HUDManager.Instance.hookSizeInfoCounter = 0;
|
|
}
|
|
if (flag)
|
|
{
|
|
jkmFishPanel.AddFishText(this, "!!! TRUE !!!", logColor);
|
|
}
|
|
else
|
|
{
|
|
jkmFishPanel.AddFishText(this, "FALSE(" + jkmDontLike + ")", logColor);
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private string GetRandomColor()
|
|
{
|
|
string[] array = new string[6] { "red", "blue", "yellow", "cyan", "green", "magenta" };
|
|
return array[UnityEngine.Random.Range(0, array.Length)];
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision col)
|
|
{
|
|
Debug.Log("Fish collide with: " + col.gameObject.name + " at pos: " + transform.position.y);
|
|
}
|
|
|
|
public void EnableAI()
|
|
{
|
|
bt.EnableBehavior();
|
|
isWatchingFish = false;
|
|
isWatchingFishReady = false;
|
|
isInNetArea = false;
|
|
isOnGround = false;
|
|
if (gameController.showFishIndicator)
|
|
{
|
|
stateIndicator.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void DisableAI()
|
|
{
|
|
if ((bool)bt)
|
|
{
|
|
bt.DisableBehavior(true);
|
|
if (ticket == this)
|
|
{
|
|
ticket = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void WaterSplash(bool particles = true, bool ripples = true, bool sound = true, float strength = -1f)
|
|
{
|
|
if (particleSwim.isPlaying)
|
|
{
|
|
}
|
|
if (!allowSearch)
|
|
{
|
|
return;
|
|
}
|
|
if (particles)
|
|
{
|
|
gameController.waterEffectsManager.PlaySplashParticle(WaterEffectsManager.SplashSize.MEDIUM, new Vector3(transform.position.x, 0.2f, transform.position.z), new Vector3(-90f, 0f, 0f));
|
|
}
|
|
float t = Mathf.InverseLerp(0.3f, 2f, Length);
|
|
if (sound)
|
|
{
|
|
AudioController.Play("SplashFish_01", transform.position, transform, Mathf.Lerp(0.3f, 0.7f, t));
|
|
}
|
|
if (ripples)
|
|
{
|
|
if (strength >= 0f)
|
|
{
|
|
gameController.PlayWaterRipple(transform.position, Mathf.Lerp(15f, 40f, t), 1f);
|
|
}
|
|
else
|
|
{
|
|
gameController.PlayWaterRipple(transform.position, strength, 1f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public float GetSpeedValue(float factor)
|
|
{
|
|
return Mathf.Lerp(fishSpeed.x, fishSpeed.y, factor);
|
|
}
|
|
|
|
public float GetCurrentStrengthFactor()
|
|
{
|
|
return Strength * DurabilityCurrentRatio;
|
|
}
|
|
|
|
public void UpdateTargetSpeed(float newSpeed = -1f)
|
|
{
|
|
if (bt == null)
|
|
{
|
|
return;
|
|
}
|
|
if (newSpeed >= 0f)
|
|
{
|
|
targetSpeed = GetSpeedValue(newSpeed);
|
|
return;
|
|
}
|
|
if (newSpeed == -666f)
|
|
{
|
|
targetSpeed = 0f;
|
|
return;
|
|
}
|
|
GameObject value = ((SharedGameObject)bt.GetVariable("Target")).Value;
|
|
if (ticket == this && !isFighting)
|
|
{
|
|
if ((bool)storedBait.fishingHands.fishingFloat || storedBait.fishingHands.isGroundRig)
|
|
{
|
|
targetSpeed = GetSpeedValue(0.6f);
|
|
}
|
|
else
|
|
{
|
|
targetSpeed = GetSpeedValue(0.85f);
|
|
}
|
|
}
|
|
else if ((bool)value && value.HasTag("BOILIE"))
|
|
{
|
|
if (isInBoilieTrigger)
|
|
{
|
|
targetSpeed = GetSpeedValue(0.1f);
|
|
}
|
|
else
|
|
{
|
|
targetSpeed = GetSpeedValue(0.3f);
|
|
}
|
|
}
|
|
else if ((bool)value && value.HasTag("WATER_PLANT"))
|
|
{
|
|
targetSpeed = GetSpeedValue(0.3f);
|
|
}
|
|
else if (ticket != this && !isFighting)
|
|
{
|
|
targetSpeed = GetSpeedValue(UnityEngine.Random.Range(0f, 0.5f));
|
|
}
|
|
else
|
|
{
|
|
if (!isFighting)
|
|
{
|
|
return;
|
|
}
|
|
if (pullForce > 0f)
|
|
{
|
|
targetSpeed = storedBait.fishingHands.currentReelSpeed * storedBait.fishingHands.FLC.fishTargetSpeedPullMultiplier;
|
|
return;
|
|
}
|
|
float num = 1f;
|
|
num *= Mathf.Lerp(0.33f, 1f, DurabilityCurrentRatio);
|
|
if (pullForce > 0f)
|
|
{
|
|
num *= Mathf.Lerp(0.33f, 1f, 1f - pullForce);
|
|
}
|
|
else if ((bool)storedBait && storedBait.fishingHands.fishingLine.stretchToDistance > 0.05f && storedBait.fishingHands.fishingPlayer.DragFishStrengthDiff < 0f)
|
|
{
|
|
num *= Mathf.Lerp(0f, 0.9f, 1f - storedBait.fishingHands.reel.GetDragForce());
|
|
}
|
|
targetSpeed = GetSpeedValue(num);
|
|
}
|
|
}
|
|
|
|
public void TurnAround()
|
|
{
|
|
targetDirection = -targetDirection;
|
|
Debug.Log("TurnAround");
|
|
}
|
|
|
|
public void SelectRandDirection()
|
|
{
|
|
if (!isJumping)
|
|
{
|
|
float x = UnityEngine.Random.Range(-30f, 30f) * DepthAggressiveness;
|
|
float y = UnityEngine.Random.Range(-180f, 180f);
|
|
if (normalDepthStyle != DepthStyle.FREE)
|
|
{
|
|
x = UnityEngine.Random.Range(-5f, 5f);
|
|
}
|
|
targetDirection = Utilities.RotateVector(transform.forward, new Vector3(x, y, 0f));
|
|
targetDirection = UpdateRotationDepthStyle(targetDirection, normalDepthStyle, normalDepthLevel);
|
|
UpdateTargetSpeed();
|
|
}
|
|
}
|
|
|
|
public Vector3 UpdateRotationDepthStyle(Vector3 dir, DepthStyle depthStyle, float depthLevel)
|
|
{
|
|
float num = depthLevel;
|
|
if (depthStyle != DepthStyle.FREE)
|
|
{
|
|
float angle180Range = Utilities.GetAngle180Range(transform.eulerAngles.x);
|
|
float num2 = 0.5f;
|
|
if (depthStyle == DepthStyle.GROUND_LEVEL)
|
|
{
|
|
num = ((!terrainTransform) ? minimumDepth : (terrainLevel.y + depthLevel));
|
|
}
|
|
float num3 = Mathf.Abs(transform.position.y - num);
|
|
if (transform.position.y < num - num2 && angle180Range >= 0f)
|
|
{
|
|
dir.y = Mathf.Lerp(0.1f, 0.7f, num3 / 10f);
|
|
}
|
|
else if (transform.position.y > num + num2 && angle180Range <= 0f)
|
|
{
|
|
dir.y = 0f - Mathf.Lerp(0.1f, 0.7f, num3 / 10f);
|
|
}
|
|
if (isFighting)
|
|
{
|
|
dir.y *= 2.5f;
|
|
}
|
|
}
|
|
if (dir.y < 0f)
|
|
{
|
|
num = ((!terrainTransform) ? minimumDepth : terrainLevel.y);
|
|
if (transform.position.y < num + 0.5f)
|
|
{
|
|
dir.y = 0f;
|
|
}
|
|
}
|
|
return dir;
|
|
}
|
|
|
|
public void ShowIcon(bool show)
|
|
{
|
|
}
|
|
|
|
public void CheckBehaviorDistance()
|
|
{
|
|
if (fishingPlayer == null)
|
|
{
|
|
return;
|
|
}
|
|
if (isWatchingFish)
|
|
{
|
|
animController.ChangeAnimation(FishAnimationController.AnimType.WATCH);
|
|
ShowRigged(true);
|
|
bt.enabled = false;
|
|
boxCollider.enabled = false;
|
|
allowSearch = false;
|
|
return;
|
|
}
|
|
if (isFighting)
|
|
{
|
|
ShowRigged(true);
|
|
bt.enabled = true;
|
|
boxCollider.enabled = true;
|
|
allowSearch = true;
|
|
if (DurabilityCurrentRatio <= 0.15f && fishingPlayer.distanceToBait < DurabilityBoostDistance)
|
|
{
|
|
DurabilityBoost();
|
|
}
|
|
return;
|
|
}
|
|
float num = Vector3.Distance((!fishingPlayer.underwaterCamera.isTurnedOn) ? fishingPlayer.ufpsCamera.transform.position : fishingPlayer.underwaterCamera.transform.position, transform.position);
|
|
distanceToBait = -1f;
|
|
if ((bool)fishingPlayer.currentHands && !fishingPlayer.fish && fishingPlayer.currentHands.bait.isOnWater)
|
|
{
|
|
distanceToBait = Vector3.Distance(fishingPlayer.currentHands.bait.transform.position, transform.position);
|
|
}
|
|
bool flag = num < fishingPlayer.currentFishDistanceBehavior || (distanceToBait > -1f && distanceToBait < 70f);
|
|
if (!GameController.Instance.useFishesPool)
|
|
{
|
|
if (fishingPlayer.isHunterVisionOn)
|
|
{
|
|
base.gameObject.SetActive(flag && num < 110f);
|
|
}
|
|
else if (!fishSpawner.hideOtherDuringFight || !fishingPlayer.fish)
|
|
{
|
|
base.gameObject.SetActive(flag);
|
|
}
|
|
}
|
|
else if (fishingPlayer.isHunterVisionOn)
|
|
{
|
|
bool flag2 = flag && num < 110f;
|
|
for (int i = 0; i < fishSpawner.fishList.Count; i++)
|
|
{
|
|
if (fishSpawner.fishList[i] == this)
|
|
{
|
|
ObjectPool.Instance.SetFishActive(ref fishSpawner.fishList, ref fishSpawner.fishCopies, i, flag2);
|
|
break;
|
|
}
|
|
}
|
|
if (!flag2)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if ((!fishSpawner.hideOtherDuringFight || !fishingPlayer.fish) && !flag)
|
|
{
|
|
for (int j = 0; j < fishSpawner.fishList.Count; j++)
|
|
{
|
|
if (fishSpawner.fishList[j] == this)
|
|
{
|
|
ObjectPool.Instance.SetFishActive(ref fishSpawner.fishList, ref fishSpawner.fishCopies, j, flag);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (base.gameObject.activeSelf)
|
|
{
|
|
if (gameController.showFishIndicator)
|
|
{
|
|
stateIndicator.gameObject.SetActive(num < 150f);
|
|
fishMapIcon.gameObject.SetActive(num < 70f);
|
|
}
|
|
if (disableLogic)
|
|
{
|
|
bt.enabled = false;
|
|
}
|
|
else
|
|
{
|
|
bt.enabled = flag;
|
|
}
|
|
boxCollider.enabled = flag;
|
|
allowSearch = flag;
|
|
if (fishingPlayer.underwaterCamera.isTurnedOn)
|
|
{
|
|
ShowRigged(num < 15f);
|
|
}
|
|
else if (transform.position.y > -1.5f)
|
|
{
|
|
ShowRigged(num < 30f);
|
|
}
|
|
else if (Length > 2f)
|
|
{
|
|
ShowRigged(num < 40f);
|
|
}
|
|
else
|
|
{
|
|
ShowRigged(num < fishingPlayer.GetFishDistanceAnimation());
|
|
}
|
|
if (!gameController.iceLevel && gameController.waterEffectsManager.randomFishSplashTimer <= 0f && num < 30f && num > 10f && transform.position.y > -5f)
|
|
{
|
|
gameController.waterEffectsManager.MakeRandomFishSplash(this, num);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeUpdateToBait(bool baitUpdate)
|
|
{
|
|
}
|
|
|
|
public void ChangeUpdateToBaitNew(bool baitUpdate)
|
|
{
|
|
if (!(storedBait == null) && isBaitUpdate != baitUpdate)
|
|
{
|
|
if (baitUpdate)
|
|
{
|
|
DisableAI();
|
|
}
|
|
else
|
|
{
|
|
EnableAI();
|
|
Debug.Log("EnableAI 1");
|
|
}
|
|
storedBait.rigidbody.velocity = Vector3.zero;
|
|
storedBait.rigidbody.angularVelocity = Vector3.zero;
|
|
storedBait.rigidbody.isKinematic = !baitUpdate;
|
|
if (baitUpdate)
|
|
{
|
|
storedBait.rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ;
|
|
}
|
|
else
|
|
{
|
|
storedBait.rigidbody.constraints = RigidbodyConstraints.None;
|
|
}
|
|
storedBait.collider.enabled = baitUpdate;
|
|
isBaitUpdate = baitUpdate;
|
|
}
|
|
}
|
|
|
|
public IEnumerator PullForce(float force)
|
|
{
|
|
if (!(storedBait == null))
|
|
{
|
|
force *= Mathf.Lerp(1f, 0f, GetCurrentStrengthFactor() * 1.5f);
|
|
force = ((!(storedBait.fishingHands.GetEquipmentDurability() <= 1f)) ? (force * Mathf.Lerp(1f, 2f, storedBait.fishingHands.GetEquipmentDurability())) : (force * Mathf.Lerp(0.1f, 1f, storedBait.fishingHands.GetEquipmentDurability())));
|
|
force *= storedBait.fishingHands.reel.GetDragForce();
|
|
Vector3 forceVector = storedBait.fishingHands.fishingRod.ropeStartPosition.position;
|
|
forceVector.y = 0f;
|
|
forceVector = (forceVector - transform.position).normalized;
|
|
forceVector *= force * 1f;
|
|
Vector3 newPosition = transform.position;
|
|
newPosition += forceVector;
|
|
if (newPosition.y > 0f)
|
|
{
|
|
newPosition.y = 0f;
|
|
}
|
|
transform.position = newPosition;
|
|
}
|
|
yield break;
|
|
}
|
|
|
|
private void CalcSpeedForce()
|
|
{
|
|
}
|
|
|
|
public void DurabilityBoost()
|
|
{
|
|
if (DurabilityBoostAmountCurrent > 0)
|
|
{
|
|
Debug.Log("DurabilityBoost");
|
|
DurabilityBoostAmountCurrent--;
|
|
float to = DurabilityStart * UnityEngine.Random.Range(0.5f, 0.75f);
|
|
DurabilityCurrent = DurabilityStart * 0.25f;
|
|
LeanTween.value(DurabilityCurrent, to, 3f).setOnUpdate(delegate(float val)
|
|
{
|
|
DurabilityCurrent = val;
|
|
});
|
|
animController.fishAnimSwim.FightSquirm();
|
|
if (transform.position.y > -0.1f)
|
|
{
|
|
WaterSplash();
|
|
}
|
|
if (DurabilityBoostAmountCurrent > 0)
|
|
{
|
|
DurabilityBoostDistance = UnityEngine.Random.Range(10f, 35f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeMaterial(bool watch)
|
|
{
|
|
if ((bool)rigRenderer)
|
|
{
|
|
if (mainMaterialId == 0)
|
|
{
|
|
rigRenderer.material = ((!watch) ? mainMaterial : watchMaterial);
|
|
}
|
|
else
|
|
{
|
|
rigRenderer.sharedMaterials[mainMaterialId] = ((!watch) ? mainMaterial : watchMaterial);
|
|
}
|
|
if (transparentMaterial != null)
|
|
{
|
|
Utilities.SetupMaterialWithBlendMode(transparentMaterial, (!watch) ? Utilities.BlendMode.Cutout : Utilities.BlendMode.Fade);
|
|
}
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void SetRigRenderer()
|
|
{
|
|
if ((bool)modelRig)
|
|
{
|
|
rigRenderer = modelRig.GetComponentInChildren<SkinnedMeshRenderer>();
|
|
}
|
|
}
|
|
|
|
public bool IsItTinyFish()
|
|
{
|
|
return Weight <= 0.1f;
|
|
}
|
|
|
|
public void AttachToBoat(BoatSimulator boatSimulator)
|
|
{
|
|
if ((bool)boatSimulator)
|
|
{
|
|
transform.parent = boatSimulator.transform;
|
|
boatAttachPosition = transform.localPosition;
|
|
isBoatUpdate = true;
|
|
}
|
|
else
|
|
{
|
|
transform.parent = fishSpawner.transform;
|
|
isBoatUpdate = false;
|
|
}
|
|
Debug.Log("AttachToBoat: " + ((!(boatSimulator != null)) ? "null" : boatSimulator.ToString()));
|
|
}
|
|
|
|
public void Kill()
|
|
{
|
|
DisableAI();
|
|
LeanTween.moveY(base.gameObject, 0f, (0f - transform.position.y) * 4f).setOnComplete((Action)delegate
|
|
{
|
|
GetComponent<FishInteractive>().enabled = true;
|
|
rigidbody.isKinematic = false;
|
|
if ((bool)GetComponent<WaterFloat>())
|
|
{
|
|
GetComponent<WaterFloat>().enabled = true;
|
|
}
|
|
});
|
|
transform.localEulerAngles = new Vector3(0f, transform.localEulerAngles.y, transform.localEulerAngles.z);
|
|
LeanTween.rotateZ(base.gameObject, 90f, 2f).setOnComplete((Action)delegate
|
|
{
|
|
rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
|
|
});
|
|
if (swimTween != null)
|
|
{
|
|
swimTween.pause();
|
|
}
|
|
animController.ChangeAnimation(FishAnimationController.AnimType.NONE);
|
|
}
|
|
|
|
public void UpdateAttractor()
|
|
{
|
|
stateIndicator.material.color = Color.magenta;
|
|
isAttracted = false;
|
|
}
|
|
|
|
public void StopSeeingBait()
|
|
{
|
|
distanceToBait = -1f;
|
|
isSeeingBait = false;
|
|
((SharedGameObject)bt.GetVariable("Target")).Value = null;
|
|
jkmFishPanel.AddFishText(this, "StopSeeingBait()", logColor);
|
|
}
|
|
|
|
private void OnDrawGizmosSelected()
|
|
{
|
|
}
|
|
|
|
public void FillFishCopy(ref ObjectPool.stFishCopy fishCopy)
|
|
{
|
|
fishCopy.position = transform.position;
|
|
fishCopy.rotation = transform.rotation;
|
|
fishCopy.scale = transform.localScale;
|
|
fishCopy.weight = Weight;
|
|
fishCopy.length = Length;
|
|
fishCopy.strength = Strength;
|
|
fishCopy.isYoung = isYoung;
|
|
fishCopy.baitSize = baitSize;
|
|
fishCopy.watchStyle = watchStyle;
|
|
fishCopy.startStrength = StartStrength;
|
|
fishCopy.durabilityStartRange = DurabilityStartRange;
|
|
fishCopy.durabilityStart = DurabilityStart;
|
|
fishCopy.fishSpeed = fishSpeed;
|
|
fishCopy.hungerLevel = HungerLevel;
|
|
fishCopy.jumpTimer = jumpTimer;
|
|
fishCopy.jumpGravity = jumpGravity;
|
|
fishCopy.jumpRotateSpeed = jumpRotateSpeed;
|
|
fishCopy.notPulling = notPulling;
|
|
fishCopy.notPullingTimer = notPullingTimer;
|
|
fishCopy.durabilityFightSpeed = DurabilityFightSpeed;
|
|
fishCopy.durabilityJerkFactor = DurabilityJerkFactor;
|
|
fishCopy.durabilityJerkSpeed = DurabilityJerkSpeed;
|
|
fishCopy.durabilityHandsRotationFactor = DurabilityHandsRotationFactor;
|
|
fishCopy.changeDirectionDelay = changeDirectionDelay;
|
|
fishCopy.targetDirection = targetDirection;
|
|
fishCopy.nextBaitEvaluation = nextBaitEvaluation;
|
|
fishCopy.fishSpawner = fishSpawner;
|
|
fishCopy.aggressivenessFight = AggressivenessFight;
|
|
fishCopy.depthAggressivenessFight = DepthAggressivenessFight;
|
|
fishCopy.fromPlayerAggressiveness = FromPlayerAggressiveness;
|
|
fishCopy.normalDepthStyle = normalDepthStyle;
|
|
fishCopy.normalDepthLevel = normalDepthLevel;
|
|
fishCopy.fightDepthStyle = fightDepthStyle;
|
|
fishCopy.fightDepthLevel = fightDepthLevel;
|
|
fishCopy.aggressiveness = Aggressiveness;
|
|
fishCopy.depthAggressiveness = DepthAggressiveness;
|
|
fishCopy.useJumps = useJumps;
|
|
fishCopy.useFightJumps = useFightJumps;
|
|
fishCopy.durabilityCurrent = DurabilityCurrent;
|
|
fishCopy.lastTargetTime = lastTargetTime;
|
|
fishCopy.waterInteractive_Multiplier = waterInteractive.Multiplier;
|
|
fishCopy.depthSensorCheckTimer = depthSensorCheckTimer;
|
|
fishCopy.isFighting = isFighting;
|
|
fishCopy.waterDepth = waterDepth;
|
|
fishCopy.terrainLevel = terrainLevel;
|
|
fishCopy.terrainTransform = terrainTransform;
|
|
fishCopy.nextTerrainCheck = nextTerrainCheck;
|
|
fishCopy.isWatchingFish = isWatchingFish;
|
|
fishCopy.distanceToBait = distanceToBait;
|
|
fishCopy.isInSearchDistance = false;
|
|
fishCopy.disableLogic = disableLogic;
|
|
fishCopy.isBoatUpdate = isBoatUpdate;
|
|
fishCopy.fishSpawner = fishSpawner;
|
|
fishCopy.parent = transform.parent;
|
|
}
|
|
|
|
public void SetParamFromCopy(ObjectPool.stFishCopy fishCopy)
|
|
{
|
|
transform.position = fishCopy.position;
|
|
transform.rotation = fishCopy.rotation;
|
|
transform.localScale = fishCopy.scale;
|
|
Weight = fishCopy.weight;
|
|
Length = fishCopy.length;
|
|
Strength = fishCopy.strength;
|
|
isYoung = fishCopy.isYoung;
|
|
baitSize = fishCopy.baitSize;
|
|
watchStyle = fishCopy.watchStyle;
|
|
StartStrength = fishCopy.startStrength;
|
|
DurabilityStartRange = fishCopy.durabilityStartRange;
|
|
DurabilityStart = fishCopy.durabilityStart;
|
|
fishSpeed = fishCopy.fishSpeed;
|
|
HungerLevel = fishCopy.hungerLevel;
|
|
jumpTimer = fishCopy.jumpTimer;
|
|
jumpGravity = fishCopy.jumpGravity;
|
|
jumpRotateSpeed = fishCopy.jumpRotateSpeed;
|
|
notPulling = fishCopy.notPulling;
|
|
notPullingTimer = fishCopy.notPullingTimer;
|
|
DurabilityFightSpeed = fishCopy.durabilityFightSpeed;
|
|
DurabilityJerkFactor = fishCopy.durabilityJerkFactor;
|
|
DurabilityJerkSpeed = fishCopy.durabilityJerkSpeed;
|
|
DurabilityHandsRotationFactor = fishCopy.durabilityHandsRotationFactor;
|
|
changeDirectionDelay = fishCopy.changeDirectionDelay;
|
|
targetDirection = fishCopy.targetDirection;
|
|
nextBaitEvaluation = fishCopy.nextBaitEvaluation;
|
|
fishSpawner = fishCopy.fishSpawner;
|
|
AggressivenessFight = fishCopy.aggressivenessFight;
|
|
DepthAggressivenessFight = fishCopy.depthAggressivenessFight;
|
|
FromPlayerAggressiveness = fishCopy.fromPlayerAggressiveness;
|
|
normalDepthStyle = fishCopy.normalDepthStyle;
|
|
normalDepthLevel = fishCopy.normalDepthLevel;
|
|
fightDepthStyle = fishCopy.fightDepthStyle;
|
|
fightDepthLevel = fishCopy.fightDepthLevel;
|
|
Aggressiveness = fishCopy.aggressiveness;
|
|
DepthAggressiveness = fishCopy.depthAggressiveness;
|
|
useJumps = fishCopy.useJumps;
|
|
useFightJumps = fishCopy.useFightJumps;
|
|
DurabilityCurrent = fishCopy.durabilityCurrent;
|
|
lastTargetTime = fishCopy.lastTargetTime;
|
|
waterInteractive.Multiplier = fishCopy.waterInteractive_Multiplier;
|
|
depthSensorCheckTimer = fishCopy.depthSensorCheckTimer;
|
|
isFighting = fishCopy.isFighting;
|
|
waterDepth = fishCopy.waterDepth;
|
|
terrainLevel = fishCopy.terrainLevel;
|
|
terrainTransform = fishCopy.terrainTransform;
|
|
nextTerrainCheck = fishCopy.nextTerrainCheck;
|
|
isWatchingFish = fishCopy.isWatchingFish;
|
|
distanceToBait = fishCopy.distanceToBait;
|
|
disableLogic = fishCopy.disableLogic;
|
|
bt.enabled = !disableLogic && fishCopy.isInSearchDistance;
|
|
boxCollider.enabled = fishCopy.isInSearchDistance;
|
|
allowSearch = fishCopy.isInSearchDistance;
|
|
isBoatUpdate = fishCopy.isBoatUpdate;
|
|
transform.parent = fishCopy.parent;
|
|
}
|
|
}
|