Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/AddFishAre.cs
2026-02-21 16:45:37 +08:00

1237 lines
35 KiB
C#

using System;
using System.Collections.Generic;
using BitStrap;
using UnityEngine;
public class AddFishAre : MonoBehaviour
{
[Serializable]
public enum EditMode
{
ExitBox = 0,
FishAre = 1
}
[Serializable]
public struct stBox
{
public Vector3 pos;
public Vector3 size;
}
[Serializable]
public struct stLines
{
public float posZ;
public List<float> posesX;
public float lenSum;
public stLines(float posZ_)
{
posZ = posZ_;
posesX = new List<float>();
lenSum = 0f;
}
internal void CalcLength()
{
posesX.Sort();
for (int i = 0; i < posesX.Count / 2; i++)
{
lenSum += posesX[i * 2 + 1] - posesX[i * 2];
}
}
}
[Serializable]
public struct stPligonAre
{
public float sumLength;
public List<stLines> fishAreLines;
public stPligonAre(float sumLength_, List<stLines> fishAreLines_)
{
sumLength = sumLength_;
fishAreLines = fishAreLines_;
}
public List<GameObject> SpawnObjects(GameObject parentPrefab, Transform parent, float step, GameObject[] prefabs)
{
List<Transform> list = new List<Transform>();
foreach (GameObject gameObject in prefabs)
{
string[] array = gameObject.name.Split('_');
GameObject gameObject2 = UnityEngine.Object.Instantiate(parentPrefab, parent);
gameObject2.name = array[1];
list.Add(gameObject2.transform);
}
List<GameObject> list2 = new List<GameObject>();
foreach (stLines fishAreLine in fishAreLines)
{
Vector3 vector = new Vector3(0f, 0f, fishAreLine.posZ);
for (int j = 0; j < fishAreLine.posesX.Count / 2; j++)
{
vector.x = UnityEngine.Random.Range(0f, step) + fishAreLine.posesX[j * 2];
while (vector.x < fishAreLine.posesX[j * 2 + 1])
{
int num = UnityEngine.Random.Range(0, prefabs.Length);
list2.Add(UnityEngine.Object.Instantiate(prefabs[num], vector, Quaternion.identity, list[num]));
Debug.Log("JKM add go " + vector);
vector.x += step;
}
}
}
return list2;
}
internal void DrawGizmos()
{
Gizmos.color = Color.red;
foreach (stLines fishAreLine in fishAreLines)
{
Vector3 vector = new Vector3(0f, 0f, fishAreLine.posZ);
Vector3 to = new Vector3(0f, 0f, fishAreLine.posZ);
for (int i = 0; i < fishAreLine.posesX.Count / 2; i++)
{
vector.x = fishAreLine.posesX[i * 2];
to.x = fishAreLine.posesX[i * 2 + 1];
Gizmos.DrawLine(vector, to);
}
}
}
}
[Serializable]
public struct stBait
{
public string name;
public FishLikesParams[] fishLikesParams;
public void AddFish(Fish.Species species, float value)
{
FishLikesParams[] array = this.fishLikesParams;
foreach (FishLikesParams fishLikesParams in array)
{
int num = -1;
if (!(fishLikesParams != null) || fishLikesParams.fishInterests == null)
{
continue;
}
for (int j = 0; j < fishLikesParams.fishInterests.Count; j++)
{
if (fishLikesParams.fishInterests[j] != null && fishLikesParams.fishInterests[j].species == species)
{
num = j;
break;
}
}
if (num == -1)
{
fishLikesParams.fishInterests.Add(new FishLikesParams.FishInterest(species, value));
}
else
{
Debug.Log("JKM Fish (" + species.ToString() + ")exist in balt " + fishLikesParams.name);
}
}
}
}
[Serializable]
public struct stFish
{
public string name;
public Fish.Species species;
public Fish fish;
public stFish(string name_, Fish.Species species_)
{
name = name_;
species = species_;
fish = null;
}
}
private struct stFishData
{
public string fishName;
public float[] values;
public stFishData(string[] names_)
{
fishName = names_[0];
values = new float[names_.Length - 1];
for (int i = 1; i < names_.Length; i++)
{
string text = names_[i];
text = text.Replace("<", string.Empty);
text = text.Replace(">", string.Empty);
text = text.Replace("*", string.Empty);
values[i - 1] = 0f;
if (text.Length > 0)
{
int result = 0;
int.TryParse(text, out result);
values[i - 1] = (float)result * 0.1f;
}
else
{
values[i - 1] = 0f;
}
}
}
}
[Serializable]
public struct stFishPara
{
public string[] s;
public stFishPara(string[] ss)
{
s = ss;
}
}
public float markPointSize = 5f;
public EditMode editMode;
public GameObject boxPrefab;
public List<stBox> boxes;
[Tooltip("Punkty do exit boxsow")]
public List<Vector3> points;
public List<Vector3> lines;
public float height = 2f;
public float xSize = 20f;
public GameObject parentPrefab;
[Tooltip("Punkty do fishAre")]
public List<Vector3> fishArePoints;
public List<int> fishAreTopPoints;
public GameObject[] fishSpawners;
public Transform fishSpawnerParent;
public bool drawPoligonAre = true;
public stPligonAre poligonsArea;
public float poligonStep = 5f;
public List<stBait> baitList;
public List<stFish> fishes;
public int percentActiveSpawner = 20;
internal void SetActiveSpawnerAtStart()
{
FishSpawner[] componentsInChildren = fishSpawnerParent.GetComponentsInChildren<FishSpawner>();
FishSpawner[] array = componentsInChildren;
foreach (FishSpawner fishSpawner in array)
{
fishSpawner.spawnAtStart = false;
}
int num = componentsInChildren.Length * percentActiveSpawner / 100;
int num2 = componentsInChildren.Length;
for (int j = 0; j < num; j++)
{
int num3 = UnityEngine.Random.Range(0, num2);
componentsInChildren[num3].spawnAtStart = true;
componentsInChildren[num3] = componentsInChildren[num2 - 1];
num2--;
}
}
public void AddBox(Vector3 pos)
{
Vector3[] array = new Vector3[4]
{
Vector3.forward,
Vector3.back,
Vector3.left,
Vector3.right
};
List<Vector3> list = new List<Vector3>();
Vector3 vector = new Vector3(pos.x, 0f - height, pos.z);
Ray ray = new Ray(vector, array[0]);
for (int i = 0; i < 2; i++)
{
ray.direction = array[i];
Vector3 origin = vector;
origin.x = vector.x - xSize;
ray.origin = origin;
RaycastHit hitInfo = default(RaycastHit);
if (!Physics.Raycast(ray, out hitInfo))
{
break;
}
Vector3 point = hitInfo.point;
origin.x = vector.x + xSize;
ray.origin = origin;
if (!Physics.Raycast(ray, out hitInfo))
{
break;
}
Vector3 point2 = hitInfo.point;
float num = Mathf.Abs(point.z - vector.z);
float num2 = Mathf.Abs(point2.z - vector.z);
if (num < num2)
{
list.Add(point);
}
else
{
list.Add(point2);
}
}
if (list.Count < 2)
{
return;
}
for (int j = 2; j < 4; j++)
{
ray.direction = array[j];
RaycastHit hitInfo2 = default(RaycastHit);
if (Physics.Raycast(ray, out hitInfo2))
{
list.Add(hitInfo2.point);
continue;
}
break;
}
if (list.Count < 4)
{
return;
}
Vector3 zero = Vector3.zero;
foreach (Vector3 item2 in list)
{
zero += item2;
}
zero /= 4f;
stBox item = default(stBox);
item.pos = zero;
item.pos.x = pos.x;
item.pos.y += height * 0.5f;
item.size = new Vector3(xSize * 2f, height, Mathf.Abs(list[0].z - list[1].z));
boxes.Add(item);
}
public void AddPoint(Vector3 p)
{
switch (editMode)
{
case EditMode.ExitBox:
points.Add(p);
break;
case EditMode.FishAre:
fishArePoints.Add(p);
break;
}
}
public void MakeLines()
{
lines.Clear();
List<Vector3> list = new List<Vector3>();
List<Vector3> list2 = new List<Vector3>();
for (int i = 1; i < points.Count - 1; i++)
{
Vector3 vector = points[i - 1] - points[i];
Vector3 vector2 = points[i + 1] - points[i];
Vector3 vector3 = vector.normalized + vector2.normalized;
vector3.y = 0f;
vector3.Normalize();
Vector3 origin = points[i];
origin.y = 0f - height;
Ray ray = new Ray(origin, vector3);
RaycastHit hitInfo = default(RaycastHit);
if (!Physics.Raycast(ray, out hitInfo))
{
continue;
}
Vector3 point = hitInfo.point;
ray.direction = Vector3.zero - vector3;
if (!Physics.Raycast(ray, out hitInfo))
{
continue;
}
Vector3 point2 = hitInfo.point;
if (list.Count > 0)
{
float num = Vector3.Distance(list[list.Count - 1], point);
float num2 = Vector3.Distance(list[list.Count - 1], point2);
if (num < num2)
{
list.Add(point);
list2.Add(point2);
}
else
{
list.Add(point2);
list2.Add(point);
}
}
else
{
list.Add(point);
list2.Add(point2);
}
}
foreach (Vector3 item in list)
{
lines.Add(item);
}
for (int num3 = list2.Count - 1; num3 >= 0; num3--)
{
lines.Add(list2[num3]);
}
}
public void BuildBoxOnPoints(GameObject prefab, Transform parent, float sideScale, float minSide = 40f)
{
for (int i = 0; i < points.Count; i++)
{
int index = (i + 1) % points.Count;
Vector3 vector = points[i] - points[index];
vector.y = 0f;
vector.Normalize();
Vector3 vector2 = Quaternion.Euler(0f, 90f, 0f) * vector;
float num = Vector3.Angle(vector, Vector3.forward);
if (vector.x < 0f)
{
num = 180f - num;
}
Vector3 position = (points[i] + points[index]) / 2f;
float num2 = Vector3.Distance(points[i], points[index]);
Quaternion rotation = Quaternion.Euler(0f, num, 0f);
position += -vector2 * num2 * 0.15f * sideScale;
GameObject gameObject = UnityEngine.Object.Instantiate(prefab, position, rotation, parent);
Vector3 localScale = gameObject.transform.localScale;
localScale.z = num2 * 1.2f;
localScale.x = num2 * 0.3f;
if (localScale.x < minSide)
{
localScale.x = minSide;
}
gameObject.transform.localScale = localScale;
}
}
public stPligonAre GetPoligonAre(float stepZ)
{
float num = float.MaxValue;
float num2 = float.MaxValue;
float num3 = float.MinValue;
float num4 = float.MinValue;
foreach (Vector3 fishArePoint in fishArePoints)
{
if (num > fishArePoint.x)
{
num = fishArePoint.x;
}
if (num3 < fishArePoint.x)
{
num3 = fishArePoint.x;
}
if (num2 > fishArePoint.z)
{
num2 = fishArePoint.z;
}
if (num4 < fishArePoint.z)
{
num4 = fishArePoint.z;
}
}
num -= 5f;
num3 += 5f;
float num5 = num2 + stepZ;
List<stLines> list = new List<stLines>();
float num6 = 0f;
for (; num5 + stepZ < num4; num5 += stepZ)
{
stLines item = new stLines(num5);
for (int i = 0; i < fishArePoints.Count; i++)
{
int index = (i + 1) % fishArePoints.Count;
float z = fishArePoints[i].z;
float z2 = fishArePoints[index].z;
Vector2 zero = Vector2.zero;
Vector2 zero2 = Vector2.zero;
if (z < z2)
{
zero = toV2(fishArePoints[i]);
zero2 = toV2(fishArePoints[index]);
}
else
{
zero = toV2(fishArePoints[index]);
zero2 = toV2(fishArePoints[i]);
}
Vector2 vector = zero2 - zero;
if (vector.y != 0f)
{
float num7 = (num5 - zero.y) / vector.y;
if (num7 > 0f && (double)num7 < 1.0)
{
float item2 = zero.x + vector.x * num7;
item.posesX.Add(item2);
}
}
}
if (item.posesX.Count > 1)
{
item.CalcLength();
num6 += item.lenSum;
list.Add(item);
}
}
return new stPligonAre(num6, list);
}
public void SpawnFishSpawner(Transform parent)
{
poligonsArea = GetPoligonAre(poligonStep);
List<GameObject> list = new List<GameObject>();
for (int i = 0; i < fishSpawnerParent.transform.childCount; i++)
{
list.Add(fishSpawnerParent.transform.GetChild(i).gameObject);
}
foreach (GameObject item in list)
{
item.transform.parent = base.transform;
UnityEngine.Object.DestroyImmediate(item);
}
if (fishSpawners.Length > 0)
{
poligonsArea.SpawnObjects(parentPrefab, parent, poligonStep, fishSpawners);
}
}
private void OnDrawGizmos()
{
foreach (stBox box in boxes)
{
Gizmos.DrawCube(box.pos, box.size);
}
switch (editMode)
{
case EditMode.ExitBox:
if (lines.Count > 1)
{
for (int j = 0; j < lines.Count; j++)
{
Gizmos.DrawLine(lines[j], lines[(j + 1) % lines.Count]);
}
}
break;
case EditMode.FishAre:
if (fishArePoints.Count > 1)
{
for (int i = 0; i < fishArePoints.Count; i++)
{
Gizmos.DrawLine(fishArePoints[i], fishArePoints[(i + 1) % fishArePoints.Count]);
}
}
if (drawPoligonAre)
{
poligonsArea.DrawGizmos();
}
break;
}
}
private Vector2 toV2(Vector3 vector3)
{
return new Vector2(vector3.x, vector3.z);
}
[Button]
public void AddFishesToBaits()
{
AddBaitsName();
AddFishesName();
CreatFishesToBaits();
CreatFishesToBaitsDCL();
}
private void AddBaitsName()
{
string[] array = new string[0];
if (base.name.Length != 0)
{
string[] array2 = array;
foreach (string text in array2)
{
stBait item = new stBait
{
name = text,
fishLikesParams = new FishLikesParams[1]
};
baitList.Add(item);
}
}
}
private void AddFishesName()
{
List<stFish> list = new List<stFish>();
if (list.Count == 0)
{
return;
}
foreach (stFish item in list)
{
fishes.Add(item);
}
}
private void CreatFishesToBaits()
{
string[] array = new string[63]
{
"DEEPX Ocean D3P", "Sakura TailSpin", "Sakura Pop N Dog", "Sakura Soukouss Blade", "Sakura SCB Crank 100", "Sakura Dumbell Popper", "Sakura Tex Shad", "Sakura Slit Finesse", "Sakura Jackax Shad", "Sakura Dumbell Popp",
"Sakura Exopen", "Sakura Exostick", "Sakura Mister Joe", "Sakura Naja", "OKENA Fly N-H20 (Nyph_01)", "OKENA Fly N-H30 (Nyph_02)", "Fly mPH-I (Nymph_03)", "Fly mPH-II (Nymph_04)", "OKENA Fly ET-W6 (Wet_01)", "OKENA Fly ET-W8 (Wet_02)",
"Fly EE-B (Wet_03)", "Fly EE-C (Wet_04)", "PANIT Fly DY-3 (Dry_01)", "PANIT Fly DY-5 (Dry_02)", "Fly R-K05 (Dry_03)", "Fly R-K06 (Dry_04)", "PANIT Fly STREAM KI (Streamer_01)", "PANIT Fly STREAM KII (Streamer_02)", "Fly MER-1 (Streamer_03)", "Fly MER-2 (Streamer_04)",
"DAKINO R-900 (WoblerFibes)", "OKENA PP-175 (BabyPoppers)", "DAKINO QRT (GnomeMikado)", "OKENA Gx355 (HoloReflex)", "Sakura Skoon Slim", "Sakura Skoon Fat", "KUBOT KKW-5 (StreamMikado)", "DAKINO W/U-15 (BigEye)", "OKENA UK (ShadBerkley)", "KUBOT M-15T (SwingImpact)",
"DAKINO ZZ 470 (TwisterRelax)", "Sakura Queen Rana", "PLECIONKA*", "MONO*", "Cheese", "Bread", "Pea", "Corn", "Marshmallow", "Dough Ball",
"Semolina Balls", "Dragonfly", "Fly", "Maggot", "Red Worm", "Wax Worms", "Leech", "Grasshopper", "Natural Salmon Eggs", "Artificial Salmon Eggs",
"Live Bait", "Cutbait", "Bait Balls"
};
string[] names_ = new string[64]
{
"Rainbow Trout", "0", ">7", ">7", "<5", ">7", "0", "<3", "<3", ">5",
"0", "0", "0", "0", "0", "<4", "<4", ">6", ">7", ">7",
"<5", ">7", ">6", "<6", ">6", ">6", ">6", ">4", ">6", ">6",
">6", "<5", ">7", ">7", "<4", "<4", "<4", ">7", "<5", "<6",
">6", ">6", ">4", "5%", "50%", "0", "0", "0", "0", "0",
"0", "0", ">5", ">5", ">7", ">7", ">7", "<5", ">7", ">7",
">7", "<1", ">5", "<4"
};
string[] names_2 = new string[64]
{
"Brown Trout", "0", "<5", ">8", ">7", ">9", "0", "<3", ">7", ">4",
"0", "0", "0", "0", "0", "<4", "<4", ">7", ">6", ">7",
"<5", ">6", ">7", "<6", ">6", ">7", "<6", ">4", ">6", ">6",
"<6", "<5", ">7", ">7", "<4", "<4", "<4", ">7", "<5", "<6",
">6", ">6", ">4", "5%", "50%", "0", "0", "0", "0", "0",
"0", "0", ">5", ">5", ">7", ">7", ">7", "<5", ">7", ">7",
">7", "<1", ">5", "<4"
};
string[] names_3 = new string[64]
{
"Brook Trout", "0", "<5", "<5", ">8", ">6", "0", "<3", ">7", "<3",
"0", "0", "0", "0", "0", "<4", "<4", ">5", "<6", ">7",
"<5", "<6", ">5", "<6", ">6", ">5", ">7", ">6", ">6", ">7",
">6", "<5", ">7", ">7", "<4", "<4", "<4", ">7", "<5", "<6",
">6", ">6", ">6", "5%", "50%", "0", "0", "0", "0", "0",
"0", "0", ">5", ">5", ">7", ">7", ">7", "<5", ">7", ">7",
">7", "<1", ">5", "<4"
};
string[] names_4 = new string[64]
{
"Carp Koi", "0", "<1", "<1", "<1", "<1", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "<4", ">2", ">2", "<4", ">1",
">1", ">2", ">2", ">1", ">1", ">2", "<3", ">2", ">2", ">1",
">1", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0%", "0%", "<2", ">7", ">6", ">8", "<2",
">6", ">6", "<1", "<1", ">5", ">5", ">5", "<1", ">4", "<1",
"<1", "0", "0", ">7"
};
string[] names_5 = new string[64]
{
"Sockeye Salmon", "<3", "<5", "<4", ">5", ">9", ">6", ">9", "<4", ">8",
"<3", "<3", "<3", "<3", ">6", ">9", ">6", ">5", "<6", ">9",
">7", ">6", ">5", ">7", "<6", ">2", "<5", ">3", "<5", ">2",
"<5", ">9", ">7", ">7", ">8", ">5", ">6", ">7", "<2", ">4",
"<4", ">3", ">6", "20%", "80%", "<1", "<1", "<1", "<1", "<1",
"<1", "<1", "<3", "<3", "<3", "<3", "<3", "<3", "<3", ">8",
">7", ">9", ">7", "0"
};
string[] names_6 = new string[64]
{
"Tench", "0", "<2", "<1", "<2", "<1", "0", "<1", ">4", "<1",
"0", "0", "0", "0", "0", "<4", "<4", ">5", "<6", "<4",
"<4", "<4", ">5", ">6", ">6", ">6", ">6", ">7", ">6", ">5",
">6", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"<4", "<4", "0", "0%", "0%", "<2", ">6", ">6", ">6", ">3",
">6", ">6", "<3", "<3", ">8", ">9", ">7", "<1", ">4", "<1",
"<1", "0", "0", ">7"
};
string[] names_7 = new string[64]
{
"Rudd", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", ">9", ">6", ">5", "<6", ">9",
">7", ">6", ">5", ">7", "<6", ">2", "<5", ">3", "<5", ">2",
"<5", "<2", "<2", "<2", "<2", "<2", "<2", "<2", "<2", "<2",
"<2", "<2", "<2", "0%", "5%", "<2", ">6", ">6", ">6", ">3",
">6", ">6", ">6", ">6", ">7", ">7", ">5", "<1", ">7", "<1",
"<1", "0", "0", ">7"
};
string[] names_8 = new string[64]
{
"Flathead grey mullet", "0", ">8", "<4", "<7", ">3", "0", ">4", ">7", ">3",
"0", "0", "0", "0", "0", "<4", "<4", ">5", ">5", ">5",
"<4", ">7", ">6", ">2", ">2", ">7", ">6", ">2", "<5", ">2",
">2", "<5", "<5", ">7", "<4", "<4", "<4", ">5", "<4", "0",
"<5", "<5", "<3", "0%", "5%", ">5", ">5", "<5", "<5", ">5",
"<3", "<3", ">5", ">5", ">7", ">7", ">7", ">7", ">4", "1",
"1", "<1", ">5", "0"
};
string[] names_9 = new string[64]
{
"Giant kōkopu", "0", "<2", "<1", "<2", "<1", "0", "<1", ">4", "<1",
"0", "0", "0", "0", "0", "<4", "<4", ">5", "<6", "<4",
"<4", "<4", ">5", ">6", ">6", ">6", ">6", ">7", ">6", ">5",
">6", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"<4", "<4", "0", "0%", "0%", "<2", ">6", ">6", ">6", ">3",
">6", ">6", "<3", "<3", ">8", ">9", ">7", "<1", ">4", "<1",
"<1", "0", "0", ">7"
};
string[] names_10 = new string[64]
{
"Brown bullhead", "0", "0", "0", "0", "0", "0", ">5", "<4", ">9",
"0", "0", "0", "0", "0", "<1", "<1", "<2", "<1", "<1",
"<2", "<1", "<1", "0", "0", "0", "0", "0", "0", "<1",
"<1", "<4", "<4", "0", "0", "0", "0", "0", "0", "<5",
"0", "0", "0", "0%", "5%", ">7", ">4", ">5", ">7", ">5",
">5", ">7", "<3", "<3", "<3", "<3", "<3", "<3", "<3", "<3",
"<3", ">5", ">5", ">7"
};
string[] names_11 = new string[64]
{
"New Zealand longfin eel", "0", ">8", "<4", "<7", ">3", "0", ">4", ">7", ">3",
"0", "0", "0", "0", "0", "<4", "<4", ">5", ">5", ">5",
"<4", ">7", ">6", ">2", ">2", ">7", ">6", ">2", "<5", ">2",
">2", "<5", "<5", ">7", "<4", "<4", "<4", ">5", "<4", "0",
"<5", "<5", "<3", "0%", "5%", ">5", ">5", "<5", "<5", ">5",
"<3", "<3", ">5", ">5", ">7", ">7", ">7", ">7", ">4", "1",
"1", "<1", ">5", "0"
};
string[] names_12 = new string[64]
{
"Chinook salmon", "0", "<5", "<5", ">8", ">6", "0", "<3", ">7", "<3",
"0", "0", "0", "0", "0", "<4", "<4", ">5", "<6", ">7",
"<5", "<6", ">5", "<6", ">6", ">5", ">7", ">6", ">6", ">7",
">6", "<5", ">7", ">7", "<4", "<4", "<4", ">7", "<5", "<6",
">6", ">6", ">6", "5%", "50%", "0", "0", "0", "0", "0",
"0", "0", ">5", ">5", ">7", ">7", ">7", "<5", ">7", ">7",
">7", "<1", ">5", "<4"
};
List<stFishData> list = new List<stFishData>();
list.Add(new stFishData(names_));
list.Add(new stFishData(names_2));
list.Add(new stFishData(names_3));
list.Add(new stFishData(names_4));
list.Add(new stFishData(names_5));
list.Add(new stFishData(names_6));
list.Add(new stFishData(names_7));
list.Add(new stFishData(names_8));
list.Add(new stFishData(names_9));
list.Add(new stFishData(names_10));
list.Add(new stFishData(names_11));
list.Add(new stFishData(names_12));
foreach (stFishData item in list)
{
Fish.Species species;
if (!FindFish(item.fishName, out species))
{
continue;
}
foreach (stBait bait in baitList)
{
bool flag = false;
for (int i = 0; i < array.Length; i++)
{
if (bait.name == array[i])
{
flag = true;
bait.AddFish(species, item.values[i]);
break;
}
}
}
}
}
private void CreatFishesToBaitsDCL()
{
string[] array = new string[33]
{
"Dumbell Popper",
"Slider Sepia Madai Jig",
"Sepia Madai Jig",
"S-Shiner 145S",
"Speed Minnow 125S-150S",
"Orion Jig",
"Roll Kicker",
"Pulsion TR",
"Jackax Shad Rigged",
"Slit Finesse",
"Tex'Shad",
"Soukouss Blade",
"SCB Crank 100",
"Barbagrub",
"Bellamy Swim Jig",
"Bomba Crank 60F-70F",
"Cajun Double Indiana",
"Cajun Double Willow",
string.Empty,
string.Empty,
string.Empty,
string.Empty,
string.Empty,
"Cajun Single Indiana",
"Cajun Chatterbait",
"Croaker Crank 55F",
"Gobygo",
"Micro Soukouss Blade 30S-35S",
"Monarc",
"Monarc Micro",
"Monsoon",
"Phoxy Minnow HW",
"Rush Diver 90SP"
};
string[] names_ = new string[36]
{
"Rainbow Trout", "1", "0", "0", "0", "0", "0", "0", "2", "2",
"0", "1", "2", "5", "6", "5", "1", "3", "1", "2",
"4", "7", "7", "4", "9", "4", "8", "10", "1", "10",
"7", "8", "7", "3", "3", "8"
};
string[] names_2 = new string[36]
{
"Brown Trout", "1", "0", "0", "0", "0", "0", "0", "1", "2",
"2", "3", "2", "3", "6", "2", "5", "5", "10", "8",
"5", "4", "8", "8", "6", "4", "5", "8", "7", "4",
"10", "3", "1", "10", "6", "1"
};
string[] names_3 = new string[36]
{
"Brook Trout", "1", "0", "0", "0", "0", "0", "0", "2", "1",
"1", "1", "2", "9", "4", "9", "10", "8", "6", "4",
"7", "8", "2", "6", "1", "3", "6", "5", "8", "9",
"5", "5", "10", "9", "9", "10"
};
string[] names_4 = new string[36]
{
"Carp Koi", "0,4", "1", "0", "0", "0", "0", "0", "0", "0",
"0", "2", "1", "2", "4", "2", "2", "1", "4", "1",
"2", "1", "4", "2", "4", "3", "2", "1", "1", "2",
"1", "4", "1", "2", "2", "4"
};
string[] names_5 = new string[36]
{
"Giant Barb", "0", "1", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0"
};
string[] names_6 = new string[36]
{
"Sockeye Salmon", "1", "0,2", "1", "3", "3", "2", "4", "4", "7",
"6", "4", "2", "9", "8", "1", "10", "8", "2", "3",
"8", "4", "10", "4", "5", "10", "5", "8", "6", "3",
"8", "2", "4", "1", "2", "5"
};
string[] names_7 = new string[36]
{
"Tench", "0,2", "1", "0", "0", "0", "0", "0", "0", "0",
"0", "2", "2", "2", "2", "2", "2", "2", "2", "1",
"1", "1", "2", "2", "2", "1", "1", "2", "1", "2",
"1", "1", "7", "2", "2", "2"
};
string[] names_8 = new string[36]
{
"Rudd", "0,4", "0,6", "4", "1", "3", "2", "4", "1", "2",
"1", "2", "4", "2", "2", "1", "3", "4", "2", "2",
"1", "2", "4", "4", "2", "4", "2", "2", "1", "1",
"2", "2", "2", "1", "1", "3"
};
string[] names_9 = new string[36]
{
"Flathead grey mullet", "0,7", "0,3", "3", "7", "4", "7", "3", "7", "1",
"1", "7", "3", "2", "4", "5", "1", "7", "6", "3",
"1", "6", "1", "3", "4", "5", "1", "2", "7", "5",
"7", "6", "2", "5", "5", "3"
};
string[] names_10 = new string[36]
{
"Giant kōkopu", "0,2", "1", "0", "0", "0", "0", "0", "0", "0",
"0", "2", "2", "2", "2", "2", "2", "2", "2", "1",
"1", "1", "2", "2", "2", "1", "1", "2", "1", "2",
"1", "1", "7", "2", "2", "2"
};
string[] names_11 = new string[36]
{
"New Zealand longfin eel", "1", "0", "2", "0", "2", "2", "2", "3", "1",
"4", "1", "7", "2", "3", "6", "7", "8", "8", "8",
"4", "2", "6", "8", "2", "3", "8", "6", "9", "5",
"1", "3", "2", "7", "3", "7"
};
string[] names_12 = new string[36]
{
"Brown bullhead", "0,5", "0,5", "0", "0", "0", "0", "0", "0", "0",
"0", "3", "3", "5", "4", "5", "5", "3", "2", "2",
"4", "5", "2", "2", "5", "5", "1", "4", "3", "2",
"2", "3", "5", "2", "5", "1"
};
string[] names_13 = new string[36]
{
"Chinook salmon", "1", "0", "0", "0", "0", "0", "0", "1", "2",
"2", "3", "2", "3", "6", "2", "5", "5", "10", "8",
"5", "4", "8", "8", "6", "4", "5", "8", "7", "4",
"10", "3", "1", "10", "6", "1"
};
List<stFishData> list = new List<stFishData>();
list.Add(new stFishData(names_));
list.Add(new stFishData(names_2));
list.Add(new stFishData(names_3));
list.Add(new stFishData(names_4));
list.Add(new stFishData(names_5));
list.Add(new stFishData(names_6));
list.Add(new stFishData(names_7));
list.Add(new stFishData(names_8));
list.Add(new stFishData(names_9));
list.Add(new stFishData(names_10));
list.Add(new stFishData(names_11));
list.Add(new stFishData(names_12));
list.Add(new stFishData(names_13));
foreach (stFishData item in list)
{
Fish.Species species;
if (!FindFish(item.fishName, out species))
{
continue;
}
foreach (stBait bait in baitList)
{
bool flag = false;
for (int i = 0; i < array.Length; i++)
{
if (bait.name == array[i])
{
flag = true;
bait.AddFish(species, item.values[i + 2]);
break;
}
}
}
}
}
private bool FindFish(string fishName, out Fish.Species species)
{
species = Fish.Species.COUNT;
foreach (stFish fish in fishes)
{
if (fish.name == fishName)
{
species = fish.species;
}
}
if (species == Fish.Species.COUNT)
{
Debug.LogError("JKM Cant find fish[" + fishName + "] in fishs");
return false;
}
return true;
}
public void SetFishParams()
{
string[] ss = new string[6] { "Rainbow Trout", "waga kg: 0.7 - 23 rozmiar m: 0.4 - 1.45", "ranek - 8 południe - 10 wieczór - 7 noc - 2 ", "brak wiatru - 10 bardzo silny - 5", "czyste niebo - 10 mocne zachmurzenie - 7", "brak deszczu - 10 mocny deszcz - 7" };
string[] ss2 = new string[6] { "Brook Trout", "waga kg: 0.15 - 7,7 rozmiar m: 0.15 - 0.86", "ranek - 9 południe - 10 wieczór - 7 noc - 2 ", "brak wiatru - 9 bardzo silny - 5", "czyste niebo - 10 mocne zachmurzenie - 7", "brak deszczu - 10 mocny deszcz - 7" };
string[] ss3 = new string[6] { "Brown Trout", "waga kg: 0.7 - 20 rozmiar m: 0.4 - 1.20", "ranek - 10 południe - 8 wieczór - 7 noc - 2 ", "brak wiatru - 9 bardzo silny - 5", "czyste niebo - 10 mocne zachmurzenie - 7", "brak deszczu - 10 mocny deszcz - 6" };
string[] ss4 = new string[6] { "Carp Koi", "waga kg: 1.3 - 50 rozmiar m: 0.45 - 1.3", "ranek - 10 południe - 5 wieczór - 9 noc - 8", "brak wiatru - 9 bardzo silny - 4", "czyste niebo - 8 mocne zachmurzenie - 6", "brak deszczu - 9 mocny deszcz - 6" };
string[] ss5 = new string[6] { "Sockeye Salmon", "waga kg: 0.5 - 7.7 rozmiar m: 0.35 - 0.8", "ranek - 8 południe - 9 wieczór - 6 noc - 3 ", "brak wiatru - 10 bardzo silny - 3", "czyste niebo - 10 mocne zachmurzenie - 5", "brak deszczu - 10 mocny deszcz - 4" };
string[] ss6 = new string[6] { "Tench", "waga kg: 0.47 - 7.5 rozmiar m: 0.3 - 0.75", "ranek - 10 południe - 7 wieczór - 6 noc - 8", "brak wiatru - 9 bardzo silny - 4", "czyste niebo - 10 mocne zachmurzenie - 3", "brak deszczu - 9 mocny deszcz - 6" };
string[] ss7 = new string[6] { "Rudd", "waga kg: 0.05 - 1.0 rozmiar m: 0.05 - 0.40", "ranek - 8 południe - 9 wieczór - 6 noc - 2", "brak wiatru - 8 bardzo silny - 5", "czyste niebo - 9 mocne zachmurzenie - 4", "brak deszczu - 7 mocny deszcz - 7" };
string[] ss8 = new string[6] { "Flathead grey mullet", "waga kg: 0.15 - 8.2 rozmiar m: 0.10 - 1.0", "ranek - 9 południe - 5 wieczór - 8 noc - 2", "brak wiatru - 9 bardzo silny - 7", "czyste niebo - 10 mocne zachmurzenie - 4", "brak deszczu - 10 mocny deszcz - 7" };
string[] ss9 = new string[6] { "Giant kōkopu", "waga kg: 0.1 - 2.7 rozmiar m: 0.1 - 0.58", "ranek - 10 południe - 5 wieczór - 7 noc - 9 ", "brak wiatru - 9 bardzo silny - 7", "czyste niebo - 8 mocne zachmurzenie - 6", "brak deszczu - 10 mocny deszcz - 5" };
string[] ss10 = new string[6] { "Brown bullhead", "waga kg: 0.15 - 2.8 rozmiar m: 0.10 - 0.55", "ranek - 9 południe - 5 wieczór - 7 noc - 8", "brak wiatru - 9 bardzo silny - 7", "czyste niebo - 8 mocne zachmurzenie - 6", "brak deszczu - 7 mocny deszcz - 9" };
string[] ss11 = new string[6] { "New Zealand longfin eel", "waga kg: 0.35 - 25 rozmiar m: 0.15 - 1.85", "ranek - 9 południe - 6 wieczór - 8 noc - 10", "brak wiatru - 9 bardzo silny - 7", "czyste niebo - 8 mocne zachmurzenie - 6", "brak deszczu - 9 mocny deszcz - 4" };
string[] ss12 = new string[7] { "Chinook salmon", "Czawycza", "waga kg: 0.3 - 61.4 rozmiar m: 0.10 - 1.5", "ranek - 8 południe - 9 wieczór - 6 noc - 3", "brak wiatru - 10 bardzo silny - 3", "czyste niebo - 10 mocne zachmurzenie - 5", "brak deszczu - 10 mocny deszcz - 4" };
List<stFishPara> list = new List<stFishPara>();
list.Add(new stFishPara(ss));
list.Add(new stFishPara(ss2));
list.Add(new stFishPara(ss3));
list.Add(new stFishPara(ss4));
list.Add(new stFishPara(ss5));
list.Add(new stFishPara(ss6));
list.Add(new stFishPara(ss7));
list.Add(new stFishPara(ss8));
list.Add(new stFishPara(ss9));
list.Add(new stFishPara(ss10));
list.Add(new stFishPara(ss11));
list.Add(new stFishPara(ss12));
foreach (stFishPara item in list)
{
Fish fish = FindFish(item.s[0]);
if ((bool)fish)
{
Debug.Log("JKM " + item.s[0]);
List<float> numbers = GetNumbers(item.s[1]);
fish.WeightMinMax.x = numbers[0];
fish.WeightMinMax.y = numbers[1];
fish.LengthMinMax.x = numbers[2];
fish.LengthMinMax.y = numbers[3];
numbers = DivList(GetNumbers(item.s[2]));
fish.timeCurve = AnimationCurve.EaseInOut(0f, numbers[3], 24f, numbers[3]);
fish.timeCurve.AddKey(new Keyframe(5f, numbers[0]));
fish.timeCurve.AddKey(new Keyframe(12f, numbers[1]));
fish.timeCurve.AddKey(new Keyframe(19f, numbers[2]));
numbers = DivList(GetNumbers(item.s[3]));
fish.windCurve = AnimationCurve.EaseInOut(0f, numbers[0], 1f, numbers[1]);
numbers = DivList(GetNumbers(item.s[4]));
fish.cloudinessCurve = AnimationCurve.EaseInOut(0f, numbers[0], 1f, numbers[1]);
numbers = DivList(GetNumbers(item.s[5]));
fish.rainCurve = AnimationCurve.EaseInOut(0f, numbers[0], 1f, numbers[1]);
}
}
}
public void SetFishZachowanie()
{
string[] ss = new string[8] { "Rainbow Trout", "G", "1", "7", "5", "8", "STRAIGHT_SLOW (2) STRAIGHT (5) LIFT_DROP (3) STOP_GO (3) TWITCHING (5)", "Gdy znajdzie się przy powierzchni, wyskakuje ponad wodę. Liczne zwroty." };
string[] ss2 = new string[8] { "Brown Trout", "W", "1", "7", "5", "6", "STRAIGHT_SLOW (2) STRAIGHT (5) LIFT_DROP (3) STOP_GO (3) TWITCHING (5)", "Walka przy powierzchni, liczne zwroty oraz wyginanie ciała. Osiąga do 50 kg. Potrafi nurkować podczas walki, ale niezbyt głęboko. " };
string[] ss3 = new string[8] { "Brook Trout", "G", "1", "3", "3", "8", "STRAIGHT_SLOW (2) STRAIGHT (5) LIFT_DROP (3) STOP_GO (3) TWITCHING (5)", "Nie jest zbyt ciężka, walka dość spokojna, jednak potrafi szarpnąć. " };
string[] ss4 = new string[8]
{
"Carp Koi",
"G",
"5",
"5",
"2",
"3",
"STRAIGHT_SLOW (1) STRAIGHT (0) LIFT_DROP (3) STOP_GO (3) TWITCHING (0)",
string.Empty
};
string[] ss5 = new string[8]
{
"Sockeye Salmon",
"F",
"5",
"8",
"4",
"8",
"STRAIGHT_SLOW (5) STRAIGHT (5) LIFT_DROP (4) STOP_GO (5) TWITCHING (5)",
string.Empty
};
string[] ss6 = new string[8]
{
"Tench",
"G",
"5",
"5",
"2",
"5",
"STRAIGHT_SLOW (5) STRAIGHT (5) LIFT_DROP (5) STOP_GO (3) TWITCHING (5)",
string.Empty
};
string[] ss7 = new string[8]
{
"Rudd",
"F",
"5",
"3",
"4",
"2",
"STRAIGHT_SLOW (1) STRAIGHT (0) LIFT_DROP (3) STOP_GO (3) TWITCHING (0)",
string.Empty
};
string[] ss8 = new string[8]
{
"Flathead grey mullet",
"F",
"5",
"3",
"2",
"2",
"LIFT_DROP (5) STOP_GO (2) STRAIGHT_SLOW (4)",
string.Empty
};
string[] ss9 = new string[8]
{
"Giant kōkopu",
"G",
"9",
"5",
"2",
"5",
"STRAIGHT_SLOW (5) STRAIGHT (5) LIFT_DROP (5) STOP_GO (3) TWITCHING (5)",
string.Empty
};
string[] ss10 = new string[8] { "Brown bullhead", "G", "9", "3", "2", "2", "LIFT_DROP (2) TWITCHING (2)", "Żyje na zmiennej głębokości, jednakże preferuje dna zbiorników. Żeruje na mniejszych rybach, padlinie czy skorupiakach. " };
string[] ss11 = new string[8]
{
"New Zealand longfin eel",
"G",
"9",
"10",
"1",
"7",
"LIFT_DROP (5) STOP_GO (2) STRAIGHT_SLOW (4)",
string.Empty
};
string[] ss12 = new string[8]
{
"Chinook salmon",
"W",
"3",
"7",
"5",
"6",
"STRAIGHT_SLOW (2) STRAIGHT (5) LIFT_DROP (3) STOP_GO (3) TWITCHING (5)",
string.Empty
};
List<stFishPara> list = new List<stFishPara>();
list.Add(new stFishPara(ss));
list.Add(new stFishPara(ss2));
list.Add(new stFishPara(ss3));
list.Add(new stFishPara(ss4));
list.Add(new stFishPara(ss5));
list.Add(new stFishPara(ss6));
list.Add(new stFishPara(ss7));
list.Add(new stFishPara(ss8));
list.Add(new stFishPara(ss9));
list.Add(new stFishPara(ss10));
list.Add(new stFishPara(ss11));
list.Add(new stFishPara(ss12));
foreach (stFishPara item in list)
{
Fish fish = FindFish(item.s[0]);
if ((bool)fish)
{
if (item.s[1] == "G")
{
fish.normalDepthStyle = Fish.DepthStyle.GROUND_LEVEL;
}
else if (item.s[1] == "W")
{
fish.normalDepthStyle = Fish.DepthStyle.WATER_LEVEL;
}
else if (item.s[1] == "F")
{
fish.normalDepthStyle = Fish.DepthStyle.FREE;
}
fish.normalDepthLevel = 0.5f;
if (float.TryParse(item.s[2], out fish.fightDepthLevel))
{
fish.fightDepthLevel /= float.PositiveInfinity;
}
else
{
fish.fightDepthLevel = 0.1f;
}
if (float.TryParse(item.s[3], out fish.Aggressiveness))
{
fish.Aggressiveness /= 9f;
}
else
{
fish.Aggressiveness = 0.5f;
}
if (float.TryParse(item.s[4], out fish.DepthAggressivenessFight))
{
fish.DepthAggressivenessFight /= 9f;
}
else
{
fish.DepthAggressivenessFight = 0.5f;
}
}
}
}
private List<float> DivList(List<float> l, float value = 10f)
{
List<float> list = new List<float>();
foreach (float item in l)
{
list.Add(item / value);
}
return list;
}
private List<float> GetNumbers(string str)
{
List<float> list = new List<float>();
string text = string.Empty;
int num = 0;
char[] array = str.ToCharArray();
foreach (char c in array)
{
if (c >= '0' && c <= '9')
{
text += c;
num = 1;
}
else if (c == '.' || c == ',')
{
if (num == 1)
{
text += '.';
}
else
{
num = 0;
}
}
else if (text.Length > 0)
{
float result = 0f;
if (float.TryParse(text, out result))
{
list.Add(result);
}
text = string.Empty;
num = 0;
}
}
if (text.Length > 0)
{
float result2 = 0f;
if (float.TryParse(text, out result2))
{
list.Add(result2);
}
}
return list;
}
private Fish FindFish(string name)
{
foreach (stFish fish in fishes)
{
if (fish.name == name)
{
return fish.fish;
}
}
return null;
}
public void SetIconsOnBuildAsset()
{
}
}