void PlayBGMSound(FishData playerData) { BGMData setBGMData = BGMData.Ingame; if (playerData.isTargetedByPredator) { setBGMData = BGMData.PredatorChase; //Debug.Log("Is targeted"); UIGameController.Instance.ShowPanelPredatorRed(); UIGameController.Instance.AnimatePredatorRed(); } else if (playerData.isInPredatorRange == 1) //octopus { setBGMData = BGMData.PredatorArea; //Debug.Log("In Predator range"); UIGameController.Instance.ShowPanelPredatorRed(); } else if (playerData.isInPredatorRange == 2) //shark { setBGMData = BGMData.PredatorAreaShark; //Debug.Log("In Predator range"); UIGameController.Instance.ShowPanelPredatorShark(); } if (usedBGMData != setBGMData) { usedBGMData = setBGMData; SoundUtility.Instance.SetBGM(usedBGMData); UIGameController.Instance.HidePanelPredator(); } }
private void SetUIExp(FishData fish, bool isPlayer) { if (isPlayer) { float currentMaxExp = DefaultParameterManager.Instance.GetFishParameterData(fish.fishSkin, fish.level).maxExp; float prevMaxExp = GetPreviousLevelMaxExp(fish.fishSkin, fish.level); if (expFirstAssign) { fishIndicator.SetExpBarData(currentMaxExp - prevMaxExp); expFirstAssign = false; fishIndicator.ShowExpBar(); } if (fish.level != localLevelIndicator) { int prevLevelMaxExp = 0; fishIndicator.SetExpBarData(currentMaxExp - prevMaxExp); } if (fish.experience != localExpIndicator) { fishIndicator.CalculateFishExp(fish.experience - prevMaxExp); } } else { //do nothing if not player fish } }
// sprite goes from 0 to 2 public void fishChangeSprite(int sprite) { fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id); GetComponent <SpriteRenderer>().sprite = fishData.fishSprite[sprite]; //currentFishSprite = fishData.fishSprite[sprite]; }
FishData CompileUserData(string userData) { FishData playerFish = new FishData(); string[] playerData = userData.Split(';'); string[] playerArray = playerData[0].Split(','); playerFish.playerID = playerArray[0]; playerFish.playerName = playerArray [1]; playerFish.xPosition = float.Parse(playerArray [2]) / scaleFactor; playerFish.yPosition = float.Parse(playerArray [3]) / scaleFactor; playerFish.fishAngle = float.Parse(playerArray [4]); playerFish.colorCode = int.Parse(playerArray [5]); playerFish.fishSkin = playerArray [6]; playerFish.level = int.Parse(playerArray [7]); FishParameterData levelData = DefaultParameterManager.Instance.GetFishParameterData(playerFish.fishSkin, playerFish.level); if (levelData != null) { playerFish.width = levelData.totalSize; playerFish.height = levelData.totalSize; } playerFish.experience = float.Parse(playerArray [8]); playerFish.buffType = int.Parse(playerArray[9]); playerFish.buffTime = float.Parse(playerArray[10]); playerFish.isInPredatorRange = int.Parse(playerArray [11]); // == 1 ? true : false; playerFish.isTargetedByPredator = int.Parse(playerArray[12]) == 1 ? true : false; playerFish.isBoost = int.Parse(playerArray[13]) == 1 ? true : false; playerFish.boostValue = float.Parse(playerArray [14]); //playerFish.isTargetedByPredator = true; //playerFish.isInPredatorRange = true; if (playerData.Length > 1) { for (int i = 1; i < playerData.Length; i++) { FishBodyData bodyData = new FishBodyData(); string[] rawBodyData = playerData[i].Split(','); bodyData.xPosition = float.Parse(rawBodyData[0]) / scaleFactor; bodyData.yPosition = float.Parse(rawBodyData[1]) / scaleFactor; bodyData.width = float.Parse(rawBodyData[2]) / scaleFactor; bodyData.height = float.Parse(rawBodyData[3]) / scaleFactor; playerFish.bodies.Add(bodyData); } } localPos = new Vector2(playerFish.xPosition, playerFish.yPosition); if (playerID != playerArray [0]) { Debug.LogError("ERROR - ID does not match"); } return(playerFish); }
public void setInfo(StadiumGraphWorker graph, FishData fd) { this.graph = graph; this.fd = fd; int dir = UnityEngine.Random.Range(0, 3); float pos = UnityEngine.Random.Range(0, SAACollection.height) - SAACollection.halfHeight; int or = pos > 0 ? 1 : -1; float npos = UnityEngine.Random.Range(0, SAACollection.height) - SAACollection.halfHeight; double angle = (npos > pos ? (npos - pos) / SAACollection.width : (pos - npos) / SAACollection.halfWidth); angle *= 180 / Math.PI; Vector3 v3 = new Vector3(0, pos, 0); Vector3 q = new Vector3(0, 0, 0); if (dir == 0) {//left 0 //test.transform. v3.x = -SAACollection.halfWidth; q.z = -or * (float)angle; q.y = 180; } else {//right 1 v3.x = SAACollection.halfWidth; q.z = or * (float)angle; } transform.eulerAngles = q; transform.position = v3; }
void Update() { if (Input.GetMouseButtonDown(0)) { screenSizeX = Camera.main.pixelWidth; windowSizeX = 260f; screenSizeY = Camera.main.pixelHeight; windowSizeY = lineSize * 5; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Debug.DrawRay (ray.origin, ray.direction*300, Color.yellow); if (Physics.Raycast(ray.origin, ray.direction, out hit) && hit.collider.tag.Equals("fish")) { selectedFish = hit.collider.gameObject; data = selectedFish.GetComponent <FishData>(); showGUI = true; } else { showGUI = false; } } if (Input.GetMouseButtonDown(1)) { showGUI = false; } }
public void SetFishBodies(FishData data) { //Set The position of the head SetPosition(data.xPosition, data.yPosition, data.fishAngle); //Set The size of the head SetFishSize(data.width, data.height); //Set Fish Level According to the level given in data SetFishLevel(data.level); if (EssentialData.Instance.IsShowBody) { //Set Bodies position and size for (int i = 0; i < data.bodies.Count; i++) { FishBodyData bodyData = data.bodies[i]; if (i >= bodyObjects.Count) { //Create new body object for the fish GameObject go = Instantiate(headHitBox) as GameObject; go.name = "Fish " + data.playerID + " Body " + (i + 1); go.transform.SetParent(tFishBodies); go.transform.localPosition = new Vector3(bodyData.xPosition, bodyData.yPosition, 0); go.transform.localScale = new Vector3(bodyData.width, bodyData.height, 1.0f); go.SetActive(true); bodyObjects.Add(go); } else { bodyObjects[i].transform.position = new Vector3(bodyData.xPosition, bodyData.yPosition, 0); bodyObjects[i].transform.localScale = new Vector3(bodyData.width, bodyData.height, 1.0f); } } } }
public static FishData[] allFish(GameObject self, float distance) { GameObject[] everyFish; everyFish = GameObject.FindGameObjectsWithTag("Fish"); int addIndex = 0; int resultSize = 0; GameObject[] tempList; tempList = new GameObject[everyFish.Length]; foreach (GameObject fish in everyFish){ if (Calc.isInRange(self, fish, distance) && (fish != self)){ resultSize ++; tempList[addIndex] = fish; addIndex ++; } } if (resultSize != 0){ FishData[] resultList; resultList = new FishData[resultSize]; for(int i = 0; i<resultSize; i++){ resultList[i] = new FishData(tempList[i].GetComponent<SpeciesStats>().species, tempList[i], Calc.relationship(self,tempList[i])); } return resultList; } else return null; }
/// <summary> /// /// </summary> /// <param name="fish"></param> public void AddFish(Fish.FishInfo fish_) { if (fish_ == null) { return; } m_caughtFishCount++; if (!isCaught(fish_)) { var f = new FishData { fishName = fish_.fishName, count = 1 }; m_fishes.Add(f); return; } foreach (var i in m_fishes) { if (i.fishName == fish_.fishName) { i.count++; return; } } }
public void setInfo(StadiumGraphWorker graph, FishData fd, long delay) { fish = transform.Find(SAAppConfig.Language + "_" + fd.fishID + "s"); stfish = STFish.getMap()[fd.fishID]; life = stfish.Life; this.graph = graph; this.fd = fd; float pos; float npos; isRight = fd.begin < 0; if (isRight)//从右侧出发 { pos = SAACollection.height * -fd.begin / 20 - SAACollection.halfHeight; npos = SAACollection.height * fd.end / 20 - SAACollection.halfHeight; transform.position = new Vector3(SAACollection.halfWidth, pos, 0); transform.LookAt(new Vector3(-SAACollection.halfWidth, npos, 0)); } else { pos = SAACollection.height * fd.begin / 20 - SAACollection.halfHeight; npos = SAACollection.height * -fd.end / 20 - SAACollection.halfHeight; transform.position = new Vector3(-SAACollection.halfWidth, pos, 0); transform.LookAt(new Vector3(SAACollection.halfWidth, npos, 0)); } //矫正位置 //transform.Translate(Vector3.forward * stfish.Speed * delay / 1000); }
void SpawnFish() { Vector3 pos; do { pos = new Vector3( Random.Range(c_fish_bounds.xMin, c_fish_bounds.xMax), c_fish_y, Random.Range(c_fish_bounds.yMin, c_fish_bounds.yMax) ); }while (m_TerrainBuilder.SampleHeightDataWorld(pos.x, pos.z) > 110); float angle = Random.Range(0, 2 * Mathf.PI); Vector3 vel = new Vector3( Mathf.Cos(angle) * c_fish_speed, 0.0f, Mathf.Sin(angle) * c_fish_speed ); GameObject fish = GameObject.Instantiate(m_Fish); fish.transform.SetParent(transform); fish.transform.position = pos; FishData fishData = new FishData(); fishData.m_fish = fish; fishData.m_velocity = vel; m_fishList.Add(fishData); }
public void ReadFishInformation() { CSVReader.instance.ReadNew("Table/table_fish", data => { for (int i = 0; i < data.Count; i++) { FishData fishInfo = new FishData(); int index = int.Parse((data[i]["index"]).ToString()); if (fishInfoDictionary.ContainsKey(index) == false) { fishInfo.fishName = (data[i]["Name"]).ToString(); fishInfo.spriteName = (data[i]["SpriteName"]).ToString(); fishInfo.moveSpeed = float.Parse((data[i]["MoveSpeed"]).ToString()); fishInfo.weight = int.Parse((data[i]["Weight"]).ToString()); fishInfo.size = int.Parse((data[i]["Size"]).ToString()); fishInfo.hitCount = int.Parse((data[i]["HitCount"]).ToString()); fishInfoDictionary.Add(index, fishInfo); } } }); }
public void UpdateFish(List <FishData> listOpponent, FishData playerFish) { for (int idx = 0; idx < listOpponent.Count; idx++) { FishData data = listOpponent[idx]; int fIdx = registeredFish.FindIndex(x => x.Id.Equals(data.playerID)); //Find the given data in the list. If it's not in the list, create new food for the data if (fIdx < 0) { GameObject go = fishPool.GetGameObject(data.fishSkin); FishController control = go.GetComponent <FishController>(); control.SetTag(EssentialData.TAG_ENEMY); control.SetData(data, false); registeredFish.Add(control); } //When it's already in the list, just reset the data else { registeredFish[fIdx].SetData(data, false); } } fishUpdateCount += 1; //Clear food after 10 updates, to reduce procesing cost if (fishUpdateCount >= 5) { ClearFish(listOpponent, playerFish); fishUpdateCount = 0; } }
public void GoFishing() { listOfFishToCatch.Clear(); foreach (FishData f in fishList.fishList) { listOfFishToCatch.Add(f); } print("Going fishing"); _fishAvailableToCatch.Clear(); caughtFish = null; //take the list of fish we have foreach (FishData f in listOfFishToCatch) { //Debug.Log("Checking fish: " + f.name); //compare all the parameters to weed out possibilities //region below works** #region //check body of water if (f.bodyOfWaterTypes.Contains(_bodyOfWaterType) || f.bodyOfWaterTypes.Contains(fishEnums.BodyOfWaterType.Any) || _bodyOfWaterType == fishEnums.BodyOfWaterType.Any) { //check time of day if (f.TimesOfDay.Contains(_timeOfDay) || f.TimesOfDay.Contains(fishEnums.TimeOfDay.Any) || _timeOfDay == fishEnums.TimeOfDay.Any) { //check attractant if (f.attractants.Contains(_attractant) || f.attractants.Contains(fishEnums.Attractant.Any) || _attractant == fishEnums.Attractant.Any) { //check tool if (f.toolsRequired.Contains(_toolRequired) || f.toolsRequired.Contains(fishEnums.ToolRequired.Any) || _toolRequired == fishEnums.ToolRequired.Any) { //check casting range if (f.castingRanges.Contains(_castingRange) || f.castingRanges.Contains(fishEnums.CastingRange.Any) || _castingRange == fishEnums.CastingRange.Any) { _fishAvailableToCatch.Add(f); } } } } } #endregion } //final step of catching fish ReturnCaughtFish(); }
public frmFishData() { InitializeComponent(); _fishData = new FishData(); btnClear.Enabled = true; SetMeasurements(); SetLineWidthCombo(); }
public void creatFish(FishData data) { GameObject fishObj = GameController.GetInstance().getPrefab(data.fishName); GameObject curfish = (GameObject)Instantiate(fishObj, data.position, Quaternion.identity, BattleLayer.transform); curfish.AddComponent <Fish> ().init(data, BattleMode); fishEntityList.Add(curfish); }
public FishController(IFishService fishService, IOptions <PagingOptions> defaultPagingOptionsWrapper, IOptions <FishData> fishDataWrapper) { _fishService = fishService; _defaultPagingOptions = defaultPagingOptionsWrapper.Value; _fishData = fishDataWrapper.Value; }
public void OnClickedIsland() { FishManager.GetInstance().Initialize(); FishData.GetInstance().GameState = GameState.MainLoop; gameObject.SetActive(false); UIManager.GetInstance().Show("Debug"); }
public void UpdateDisplayUI(FishData fishData) { score.text += " " + fishData.FishValue; fishName.text += " " + fishData.FishSpecies; fishRarity.text += " " + fishData.FishRarity; fishSize.text += " " + fishData.FishSize; timeCaught.text += Time.realtimeSinceStartup.ToString(); }
public void DebugCatchCatchesManyFish() { var response = AdminModule.DebugCatch(""); Assert.IsTrue(response.Processed); Assert.AreNotEqual(0, response.Debug.Count); Assert.IsTrue(response.Debug.Any(x => FishData.Any(y => x.Contains(y.Name)))); }
void creatFish() { direct = Quaternion.AngleAxis(20f, Vector3.forward) * direct.normalized; FishData data = new FishData(spec, direct, transform.position, 0, 0, 0); BattleController.GetInstance().creatFish(data); }
/* * creates a new fish and returns it. * leader is the cluster's name * isLeader defines if it is main fish that represents the cluster. */ public GameObject SpawnFish(string leader, bool isLeader) { GameObject fish = Instantiate(fishPrefab, transform.FindChild("center").transform.position, Quaternion.identity) as GameObject; FishData fd = fish.GetComponent <FishData> (); FishMovement fm = fish.GetComponent <FishMovement>(); fd.school = leader; if (isLeader) { fd.name = leader; fd.isSchoolLeader = isLeader; GameObject[] allfish = GameObject.FindGameObjectsWithTag("fish"); foreach (GameObject followerFish in allfish) { if (followerFish.GetComponent <FishData> ().school.Equals(leader)) { followerFish.GetComponent <FishMovement> ().leaderFish = fish; } if (followerFish.name.Equals(leader) && followerFish != fish) { Destroy(followerFish); } } } else { fm.leaderFish = GameObject.Find(leader); } if (leader.Equals("sandhills")) { if (isLeader) { fd.fishColor = new Color(0f, 0.3f, 0f); } else { fd.fishColor = Color.green; } } else if (leader.Equals("red-workers")) { if (isLeader) { fd.fishColor = new Color(0.3f, 0f, 0f); } else { fd.fishColor = Color.red; } } else { fd.fishColor = Color.cyan; } fd.SetColor(fd.fishColor); return(fish); }
void OnLoadFishData(FishData _dataLoaded) { dataToSave = new FishData(_dataLoaded); if (dataToSave.spriteId != null) { pickedIcon = AssetsBundlesManager.GetAssetBundle(BundleName.FishIcons).LoadAsset <Sprite>(dataToSave.spriteId); } Repaint(); }
public void AddFish(int id, FishTraits traits, FishData dataTemplate) { this.AddedTraits.Add(id, traits); this.AddedData.Add(id, dataTemplate); // Register fish if the API has already been loaded this.Api?.SetFishTraits(id, traits); this.Api?.SetFishName(id, traits.Name); }
public static FishData GetInstance() { if (mInstance == null) { mInstance = new FishData(); } return(mInstance); }
/// <summary> /// パーツデータを魚のパラメータに変換 /// </summary> public void InitData(FishData data) { int fixedPartsCount = 2; if (data.Body._id >= 0 && data.Eye._id >= 0) { Param = new CharaParam() { Height = FishMasterData.GetBody(data.Body._id).Height, Attack = FishMasterData.GetBody(data.Body._id).Attack + FishMasterData.GetEye(data.Eye._id).Attack, Weight = FishMasterData.GetBody(data.Body._id).Weight, Aggressive = FishMasterData.GetEye(data.Eye._id).Aggressive, Hp = 0, Speed = 0, Agility = 0 }; for (int i = 0; i < data.Fin.Count; i++) { Param.Weight += FishMasterData.GetFin(data.Fin[i]._id).Weight; Param.Height += FishMasterData.GetFin(data.Fin[i]._id).Height; Param.Sight += FishMasterData.GetFin(data.Fin[i]._id).Sight; Param.Attack += FishMasterData.GetFin(data.Fin[i]._id).Attack; } ParamInit(); InstantiateParts(0, FishMasterData.MaterialPath[PartsType.Body] + data.Body._id, data.Body._pos); InstantiateParts(1, FishMasterData.MaterialPath[PartsType.Eye] + data.Eye._id, data.Eye._pos); for (int i = 0; i < data.Fin.Count; i++) { InstantiateParts(i + fixedPartsCount, FishMasterData.MaterialPath[PartsType.Fin] + data.Fin[i]._id, data.Fin[i]._pos); } } else { DefaultParam(); ParamInit(); DefaultMaterial(); } //dummy --------------------------- Param = new CharaParam() { Hp = 1, Height = 1, Attack = 1, Weight = 20, Speed = 1, Agility = 20, Sight = 1 }; //dummy --------------------------- Init(); isInit = true; }
void InstantiateFish(int id, Vector2 pos, int mem) { FishData data = new FishData();//Masterからロード data = LocalDataManager.LoadFishData(0); GameObject f = Instantiate(_fishBase, pos, Quaternion.identity); f.GetComponent <FishBase>().InitData(data); f.GetComponent <FishBase>().Team = mem; }
public GameObject spawnFish(string baseId) { FishData fishData = this.GetFishDataById(baseId); Fish fish = new Fish(fishData); this.currentSpawnedFish = fish; GameObject fishToSpawn = (GameObject)Instantiate(Resources.Load("Prefabs/Fish"), GameManager.instance.hook.transform.position, Quaternion.identity); return(fishToSpawn); }
public void UpdatePlayer(FishData playerData, List <FoodData> listFoodData) { UpdateCamera(playerData.xPosition, playerData.yPosition); if (previousPlayerData == null || previousPlayerData.level != playerData.level) { UpdateViewPort(playerData); } playerFish.SetData(playerData, true); //Update UI information UIGameController.Instance.UpdatePlayerPosition(playerData.xPosition, playerData.yPosition); UIGameController.Instance.UpdatePlayerLevel(playerData.level, playerData.experience); UIGameController.Instance.UpdatePlayerPoint(Mathf.RoundToInt(playerData.experience)); previousPlayerData = playerData; OcculsionManager.Instance.UpdateOcculstion(playerData); //Food Eaten Calculation float playerRadius = playerData.width / 2; float foodRadius; try { for (int i = 0; i < listFoodData.Count; i++) { foodRadius = listFoodData[i].width / 2; //compare food pos and player pos float xDiff = Mathf.Abs(listFoodData[i].xPosition - playerData.xPosition); float yDiff = Mathf.Abs(listFoodData[i].yPosition - playerData.yPosition); float foodDistance = xDiff + yDiff; //if the distance is lesser than both radius added, it is eaten if (foodDistance <= (foodRadius + playerRadius)) { //Search the GO, play animation with the gameobject and change its tag to eaten int idx = registeredFood.FindIndex(x => x.foodId == listFoodData[i].foodID); if (idx >= 0) { playerFish.fishLevelControl.EatingAnimationStart(registeredFood[idx].gameObject); registeredFood[idx].gameObject.tag = "Eaten"; } } } } catch (System.Exception e) { Debug.Log("Food Animation Error - " + gameObject.name + " : " + e.ToString()); } RandomBubbleController.Instance.AutomateRandomBubble(playerData); PlayBGMSound(playerData); }
public override void MngUpdate() { //生成批次的控制 CreatStreamTimer += Time.deltaTime; if (CreatStreamTimer < CreatStreamTime) { return; } CreatStreamTimer = 0; //得到产鱼位置 index int posIndex = Random.Range(0, FishCreatPoint.Length / 2); //得到产鱼种类 index int fishIndex; if (Random.Range(0f, 1f) < isBigFish) { fishIndex = Random.Range(0, FishPre.Length); } else { fishIndex = Random.Range(FishPre.Length / 4 + 1, FishPre.Length); } //得到该种鱼的一些属性 FishData fishData = MainPoolManager.Instance.GetData(PoolType.FISH, fishIndex) as FishData; //此批次产鱼数 int creatNum = Random.Range(fishData.maxNum / 2 + 1, fishData.maxNum); //鱼的速度 (1-fishIndex/FishPre.Length/3f)位置靠后的鱼速度越慢 float speed = Random.Range(fishData.moveSpeed / 2f, fishData.moveSpeed) * (1 - fishIndex / FishPre.Length / 3f); Transform fishCreatPos = FishCreatPoint[posIndex]; //得到鱼游的属性 float line = Random.Range(0f, 1f); if (line < 0.5f)//直线 { float straightAngle = Random.Range(-22f, 22f); StartCoroutine(CreatStraightFishStram(fishCreatPos, fishIndex, creatNum, speed, straightAngle)); } else//曲线 { float rotateAngle; float rotateAngleSign = Random.Range(0f, 1f); if (rotateAngleSign < 0.5f) { rotateAngle = Random.Range(-8f, -15f); } else { rotateAngle = Random.Range(8f, 15f); } StartCoroutine(CreatTrunFishStram(fishCreatPos, fishIndex, creatNum, speed, rotateAngle)); } }
void ChangeFishSize(int sizeModifer) { GameObject[] allFish = GameObject.FindGameObjectsWithTag("fish"); foreach (GameObject fish in allFish) { FishData fishData = fish.GetComponent <FishData>(); fishData.baseScale += sizeModifer * tankScale; fishData.Resize(fishData.baseScale); } Debug.Log(allFish[1].GetComponent <FishData>().baseScale); }
private bool isFishIntesedted(int model, Vector3 coords) { var data = FishDatas.FirstOrDefault(i => i.ModelHash == model); if (data == null) { return(false); } this.CurrentFishData = data; return(data.FishBait == this.CurrentBait); }
public frmFishData(int id, int row) { InitializeComponent(); _fishData = new FishData(); _fishData.Experiment = id; _fishData.Row = row; SetMeasurements(); SetLineWidthCombo(); SetFields(); btnClear.Enabled = false; }