protected override void Skill() { base.Skill(); CloudOptManager.GetInstance().OpenNormal_1_1(); //CloudOptManager.GetInstance().optionList.Add(CloudOptManager.GetInstance().specialOptions[Global.CloudType.NORMAL_1_1]); }
public static void RemoveAndNotify(this List <CloudProperty> options, CloudProperty cloud) { if (cloud == null) { Debug.Log("cloudProperty in <CloudOptManager>.RemoveAndNotify is NULL"); return; } // index = options.FindIndex((CloudProperty s) => s == cloud); options.Remove(cloud); CloudOptManager.optionChangeHandle(); }
/// <summary> /// 扩展方法:自定义的List的Add和Remove /// </summary> /// <param name="cl">表示调用这个方法的类型是List<CloudProperty></param> /// <param name="cloud">真正的参数,要添加到list中的item</param> public static void AddAndNotify(this List <CloudProperty> options, CloudProperty cloud) { options.Add(cloud); //CloudOptManager.optionChangeHandle.Method; if (CloudOptManager.optionChangeHandle == null) { Debug.Log("CloudOptManager.optionChangeHandle in <CloudOptManager> is NULL"); return; } CloudOptManager.optionChangeHandle(); }
// Use this for initialization void Start() { cloudOptionList = CloudOptManager.GetInstance().optionList; plantOptionList = PlantOptManager.GetInstance().optionList; //cloudOptImageList = new List<RawImage>(); //plantOptImageList = new List<RawImage>(); EnableSubscribe(); SetSteps(); UpdateCloudOption(); StartCoroutine("InitialSunshine"); }
protected override void InitSeletedItem() { int index = HUDManager.GetInstance().cloudOptImageList.FindIndex((RawImage s) => s == image); if (index < 0) { Debug.Log("cloudProperty in <Option> is NULL"); } cloudProperty = CloudOptManager.GetInstance().optionList[index]; //imgReduceScale = (256f/imgRect.rect.width); //imgNormalScale = (256f/imgRect.rect.width); imageOffset = new Vector2(-image.rectTransform.rect.width * 0.5f * image.rectTransform.localScale.x, image.rectTransform.rect.height * 0.5f * image.rectTransform.localScale.y); }
//CloudOption是重复使用的,每次调用只是设置是否可见,放回正确位置 private void UpdateCloudOption() { int count = cloudOptionList.Count > CloudOptManager.GetInstance().maxNum? CloudOptManager.GetInstance().maxNum: cloudOptionList.Count; for (int i = 0; i < count; i++) { cloudOptImageList[i].gameObject.SetActive(true); cloudOptImageList[i].texture = cloudOptionList[i].texture; cloudOptImageList[i].transform.localScale = new Vector3(cloudOptionList[i].width / 2f, (float)cloudOptionList[i].height / 2f, 1); cloudOptImageList[i].GetComponent <CloudOption>().imgNormalScale = cloudOptImageList[i].transform.localScale; cloudOptImageList[i].GetComponent <CloudOption>().imgReduceScale = cloudOptImageList[i].transform.localScale * 1.2f; cloudOptImageList[i].transform.localPosition = new Vector3(optWidthOffset * (i - 1), optHeightPos, 0); } for (int i = count; i < CloudOptManager.GetInstance().maxNum; i++) { cloudOptImageList[i].gameObject.SetActive(false); } }
protected override void Skill() { base.Skill(); CloudOptManager.GetInstance().optionList.AddAndNotify(CloudOptManager.GetInstance().specialOptions[Global.CloudType.SPECIAL_3_3]); }
private void EndDrag(CloudProperty c, Vector2 leftTop) { //消除提示 hoveringGrids.ClearHintState(); Ground.GetInstance().ClearHintState(); bool destroyOption = false; RaycastHit hit; Vector2Int pos = new Vector2Int(); int left = 0;//图片对应的最左和最右格子,用于传递给TemplateMatch(),减小遍历面积 int right = 0; int top = 0; int bottom = 0; Ray ray = Camera.main.ScreenPointToRay(leftTop); if (Physics.Raycast(ray, out hit, 100.0f, LayerMask.GetMask("Sky"))) { // 打印射线检测到的物体的名称 //Debug.Log("射线检测到的物体名称: " + hit.transform.name); pos = hit.transform.GetComponent <SkyGrid>().position;//图片左上角碰撞到的格子的坐标 left = pos.x; right = pos.x + c.width - 1; top = pos.y; bottom = pos.y - c.height + 1; //判断选项是否被完全包含在天空里 //既然左上角碰撞到了就只需检查右界、下界 if (pos.x + c.width > wNum || pos.y - c.height + 1 < 0) { destroyOption = false; } else { destroyOption = true; for (int i = 0; i < c.width; i++) { for (int j = 0; j < c.height; j++)//注意pos.y是上大下小 { if (c.data[i, j] == 1) { if (grids[pos.x + i, pos.y - j].State == 1) { destroyOption = false; break; } } } if (destroyOption == false) { break; } } } } if (destroyOption) { c.EnableSubscribe(); //拖动成功,消除原来的选项 CloudOptManager.GetInstance().RemoveOption(c); if (UseSkill == null) { //Normal skill for (int i = 0; i < c.width; i++) { for (int j = 0; j < c.height; j++)//注意pos.y是上大下小 { if (c.data[i, j] == 1) { grids[pos.x + i, pos.y - j].State = 1; } } } TemplateMatch(left, right, top, bottom); } else { //Special skill UseSkill(pos.x, pos.y); } c.DisableSubscribe(); } else { //如果没拖到云彩上,要把选项放回到原来的位置 CloudOptManager.GetInstance().PutBackOption(c); } }
private void Awake() { instance = this; }