private void LoadDialogText() { if (nowDialogueData.textSize == 0 && nowDialogueData.dialogText == null) { FindChild.FindTheChild(CanvasGameObject, "Boxbg").SetActive(false); } else { FindChild.FindTheChild(CanvasGameObject, "Boxbg").SetActive(true); Text text = FindChild.FindTheChild(CanvasGameObject, "DialogText").GetComponent <Text>(); textAnimation = DOTween.Sequence(); textAnimation.SetUpdate(true); //设置移动类型 textAnimation.SetEase(Ease.Linear); textAnimation.AppendCallback(() => { text.text = null; }); textAnimation.Append(text.DOText(nowDialogueData.dialogText, nowDialogueData.dialogText.Length * 0.2f)); if (nowDialogueData.textPositon == "居中") { FindChild.FindTheChild(CanvasGameObject, "DialogText").GetComponent <Text>().alignment = TextAnchor.MiddleCenter; } else if (nowDialogueData.textPositon == null) { FindChild.FindTheChild(CanvasGameObject, "DialogText").GetComponent <Text>().alignment = TextAnchor.UpperLeft; } FindChild.FindTheChild(CanvasGameObject, "DialogText").GetComponent <Text>().fontSize = nowDialogueData.textSize; } }
public void ChangeMap() { switch (MapDropDown.GetComponent <Dropdown>().value) { case 0: MapAttribute.NowMapArr = MapAttribute.MapHomeArr; FindChild.FindTheChild(mainControler, "Map"); break; case 1: MapAttribute.NowMapArr = MapAttribute.MapFarmArr; break; case 2: MapAttribute.NowMapArr = MapAttribute.MapSquareArr; break; case 3: MapAttribute.NowMapArr = MapAttribute.MapForestArr; break; default: break; } }
void Start() { _rigidbody2D = GetComponent <Rigidbody2D>(); GameObject playerSprite = FindChild.FindTheChild(gameObject, "PlayerSprite"); animator = playerSprite.GetComponent <Animator>(); animator.SetInteger("DirectionEnum", (int)PlayerAnimEnum.PlayerDirection.Down); //初始位置向下 }
private void LoadVoice() { if (nowDialogueData.sound != null) { FindChild.FindTheChild(CanvasGameObject, "RoleVoice").GetComponent <AudioSource>().clip = Resources.Load("Voice/" + nowDialogueData.sound, typeof(AudioClip)) as AudioClip; FindChild.FindTheChild(CanvasGameObject, "RoleVoice").GetComponent <AudioSource>().Play(); } }
private void Awake() { _Instance = this; NowVitality = FindChild.FindTheChild(gameObject, "NowVitality"); MaxVitality = FindChild.FindTheChild(gameObject, "MaxVitality"); VitalityInfo = FindChild.FindTheChild(gameObject, "VitalityInfo"); VitalityValue = FindChild.FindTheChild(gameObject, "VitalityValue"); }
private void ScaleRole2() { Vector3 scaleRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localScale; scaleRole2.x = (float)nowDialogueData.ImageState2[2] / 100; scaleRole2.y = scaleRole2.x; FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localScale = scaleRole2; }
void Start() { CanvasGameObject = GameObject.FindWithTag("Canvas"); BGGameObject = FindChild.FindTheChild(CanvasGameObject, "BG"); FullScreeAnimationGameObject = FindChild.FindTheChild(CanvasGameObject, "FullScreeAnimation"); //运行时对Canvas的GameObject进行绑定 //**** 可以在此处插入剧情开始流程****// DialogReduction(nowDialogueID); //加载第一句对话 }
} //完成了BGM播放,如果要播放的bgm与上一句相同,则不作任何 改变 private void LoadSayerName() { if (nowDialogueData.sayerID == 0) { FindChild.FindTheChild(CanvasGameObject, "SayerName").GetComponent <Text>().text = null; } else { FindChild.FindTheChild(CanvasGameObject, "SayerName").GetComponent <Text>().text = dataManager.GetCharactersItemByID(nowDialogueData.sayerID).name; } }
private void getItemUIObjects() { for (int i = 0; i < FarmDataManager._Instance.mainData.itemListArr.GetLength(1); i++) { GameObject temp = FindChild.FindTheChild(GameObject.Find("UI"), i.ToString()); if (temp != null) { itemImgArr.Add(temp); } } }
private void LoadCG() { if (nowDialogueData.CGImage != null) { FindChild.FindTheChild(CanvasGameObject, "CG").GetComponent <RawImage>().texture = Resources.Load("CG/" + nowDialogueData.CGImage, typeof(Texture)) as Texture; FindChild.FindTheChild(CanvasGameObject, "CG").GetComponent <RawImage>().DOColor(new Color(225, 225, 225, 1), 0.5f); } else { FindChild.FindTheChild(CanvasGameObject, "CG").GetComponent <RawImage>().DOColor(new Color(225, 225, 225, 0), 0.5f); } }
void OnMouseDown() { mainControler = transform.parent.parent.gameObject; mapLengthX = mainControler.GetComponent <MapEditor>().mapLengthX; mapLengthY = mainControler.GetComponent <MapEditor>().mapLengthY; cellLengthX = mainControler.GetComponent <MapEditor>().cellLengthX; cellLengthY = mainControler.GetComponent <MapEditor>().cellLengthY; GameObject cellXText = FindChild.FindTheChild(mainControler, "CellXInput"); GameObject cellYText = FindChild.FindTheChild(mainControler, "CellYInput"); cellXText.GetComponent <InputField>().text = Mathf.Round((transform.position.x + mapLengthX / 2 - cellLengthX / 2) / cellLengthX).ToString(); cellYText.GetComponent <InputField>().text = Mathf.Round((mapLengthY / 2 - cellLengthY / 2 - transform.position.y) / cellLengthY).ToString(); // cellYText.GetComponent<TextEditor>().text =; }
private void LoadBGM() { if (nowDialogueID == originalDialogueID || nowDialogueData.Bgm != LastDialogueData.Bgm) //本句是第一句话或与上一句数据的BGM 不同时 { if (nowDialogueData.Bgm == null) //如果数据为空 { FindChild.FindTheChild(CanvasGameObject, "BGM").GetComponent <AudioSource>().clip = null; //将播放内容换成null } else//如果数据不为空 { FindChild.FindTheChild(CanvasGameObject, "BGM").GetComponent <AudioSource>().clip = Resources.Load("BGM/" + nowDialogueData.Bgm, typeof(AudioClip)) as AudioClip; FindChild.FindTheChild(CanvasGameObject, "BGM").GetComponent <AudioSource>().Play(); } //播放内容 } } //完成了BGM播放,如果要播放的bgm与上一句相同,则不作任何 改变
private void RotateRole2() { Quaternion rotationRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localRotation; switch (nowDialogueData.ImageState2[0]) { case 0: rotationRole2.y = 0; break; case 1: rotationRole2.y = 180; break; } FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localRotation = rotationRole2; }
public void CheckItemLiftable() { SpriteRenderer itemImg = FindChild.FindTheChild(gameObject, "PropIMG").GetComponent <SpriteRenderer>(); if (BackpackData.nowItemID == 0 || FarmDataManager._Instance.dataManager.GetPropsItemByID(BackpackData.nowItemID).isLiftable == 0) { itemImg.sprite = null; animator.SetInteger("LiftableEnum", (int)PlayerAnimEnum.Liftable.disable); //不可举起 } else if (FarmDataManager._Instance.dataManager.GetPropsItemByID(BackpackData.nowItemID).isLiftable == 1) { Sprite temp = Resources.Load("UI/ItemIMG/" + FarmDataManager._Instance.dataManager.GetPropsItemByID(BackpackData.nowItemID).img, typeof(Sprite)) as Sprite; itemImg.sprite = temp; animator.SetInteger("LiftableEnum", (int)PlayerAnimEnum.Liftable.enable); //可举起 } }
// Start is called before the first frame update void Start() { mapObject = FindChild.FindTheChild(mainControler, "Map"); mapLengthX = mapObject.transform.localScale.x * mapObject.GetComponent <SpriteRenderer>().sprite.bounds.size.x; mapLengthY = mapObject.transform.localScale.y * mapObject.GetComponent <SpriteRenderer>().sprite.bounds.size.y; cellLengthX = 0.2f; cellLengthY = 0.2f; cellNumX = mapLengthX / cellLengthX; cellNumY = mapLengthY / cellLengthY; for (int y = 0; y < cellNumY; y++) { for (int x = 0; x < cellNumX; x++) { GameObject nowPrafab = Instantiate(CellPrefab, new Vector3(x * cellLengthX + mapLengthX / 2 * -1 + cellLengthX / 2, mapLengthY / 2 - cellLengthY / 2 - y * cellLengthY, 0), Quaternion.identity, CellFolder); nowPrafab.name = x.ToString() + "," + y.ToString(); } } }
private void LoadBG() { if (nowDialogueID == originalDialogueID) { FindChild.FindTheChild(CanvasGameObject, "BG").GetComponent <RawImage>().texture = Resources.Load("BG/" + nowDialogueData.backGround, typeof(Texture)) as Texture; } else if (nowDialogueData.backGround != LastDialogueData.backGround) { Sequence mySequence = DOTween.Sequence(); mySequence.AppendCallback(() => { FindChild.FindTheChild(CanvasGameObject, "BGAnimate").GetComponent <RawImage>().texture = Resources.Load("BG/" + nowDialogueData.backGround, typeof(Texture)) as Texture; }); mySequence.Append(FindChild.FindTheChild(CanvasGameObject, "BGAnimate").GetComponent <RawImage>().DOColor(new Color(255, 255, 255, 1), 0.5f)); mySequence.AppendCallback(() => { FindChild.FindTheChild(CanvasGameObject, "BG").GetComponent <RawImage>().texture = Resources.Load("BG/" + nowDialogueData.backGround, typeof(Texture)) as Texture; }); mySequence.Append(FindChild.FindTheChild(CanvasGameObject, "BGAnimate").GetComponent <RawImage>().DOColor(new Color(255, 255, 255, 0), 0.5f)); //bgAnimate变成新图、渐变显示,显示完成后bg换成新图,bganime变成透明 } }
private void Awake() { buildableSprite = Resources.Load("Map/Buildings/Buildable", typeof(Sprite)) as Sprite; //刷新图片 unbuildableSprite = Resources.Load("Map/Buildings/Unbuildable", typeof(Sprite)) as Sprite; //刷新图片 inBuildMode = true; _Instance = this; arableCheckLayer = FindChild.FindTheChild(GameObject.Find("Map"), "ArableCheckLayer"); plowLayer = FindChild.FindTheChild(GameObject.Find("Map"), "PlowLayer"); wateringLayer = FindChild.FindTheChild(GameObject.Find("Map"), "WateringLayer"); cropsLayer = FindChild.FindTheChild(GameObject.Find("Map"), "CropsLayer"); BuildableCheckLayer = FindChild.FindTheChild(GameObject.Find("Map"), "BuildableCheckLayer"); arableTM = arableCheckLayer.GetComponent <Tilemap>(); plowTM = plowLayer.GetComponent <Tilemap>(); waterTM = wateringLayer.GetComponent <Tilemap>(); cropsTM = cropsLayer.GetComponent <Tilemap>(); BuildableTM = BuildableCheckLayer.GetComponent <Tilemap>(); }
/// <summary> /// 更新快捷背包界面的UI /// </summary> public void RefreshItemUI() { for (int i = 0; i < FarmDataManager._Instance.mainData.itemListArr.GetLength(1); i++) { if (i < itemImgArr.Count) { Image img = itemImgArr[i].GetComponent <Image>(); if (FarmDataManager._Instance.mainData.itemListArr[BackpackData.nowBackpackPage, i].ID != 0) { img.sprite = Resources.Load("UI/ItemIMG/" + FarmDataManager._Instance.dataManager.GetPropsItemByID( FarmDataManager._Instance.mainData.itemListArr[ BackpackData.nowBackpackPage, i].ID) .img, typeof(Sprite)) as Sprite; //刷新图片 FindChild.FindTheChild(itemImgArr[i], ("Text")).GetComponent <Text>().text = FarmDataManager._Instance.mainData.itemListArr[BackpackData.nowBackpackPage, i].Num .ToString(); //刷新数量 } else if (i < itemImgArr.Count) { img.sprite = null; FindChild.FindTheChild(itemImgArr[i], ("Text")).GetComponent <Text>().text = "0"; } if (i == BackpackData.nowBackpackIndex) //刷新选中框 { FindChild.FindTheChild(itemImgArr[i], "Choose").SetActive(true); } else if (i < itemImgArr.Count) { FindChild.FindTheChild(itemImgArr[i], "Choose").SetActive(false); } } } }
private void PostionRole2() { Vector3 posRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localPosition; switch (nowDialogueData.ImageState2[1]) { case -3: //左侧画面外 posRole2.x = -750; break; case -2: //左侧靠边 posRole2.x = -365; break; case -1: //左侧中间 posRole2.x = -250; break; case 0: //画面中间 posRole2.x = 0; break; case 1: //右侧中间 posRole2.x = 250; break; case 2: //右侧靠边 posRole2.x = 365; break; case 3: //右侧画面外 posRole2.x = 750; break; } FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localPosition = posRole2; }
public void NextYearButton() { wolfInput = float.Parse(FindChild.FindTheChild(Canvas, "WolfInput").GetComponent <Text>().text); rabbitInput = float.Parse(FindChild.FindTheChild(Canvas, "RabbitInput").GetComponent <Text>().text); grassInput = float.Parse(FindChild.FindTheChild(Canvas, "GrassInput").GetComponent <Text>().text); if ((wolfInput + wolfNum) * wolfRepRate <= (rabbitNum + rabbitInput) / wolfPreyRate) { newWolfNum = (wolfInput + wolfNum) * wolfRepRate; } else { newWolfNum = (rabbitNum + rabbitInput) / wolfPreyRate; } //比较狼*wolfRepRate和兔子除wolfPreyRate哪个小 用哪个 if (newWolfNum < 0) { newWolfNum = 0; } if ((rabbitNum + rabbitInput) * rabbitRepRate <= (grassNum + grassInput) / rabbitPreyRate) { newRabbitNum = (rabbitNum + rabbitInput) * rabbitRepRate; } else { newRabbitNum = (grassNum + grassInput) / rabbitPreyRate; } if ((wolfInput + wolfNum) * wolfPreyRate >= newRabbitNum) { newRabbitNum = newRabbitNum * 0.1f; } else { newRabbitNum = newRabbitNum - (wolfInput + wolfNum) * wolfPreyRate; } if (newRabbitNum < 0) { newRabbitNum = 0; } //比较兔子*rabbitRepRate和草除rabbitPreyRate哪个小 那个小用哪个 再减去原狼*wolfPreyRate如果数值大于现存兔子数换做兔子-90% if ((grassNum + grassInput) * grassRepRate + 2000 >= 30000) { newGrassNum = 30000; } else { newGrassNum = (grassNum + grassInput) * grassRepRate + 2000; } newGrassNum -= newRabbitNum * rabbitPreyRate; if (newGrassNum < 0) { newGrassNum = 0; } //草每年*grassRepRate+2000 不大于30000 再减去兔*rabbitPreyRate rabbitNum = newRabbitNum; wolfNum = newWolfNum; grassNum = newGrassNum; //newWolfNum = (wolfInput + wolfNum) * (rabbitNum + rabbitInput) / 1000f; //newRabbitNum = (rabbitNum + rabbitInput) / ((wolfInput + wolfNum) / 100f) * ((grassNum + grassInput) / 10000f) // newGrassNum = (grassNum + grassInput) / ((rabbitNum + rabbitInput) / 1000f); // if (newWolfNum > (wolfInput + wolfNum) * 2) wolfNum = (wolfInput + wolfNum) * 2; // else wolfNum = newWolfNum; // // if (newRabbitNum > (rabbitNum + rabbitInput) * 5) rabbitNum = (rabbitNum + rabbitInput) * 5; // else rabbitNum = newRabbitNum; // if (newGrassNum > 30000f) grassNum = 30000f; // else if (newGrassNum > (grassNum + grassInput) * 10) newGrassNum = (grassNum + grassInput) * 10; // else grassNum = newGrassNum; FindChild.FindTheChild(Canvas, "WolfNum").GetComponent <Text>().text = wolfNum.ToString(); FindChild.FindTheChild(Canvas, "RabbitNum").GetComponent <Text>().text = rabbitNum.ToString(); FindChild.FindTheChild(Canvas, "GrassNum").GetComponent <Text>().text = grassNum.ToString(); }
private void LoadRole2() { if (nowDialogueID == originalDialogueID) { ChangeRole2Image(); //替换role1的图片 RotateRole2();//完成了role1的是否翻转读表 PostionRole2();//完成了role1的显示位置读表 ScaleRole2(); //完成了role1的缩放 } else if (nowDialogueData.role2ID != LastDialogueData.role2ID) { Sequence mySequence = DOTween.Sequence(); Ease MyEase; MyEase = Ease.Linear; mySequence.SetEase(MyEase); //设置移动类型 Color color = FindChild.FindTheChild(CanvasGameObject, "Role2").GetComponent <RawImage>().color; mySequence.AppendCallback(() => { color.a = 1; }); mySequence.Append(DOTween.ToAlpha(() => color, x => color = x, 0, 0.4f)); mySequence.InsertCallback(0.4f, () => { ChangeRole2Image(); Debug.Log("role2替换图片"); }); mySequence.InsertCallback(0.4f, () => { RotateRole2(); Debug.Log("role2翻转读表"); }); mySequence.InsertCallback(0.4f, () => { PostionRole2(); Debug.Log("role2位置读表"); }); mySequence.InsertCallback(0.4f, () => { ScaleRole2(); Debug.Log("role2的缩放"); }); mySequence.Insert(0.4f, DOTween.ToAlpha(() => color, x => color = x, 1, 0.4f)); mySequence.onUpdate = () => { FindChild.FindTheChild(CanvasGameObject, "Role2").GetComponent <RawImage>().color = color; Debug.Log(color.a); }; mySequence.SetUpdate(true); } else { ChangeRole2Image(); if (nowDialogueData.ImageState2[0] != LastDialogueData.ImageState2[0]) { Vector3 role2Rotate = new Vector3(0, 0, 0); switch (nowDialogueData.ImageState2[0]) { case 0: role2Rotate.y = 0; break; case 1: role2Rotate.y = 180; break; } FindChild.FindTheChild(CanvasGameObject, "Role2").transform.DOLocalRotate(role2Rotate, 0.5f); } if (nowDialogueData.ImageState2[1] != LastDialogueData.ImageState2[1]) { Vector3 posRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localPosition; switch (nowDialogueData.ImageState2[1]) { case -3: //左侧画面外 posRole2.x = -750; break; case -2: //左侧靠边 posRole2.x = -365; break; case -1: //左侧中间 posRole2.x = -250; break; case 0: //画面中间 posRole2.x = 0; break; case 1: //右侧中间 posRole2.x = 250; break; case 2: //右侧靠边 posRole2.x = 365; break; case 3: //右侧画面外 posRole2.x = 750; break; } FindChild.FindTheChild(CanvasGameObject, "Role2").transform.DOLocalMoveX(posRole2.x, 0.5f); } if (nowDialogueData.ImageState2[2] != LastDialogueData.ImageState2[2]) { Vector3 scaleRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2").transform.localScale; scaleRole2.x = (float)nowDialogueData.ImageState2[2] / 100; scaleRole2.y = scaleRole2.x; FindChild.FindTheChild(CanvasGameObject, "Role2").transform.DOScale(scaleRole2, 0.5f); } } }
private void ChangeRole2Image() { GameObject objRole2 = FindChild.FindTheChild(CanvasGameObject, "Role2"); objRole2.GetComponent <RawImage>().texture = Resources.Load("Characters/" + role2Data.image + nowDialogueData.Imageface2, typeof(Texture)) as Texture; }