//se fija si a la izquierda hay un plataforma y si hay depende del tamaño de la platafoma si este bloque es bloque plataforma o no public void CheckPlatform(int i, int j, BaseCube block, List <List <BaseCube> > matrizCubes) { if (matrizCubes[i - 1][j].space > 0) { block.space = matrizCubes[i - 1][j].space - 1; return; } if (matrizCubes[i - 1][j].exists) { if (matrizCubes[i - 1][j].tamaño > 0 && !matrizCubes[i - 1][j - 1].exists && !matrizCubes[i - 1][j - 2].exists && !matrizCubes[i][j - 1].exists && !matrizCubes[i][j - 2].exists && !matrizCubes[i - 2][j - 2].exists && !matrizCubes[i - 3][j - 2].exists) { block.tamaño = matrizCubes[i - 1][j].tamaño - 1; if (block.tamaño == 0) { block.space = Modifiers.platformSpaceSize; } block.exists = true; block.GetComponent <MeshRenderer>().material.color = Color.blue; var spikeChance = Random.Range(0, 100);//random para determinar si tiiene pinches if (spikeChance < Modifiers.spikeChance && !matrizCubes[i - 1][j].spike /*&& block.tamaño!= 0*/) { block.Spike(); } else { var coinChance = Random.Range(0, 100);//random para determinar si tiiene pinches if (coinChance < Modifiers.spikeChance) { block.Coin(); } } return; } } var platformChance = Random.Range(0, 100);//random para determinar si es plataforma if (platformChance < Modifiers.platformBlockChance) { if (!matrizCubes[i - 1][j - 1].exists && !matrizCubes[i - 1][j - 2].exists && !matrizCubes[i][j - 1].exists && !matrizCubes[i][j - 2].exists && !matrizCubes[i - 2][j - 2].exists && !matrizCubes[i - 3][j - 2].exists) { block.tamaño = Random.Range(1, Modifiers.platfomrSize); block.exists = true; block.GetComponent <MeshRenderer>().material.color = Color.blue; return; } } }
public BaseCube CreateDeliveryCube(string address) { Cube addressedCube = _cubeRepository.GetCube(address); if (addressedCube == null) { Logger.LogError("Not found cube addressed: " + address); } var cubeType = GetType().Assembly.GetTypes() .FirstOrDefault(x => x.Name.Contains(addressedCube.CubeType)); Object[] args = { addressedCube, _cubeRepository, this }; BaseCube cube = (BaseCube)Activator.CreateInstance(cubeType, args); return(cube); }
public void ViewCube(int bt) { // 获取索引 GameObject Img_Lift = gameObject.transform.Find("CubeViewPanel/Img_Lift").gameObject; GameObject Text_CubeName = gameObject.transform.Find("CubeViewPanel/Text_CubeName").gameObject; GameObject Text_CubeName_Shadow = gameObject.transform.Find("CubeViewPanel/Text_CubeName_Shadow").gameObject; GameObject Text_Describe = gameObject.transform.Find("CubeViewPanel/Text_Describe").gameObject; GameObject Text_Tag = gameObject.transform.Find("CubeViewPanel/Text_Tag").gameObject; // 清空上次 for (int i = 0; i < cubeItemList.Count; i++) { Imagecolor = new Color(255, 255, 255, 255); cubeItemList[i].transform.Find("Img_shadow").gameObject.GetComponent <Image>().color = Imagecolor; Text_Describe.GetComponent <Text>().text = " ???"; Text_Tag.GetComponent <Text>().text = "???"; } BaseCube cube = Consts.cubeList[bt]; // 点击后小图无效果 或者 none无,name有,shadow无,role有 // 点击后大图效果:if已有图鉴 Img_Lift.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Texture/CubeList")[Consts.cubeList[bt].CubeId]; Img_Lift.GetComponent <Image>().SetNativeSize(); Img_Lift.GetComponent <Image>().color = Color.black; Text_CubeName.GetComponent <Text>().text = "" + cubeItemList[bt].transform.Find("Text_name").gameObject.GetComponent <Text>().text; Text_CubeName_Shadow.GetComponent <Text>().text = "" + cubeItemList[bt].transform.Find("Text_name").gameObject.GetComponent <Text>().text; if (Consts.cubeList[bt].isFirst == true) { Imagecolor.a = 0; cubeItemList[bt].transform.Find("Img_shadow").gameObject.GetComponent <Image>().color = Imagecolor; Debug.Log("如果当前图鉴已存在,图片显示,颜色正常,文字正常"); Img_Lift.GetComponent <Image>().color = Color.white; Text_Describe.GetComponent <Text>().text = " " + cube.Describe; Text_Tag.GetComponent <Text>().text = "" + cube.Tag; Img_Lift.GetComponent <Image>().color = Color.white; } }
/// <summary> /// 每次吃方块调用 /// </summary> /// <param name="bt">方块类型</param> void EatBlockHander(BlockType bt) { int index = (int)bt - 1; Debug.Log("当前吃到的方块类型" + bt); if (Consts.cubeList[index].isFirst == false) { // PauseOrContinue(true); GameObject Img_Tip1 = maskLayerCubeFirst.transform.Find("Img_Tip1").gameObject; GameObject Img_Lift = cubeViewPanel.transform.Find("Img_Lift").gameObject; GameObject Text_CubeName = cubeViewPanel.transform.Find("Text_CubeName").gameObject; GameObject Text_CubeName_Shadow = cubeViewPanel.transform.Find("Text_CubeName_Shadow").gameObject; GameObject Text_Describe = cubeViewPanel.transform.Find("Text_Describe").gameObject; GameObject Text_Tag = cubeViewPanel.transform.Find("Text_Tag").gameObject; BaseCube cube = Consts.cubeList[index]; // 展示panel,文字、文字阴影、描述、类型、图片 maskLayerCubeFirst.gameObject.SetActive(true); Text_CubeName.GetComponent <Text>().text = cube.CubeName + ""; Text_CubeName_Shadow.GetComponent <Text>().text = cube.CubeName + ""; Text_Describe.GetComponent <Text>().text = " " + cube.Describe; Text_Tag.GetComponent <Text>().text = cube.Tag + ""; Img_Lift.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Texture/CubeList")[Consts.cubeList[index].CubeId]; Img_Lift.GetComponent <Image>().SetNativeSize(); GameObject g = IllustrationSystem.GetComponent <Illustration>().cubeItemList[index]; Debug.Log("初始化图鉴小图"); g.transform.Find("Text_name").gameObject.GetComponent <Text>().text = Consts.cubeList[index].CubeName; Color Imagecolor = new Color(); Imagecolor.a = 0; g.transform.Find("Img_none").gameObject.GetComponent <Image>().color = Imagecolor; g.transform.Find("Img_role").gameObject.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Texture/CubeList")[Consts.cubeList[index].CubeId]; g.transform.Find("Img_role").gameObject.GetComponent <Image>().SetNativeSize(); g.transform.Find("Img_role").gameObject.GetComponent <Image>().color = Color.white; Consts.cubeList[index].isFirst = true; } }
public void CreateFloor(int i, BaseCube block, List <List <BaseCube> > matrizCubes) { var gap = Random.Range(0, 100);// random para determinar si hay piso o no if (gap < Modifiers.floorGapChance) { block.exists = false; //fuerza a un piso si el hueco es muy grande bool ex = false; for (int j = 0; j < Modifiers.maxFloorGapSize; j++) { if (i - j < 0) { break; } if (!matrizCubes[i - j][0].exists) { ex = true; } else { ex = false; break; } } block.exists = ex; } else { block.exists = true; var spikeChance = Random.Range(0, 100);//random para determinar si tiiene pinches if (spikeChance < Modifiers.spikeChance && matrizCubes[i - 1][0].exists) { block.Spike(); } } }
void Awake() { by = this; }
public void CreatPlatform(int i, int j, BaseCube block, List <List <BaseCube> > matrizCubes) { CheckPlatform(i, j, block, matrizCubes); }