void SetBlockSpecial(BlockSpecial newSpecial) { if (special != newSpecial) { special = newSpecial; } }
void OnCollisionEnter(Collision collision) { if (collision.transform.tag == "Mine") { Teleport(); } foreach (ContactPoint cp in collision.contacts) { Block block = world.GetBlock((int)cp.point.x, (int)cp.point.y, (int)cp.point.z); if (block is BlockSpecial) { BlockSpecial t = (BlockSpecial)block; if (t.owner == BlockSpecial.Owner.other) { switch (t.type) { case BlockSpecial.Specal_type.Bound: Bound(); break; case BlockSpecial.Specal_type.Suck: sucked = true; sucked_pos = transform.position; break; } } } } }
public void SendSetSpecBlock(WorldPos position, BlockSpecial.Specal_type type){ Dictionary<string,string> data = new Dictionary<string ,string>(); data["id"] = ""+socket.sid; data["p_x"] = ""+position.x; data["p_y"] = ""+position.y; data["p_z"] = ""+position.z; data["type"] = type.ToString(); socket.Emit("set_specblock", new JSONObject(data)); }
public void SpecialBlockEff_mod(WorldPos position, BlockSpecial.Specal_type blocktype, BlockSpecial.Owner owner){ for(int i=0;i<10;i++){ float r_x = Random.Range(-10, 10); float r_y = Random.Range(-10, 10); float r_z = Random.Range(-10, 10); Instantiate(specialDelivery, new Vector3(position.x+r_x,position.y+r_y,position.z+r_z), specialDelivery.transform.rotation); } }
// List<WorldPos> GeneratePillars(WorldPos startpoint,int size){ // int pillar_num = Random.Range (15, 30); // // List<WorldPos> base_position = new List<WorldPos>(); // for (int i=0; i<pillar_num; i++) { // WorldPos w = new WorldPos( // Random.Range(0,size), // (int)Random.Range(0,size*0.7f), // Random.Range(0,size) // ); // w.extra = (int)Random.Range(3,6); // base_position.Add(w); // } // // List<WorldPos> points = new List<WorldPos> (); // // for (int i=0; i<base_position.Count; i++) { // WorldPos base_point = base_position[i]; // // for(int h=0;h<base_point.y;h++){ // for(int x=0;x<base_point.extra;x++) // for(int z=0;z<base_point.extra;z++){ // points.Add( // new WorldPos( // startpoint.x+base_point.x+x, // startpoint.y+h, // startpoint.z+base_point.z+z // ) // ); // } // } // } // // return points; // } public void SpecialBlockEff(WorldPos position, BlockSpecial.Specal_type blocktype, BlockSpecial.Owner owner){ List<WorldPos> points = new List<WorldPos> (); int range = 8; for(int x=-range/2; x<range/2; x++) for(int y=-range/2; y<range/2; y++) for(int z=-range/2; z<range/2; z++){ if(!(GetBlock(position.x+x, position.y+y, position.z+z) is BlockAir)) points.Add( new WorldPos( position.x+x, position.y+y, position.z+z ) ); } SetSpecalBlockS(points, blocktype, owner); }
public void SetSpecalBlockS(List<WorldPos> coordList, BlockSpecial.Specal_type btype, BlockSpecial.Owner owner){ for(int i=0;i<coordList.Count;i++){ System.Random r = new System.Random(); Color c = new Color((float)r.NextDouble(),(float)r.NextDouble(),(float)r.NextDouble()); // BlockSpecial a=new BlockSpecial(btype); SetBlock( coordList[i].x, coordList[i].y, coordList[i].z, new BlockSpecial(btype, owner)); } }
public void ChangeBlock(int newX, int newY, BlockColor newColor = BlockColor.None, BlockState newState = BlockState.None, BlockSpecial newSpecial = BlockSpecial.None) { //PrintBlock("ChangeBlock", " (" + x + "/" + newX + "," + y + "/" + newY + ") State: " + state + "/" + newState); if (state == BlockState.Held) //Update held blocks { SetBlockXY(newX, newY); fxControllerScript.SendMessage("BlockSwap"); //Dont change state } else if (state == BlockState.Moving) //Update moving blocks { transform.Translate(Vector3.MoveTowards(transform.position, fieldScript.GetBlockPositionForFieldXY(newX, newY), 6f) - transform.position); SetBlockXY(newX, newY); StopBlock(); } else if (state == BlockState.Match) { transform.Translate(Vector3.MoveTowards(transform.position, fieldScript.GetBlockPositionForFieldXY(newX, newY), 6f) - transform.position); SetBlockXY(newX, newY); } else if (state == BlockState.Swap) //Move swapped blocks, check for matches then set them back { SetBlockXY(newX, newY); transform.Translate(Vector3.MoveTowards(transform.position, fieldScript.GetBlockPositionForFieldXY(newX, newY), 6f) - transform.position); fieldScript.CheckForMatchesAtBlock(this); //PrintBlock("ChangeBlock:Swap"); StopBlock(); } else if (newState == BlockState.New) //set new blocks { SetBlockXY(newX, newY); SetBlockColor(newColor); StopBlock(); } }
void CreateBlock(GameObject blockPrefab, int newX, int newY, BlockState newState = BlockState.New, BlockSpecial newSpecial = BlockSpecial.None) { GameObject block = Instantiate(blockPrefab, GetBlockPositionForFieldXY(newX, newY), Quaternion.identity) as GameObject; block.transform.parent = this.transform; BlockScript blockScript = block.GetComponent <MonoBehaviour>() as BlockScript; blockScript.ChangeBlock(newX, newY, BlockColor.None, newState, newSpecial); AddBlockToFieldBlocks(blockScript); blockScript.fieldScript = this; //print("New Block: " + blockScript + ", " + blockScript.x + ", " + blockScript.y + " State: " + blockScript.state); }
public void GetAitem(BlockSpecial.Specal_type type){ switch(type){ case BlockSpecial.Specal_type.Bound: Bump_item++; break; case BlockSpecial.Specal_type.Suck: Suck_item++; break; case BlockSpecial.Specal_type.Teleport: Teleport_item++; break; } }