// 对四个方向的相邻方块进行射线检测 bool NextAreaDetect(Vector3 point) { Vector3[] vectors = { Vector2.up, Vector2.down, Vector2.left, Vector2.right }; for (int i = 0; i < 4; i++) { RaycastHit hit; Physics.Raycast(point, vectors[i], out hit, gameObject.GetComponentInChildren <BoxCollider>().size.x, blockLayerMask); if (hit.collider != null) { blockType hitBlockType = hit.collider.gameObject.GetComponentInParent <blockController>().type; if (this.type < blockType.elephant) { if (this.type == hitBlockType - 1) { return(true); } } else { if (hitBlockType == blockType.mouse) { return(true); } } } } return(false); }
//////////////////////////////////// //randomly selecting a blockType public blockType RandomBlockType() { var random = new Random(); blockType kind = (blockType)random.Next(3); return(kind); }
public TextShow(Vector2 location, blockType type,bool canBeDraged, bool can_spawn) : base(location, (int)Game.fonts["font32"].MeasureString(BlockData.getName(type)).X + 8 + 4 + 4, (int)Game.fonts["font32"].MeasureString(BlockData.getName(type)).Y + 8 + 4 + 4) { can_spawn = true; this.canBeDraged = canBeDraged; this.can_spawn = can_spawn; this.type = type; blockData = new BlockData(type); border_widths = new int[] { 4, 4, 4, 4 }; font = "font32"; inside_color = Color.Yellow; border_colors = blockData.borderColours; text_color = blockData.textColour; text = blockData.name; sprite_height = (int)Game.fonts["font16"].MeasureString(text).Y+ border_widths[1]+ border_widths[3]; sprite_length = (int)Game.fonts["font16"].MeasureString(text).X +border_widths[0]+ border_widths[2]; data = new Color[width * height]; data_to_convert = new Color[width, height]; generateTextureComplex(new int[4] { 4, 4, 4, 4 }, border_colors, inside_color); }
public string text; // przechowuje tekst etykiety bloku /// <summary> /// Konstruktor /// </summary> /// <param name="x">współrzędna X lewego górnego narożnika bloku</param> /// <param name="y">współrzędna Y lewego górnego narożnika bloku</param> /// <param name="height">wysokość bloku</param> /// <param name="width">szerokość bloku</param> /// <param name="text">treść etykiety bloku</param> /// <param name="type">typ bloku</param> public Block(int x, int y, int height, int width, string text, blockType type) { this.x = x; this.y = y; this.height = height; this.width = width; this.rec = new Rectangle(x, y, width, height); this.type = type; switch (type) { case blockType.protocol: this.text = "Protokół: \n" + text; this.brush = Configuration.protocolBr; break; case blockType.segment: this.text = "Segment: \n" + text; this.brush = Configuration.segmentBr; break; case blockType.channel: this.text = text; this.brush = Configuration.channelBr; break; } }
public static string getName(blockType type) { BlockData t = new BlockData(type); return t.name; }
//Changes block type whether its a normal block or reverse block public static void ChangeBlockType(ref blockType type, List <SpriteRenderer> blockSprites /*,SpriteRenderer blockSprite ,SpriteRenderer childBlockSprite*/) { if (type == blockType.normal) { type = blockType.reverse; foreach (SpriteRenderer sp in blockSprites) { sp.sprite = reverseBlock; sp.color = reverseColor; } /* blockSprite.sprite = reverseBlock; * blockSprite.color = reverseColor; * * childBlockSprite.sprite = reverseBlock; * childBlockSprite.color = reverseColor; */ } else { type = blockType.normal; foreach (SpriteRenderer sp in blockSprites) { sp.sprite = normalBlock; sp.color = normalColor; } /* blockSprite.sprite = normalBlock; * blockSprite.color = normalColor; * * childBlockSprite.sprite = normalBlock; * childBlockSprite.color = normalColor; */ } }
public List<Core.Model.Block> getBlocks(blockType type, blockWhat what) { int block_type = (int)type; int block_what = (int)what; List<block> blocks = (from m in db_mysql.blocks where m.Type == block_type && m.What == block_what select m).ToList(); return Mapper.Map<List<block>, List<Block>>(blocks); }
public gBlockStruct(byte iType, byte data) { if (Enum.IsDefined(typeof(blockType), iType)) { blockType b = (blockType)Enum.Parse(typeof(blockType), iType.ToString()); gBlockStruct(b, data); } else gBlockStruct(blockType.Undefined, data); }
public Bitmap pic; // obrazek ikonki /// <summary> /// Konstruktor /// </summary> /// <param name="x">współrzędna X lewego górnego narożnika bloku</param> /// <param name="y">współrzędna Y lewego górnego narożnika bloku</param> /// <param name="height">wysokość bloku</param> /// <param name="width">szerokość bloku</param> /// <param name="pic">treść etykiety bloku</param> /// <param name="type">typ bloku</param> public Icon(int x, int y, int height, int width, Bitmap pic, blockType type) { this.x = x; this.y = y; this.height = height; this.width = width; this.rec = new Rectangle(x, y, width, height); this.type = type; this.pic = pic; }
/*// 합수 */ // ////[임시]생성자 (Needs Color Elements) public TetrisGrid(int gridHeight, int gridLength, blockType blockType, int pivotX, int pivotY, int turnState) { this.gridHeight = gridHeight; this.gridLength = gridLength; this.grid = new int[gridHeight, gridLength]; this._blockType = blockType; this._pivotX = pivotX; this._pivotY = pivotY; this._blockTurnState = turnState; }
////복사생성자 public TetrisGrid(TetrisGrid T) { this.gridHeight = T.gridHeight; this.gridLength = T.gridLength; //배열 복사할때는 Clone() 사용 this.grid = (int[,])T.grid.Clone(); this._blockType = T._blockType; this._pivotX = T._pivotX; this._pivotY = T._pivotY; this._blockTurnState = T._blockTurnState; this._color = T._color; this._validCheck = T._validCheck; }
///////////////////////////////////// //sets certain blockTypes to their specific bitmap public Bitmap blockBitmap(blockType kind) { //kind value; switch (kind) { case blockType.soft: return(SwinGame.BitmapNamed("soft")); case blockType.hard: return(SwinGame.BitmapNamed("hard")); case blockType.items: return(SwinGame.BitmapNamed("item")); default: return(null); } }
void RandomizeSprite() { int randomNumber = Random.Range(0, 8); switch (randomNumber) { case 0: currentType = blockType.Antler; GetComponent <SpriteRenderer>().sprite = antler; break; case 1: currentType = blockType.Arrow; GetComponent <SpriteRenderer>().sprite = arrow; break; case 2: currentType = blockType.Candle; GetComponent <SpriteRenderer>().sprite = candle; break; case 3: currentType = blockType.Grave; GetComponent <SpriteRenderer>().sprite = grave; break; case 4: currentType = blockType.Jelly; GetComponent <SpriteRenderer>().sprite = jelly; break; case 5: currentType = blockType.Scarecrow; GetComponent <SpriteRenderer>().sprite = scarecrow; break; case 6: currentType = blockType.Swim; GetComponent <SpriteRenderer>().sprite = swim; break; case 7: currentType = blockType.Totem; GetComponent <SpriteRenderer>().sprite = totem; break; } }
// This way we can fine the exact block and will image it, if its out of range it will display the 255 block // if it is in range but no defiend it wil display the block with the block number public gBlockTypeStruct getSet(int iType) { if (Enum.IsDefined(typeof(blockType), (byte)iType)) { blockType cBlockType = (blockType)Enum.Parse(typeof(blockType), iType.ToString()); return(getSet(cBlockType)); } else if (iType >= 0 && iType < blockMax) { return(new gBlockTypeStruct(blockType.Undefined, textures[iType])); } else { return(new gBlockTypeStruct(blockType.Undefined, textures[blockMax - 1])); } }
//生成方块组合,//默认第一个为组合的中心点 public List <GameObject> SpawnBlockCombo() { blockType ty = (blockType)UnityEngine.Random.Range(0, Enum.GetValues(typeof(blockType)).Length); switch (ty) { case blockType.Z: currentCombo = SpawnZ(); break; case blockType.I: currentCombo = SpawnI(); break; case blockType.T: currentCombo = SpawnT(); break; case blockType.L: currentCombo = SpawnL(); break; case blockType.O: currentCombo = SpawnO(); break; } // float angle=UnityEngine.Random.Range(0,angles.Length); // RotateBlock(currentCombo[0].transform,currentCombo,angle); int isOverTurn = UnityEngine.Random.Range(0, 100); if (isOverTurn > 50) { OverTure(currentCombo[0].transform, currentCombo); } Color[] colors = GameConfig.Colors[UnityEngine.Random.Range(0, GameConfig.Colors.Length)]; foreach (GameObject obj in currentCombo) { obj.GetComponent <Image>().color = colors[0]; obj.transform.GetChild(0).GetComponent <Image>().color = colors[1]; } return(currentCombo); }
public gBlockTypeStruct(blockType iType, int[] tiles, int x, int y, int z) { bType = iType; bmp = tiles; X = x; Y = y; Z = z; }
public void spawnBlock(laneNumber blockLane, blockType type) { Vector3 toPlaceAt; GameObject newBlock; Material blockColor; if (type == blockType.note) { newBlock = Instantiate(blockPrototype); } else { newBlock = Instantiate(sustainPrototype); } switch (blockLane) { case laneNumber.lane1: { toPlaceAt = lane1Start; blockColor = lane1; break; } case laneNumber.lane2: { toPlaceAt = lane2Start; blockColor = lane2; break; } case laneNumber.lane3: { toPlaceAt = lane3Start; blockColor = lane3; break; } case laneNumber.lane4: { toPlaceAt = lane4Start; blockColor = lane4; break; } case laneNumber.lane5: { toPlaceAt = lane5Start; blockColor = lane5; break; } default: { toPlaceAt = Vector3.zero; blockColor = lane1; break; } } newBlock.transform.position = toPlaceAt; newBlock.GetComponent <Renderer>().material = blockColor; }
void SetNamePrefix(blockType block){ // as at least some kind of visual aid, // Maintain "IF", "ENDIF", "ELSE" or "END" as prefix of lines with block controls set for readability if (name[0]!='?' && type != actionType.ifThenElse && block == blockType.none) return; // otherwise, strip off prefixes and set any appropriate ones if (type == actionType.ifThenElse && !name.Contains ("?IF")){ StripPrefix (); name = "?IF"+name; return; } if (block == blockType.beginElse && !name.Contains ("?ELSE")){ StripPrefix (); name = "?ELSE"+name; return; } if (block == blockType.endIfThenElse && !name.Contains ("?END")){ StripPrefix (); name = "?END"+name; return; } //if the block type is other than if (name[0]=='?' && type != actionType.ifThenElse && block == blockType.none) StripPrefix (); }
public Marker(ILInstruction initialInline, int targetOffset, blockType kind) : base(initialInline.Offset) { this.Inline = initialInline; this.TargetOffset = targetOffset; this.Kind = kind; }
public void InitFrom(ScriptedActionInfo info){ // initialize members from deserialized info gameObject.name = info.unityObjectName; comment = info.comment; objectName = info.objectName; type = info.type; role = info.role; // in a multi-role script, which role performs this action stringParam = info.stringParam; // used for a lot of different things //info.audioClipName = sa.audioClipName; fadeLength = info.fadeLength; // also used for wait, move desiredAlpha = info.desiredAlpha; desiredColor = info.desiredColor; // public Texture2Dname texture2D = null; // used for enableInteraction; // public Transform moveTo; moveToName = info.moveToName; offset = info.offset; // offset from transform for move, in transform's reference frame orientation = info.orientation; // if (info.scriptToExecuteName != null && info.scriptToExecuteName){ // this probably need a redesign, where the search occurs at Start() time, since the script // info.scriptToExecuteName = scriptToExecute.name; // } ease = info.ease; negate = info.negate; // use to turn enable to disable, stop audio, etc. loop = info.loop; waitForCompletion = info.waitForCompletion; // signal complete after audio, fade, etc. sequenceEnd = info.sequenceEnd; executeOnlyOnce = info.executeOnlyOnce; block = info.block; dialogIfThen = info.dialogIfThen; breakpoint = info.breakpoint; preAttributes = info.preAttributes; // processed when the line is begun postAttributes = info.postAttributes; // processed when the line completes stringParam2 = info.stringParam2; stringParam3 = info.stringParam3; stringParam4 = info.stringParam4; attachmentOverride = info.attachmentOverride; eventScript = info.eventScript; voiceTag = info.voiceTag; heading = info.heading; speed = info.speed; if (info.gameMsgFormInfo != null){ gameMsgForm = gameObject.AddComponent<GameMsgForm>(); gameMsgForm.InitFrom(info.gameMsgFormInfo); // info.gameMsg = sa.gameMsgForm.ToGameMsg(this); // how to handle message subclasses ? if (info.map != null){ gameMsgForm.map = gameObject.AddComponent<InteractionMapForm>(); gameMsgForm.map.InitFromMap(info.map); } } syncToTasksIndex = info.syncToTasksIndex; if (syncToTasksIndex != null) syncToTasks = new ScriptedAction[syncToTasksIndex.Length]; // will init when script is fully loaded. else syncToTasks = new ScriptedAction[0]; }
void makeImages() { // First release all memory used by img. RecreateImg(); //Create graphics contucts and other values Bitmap tmpBmp = new Bitmap(tileWidth, tileHeight, PixelFormat.Format32bppArgb); RectangleF centerCircle = new RectangleF( (tileWidth / 2) - (tileWidth / 4), (tileHeight / 2) - (tileHeight / 4), (tileWidth / 4) * 2, (tileHeight / 4) * 2); RectangleF centerLine = new RectangleF( (tileWidth / 2) - (tileWidth / 8), (tileHeight / 2) - (tileHeight / 8), (tileWidth / 8) * 2, tileHeight); Bitmap t; Bitmap[] nb = null; Graphics g; // Yea yea, using a temp var as global. byte me. // Sigh, so is it better to pass Graphics and Bitmap to functions // or just make a global scope for it? meh. Only running all of these // once g = Graphics.FromImage(tmpBmp); g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; // Lets make the nice Yellow Block and lets fill all the blocks with it in the first space. // I am assuming that all the blocks put out by MCsim is all dirt blocks unless specified. // Otherwise, its going to be annoying to illerate though all of them, next version:P g.FillRectangle(Brushes.Yellow, 0, 0, tmpBmp.Width, tmpBmp.Width); for (int idx = 0; idx < blockMax; idx++) { if (Enum.IsDefined(typeof(blockType), (byte)idx)) { blockType cBlockType = (blockType)Enum.Parse(typeof(blockType), idx.ToString()); switch (cBlockType) { case blockType.StoneButton: nb = new Bitmap[4]; //North,West,South,East for (int i = 0; i < 4; i++) { g.Clear(Color.White); g.FillRectangle(Brushes.Gray, 4, 14, 14, 19); g.RotateTransform(i * 90); nb[i] = new Bitmap(tmpBmp); } //Why the hell did notch do it like this? //South,North,West,East t = nb[0]; nb[0] = nb[2]; nb[2] = nb[1]; nb[1] = t; img[idx] = nb; break; case blockType.RedstoneTorchOn: //North,East,South,West nb = new Bitmap[5]; g.Clear(Color.White); g.FillRectangle(Brushes.Gray, centerLine); g.FillEllipse(Brushes.Red, centerCircle); for (int i = 0; i < 4; i++) { nb[i] = new Bitmap(tmpBmp); tmpBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); } // Floor Torch g.Clear(Color.White); g.FillEllipse(Brushes.Red, centerCircle); nb[4] = new Bitmap(tmpBmp); //Why the hell did notch do it like this? //South,North,West,East,Floor t = nb[0]; nb[0] = nb[2]; nb[2] = nb[3]; nb[3] = nb[1]; nb[1] = t; img[idx] = nb; debugSaveImages("RedstoneTorchOn", nb); break; case blockType.RedstoneTorchOff: //South,North,West,East,Floor nb = new Bitmap[5]; g.Clear(Color.White); g.FillRectangle(Brushes.Gray, centerLine); g.FillEllipse(Brushes.Black, centerCircle); for (int i = 0; i < 4; i++) { nb[i] = new Bitmap(tmpBmp); tmpBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); } // Floor Torch g.Clear(Color.White); g.FillEllipse(Brushes.Black, centerCircle); nb[4] = new Bitmap(tmpBmp); t = nb[0]; nb[0] = nb[2]; nb[2] = nb[3]; nb[3] = nb[1]; nb[1] = t; img[idx] = nb; debugSaveImages("RedstoneTorchOff", nb); break; case blockType.RedstoneWire: nb = new Bitmap[1]; Pen thickLine = new Pen(Color.Red, 5); g.Clear(Color.Transparent); g.DrawLine(thickLine, 10, 0, 10, 20); g.DrawLine(thickLine, 0, 10, 20, 10); nb[0] = new Bitmap(tmpBmp); img[idx] = nb; nb = null; break; case blockType.Air: nb = new Bitmap[1]; g.Clear(Color.White); nb[0] = new Bitmap(tmpBmp); img[idx] = nb; nb = null; break; default: nb = new Bitmap[1]; g.Clear(Color.Yellow); nb[0] = new Bitmap(tmpBmp); img[idx] = nb; nb = null; break; } } else { // block not defined, going to make it white with a black X in it Font boxFont = new Font("courier", 10, FontStyle.Regular); StringFormat strCenterBox = new StringFormat(); strCenterBox.Alignment = StringAlignment.Center; strCenterBox.LineAlignment = StringAlignment.Center; Bitmap[] b = new Bitmap[1]; RectangleF tmpBmpRect = new Rectangle(5, 5, 15, 15); g.Clear(Color.White); g.DrawString(idx.ToString(), SystemFonts.DefaultFont, Brushes.Black, tmpBmpRect); b[0] = new Bitmap(tmpBmp); img[idx] = b; } } }
public TextShow(Vector2 location, blockType type) : base(location, (int)Game1.title_font.MeasureString(BlockData.getName(type)).X + 8 + 4 + 4, (int)Game1.title_font.MeasureString(BlockData.getName(type)).Y + 8 + 4 + 4) { blockData = new BlockData(type); font = Game1.title_font; inside_color = Color.Yellow; border_colors = blockData.borderColours; text_color = blockData.textColour; text = blockData.name; canBeDraged = true; sprite_height = (int)font.MeasureString(text).Y; sprite_length = (int)font.MeasureString(text).X; data = new Color[width * height]; data_to_convert = new Color[width, height]; border_size = 8; generateTextureComplex(new int[4] { 4, 4, 4,4 }, border_colors, inside_color); }
public gBlockTypeStruct getSet(blockType iType) { return new gBlockTypeStruct(iType,img[(int)iType]); }
public void Initialize(int recLevel, blockType type, int blockMaterial) { recursionLevel = recLevel; myType = type; myMaterial = blockMaterial; }
public BlockData(blockType type) { this.type = type; switch (this.type) { case blockType.LEFT: name = "TURN LEFT"; canBeDockedTo = new bool[] { true, false }; borderColours = new Color[4] { insideColour, insideColour, insideColour, Color.Green }; textColour = Color.CadetBlue; break; case blockType.RIGHT: name = "TURN RIGHT"; canBeDockedTo = new bool[] { true, false }; borderColours = new Color[4] { insideColour, insideColour, insideColour, Color.Green }; textColour = Color.CadetBlue; break; case blockType.START: name = "START"; canBeDockedTo = new bool[2] { true, false }; borderColours = new Color[4] { insideColour, insideColour, insideColour, Color.Green }; textColour = Color.CadetBlue; break; case blockType.STOP: name = "STOP"; canBeDockedTo = new bool[2] { false, false }; borderColours = new Color[4] { insideColour, Color.Green, insideColour, insideColour }; textColour = Color.CadetBlue; break; case blockType.IF: name = "IF"; canBeDockedTo = new bool[2] { true, true }; borderColours = new Color[4] { insideColour, Color.Green, Color.Red, Color.Green }; textColour = Color.CadetBlue; break; case blockType.FOR: name = "FOR"; canBeDockedTo = new bool[2] { true, true }; borderColours = new Color[4] { insideColour, Color.Green, Color.Red, Color.Green }; ; textColour = Color.CadetBlue; break; case blockType.WHILE: name = "WHILE"; canBeDockedTo = new bool[2] { true, true }; borderColours = new Color[4] { insideColour, Color.Green, Color.Red, Color.Green }; textColour = Color.CadetBlue; break; case blockType.END: name = "END"; canBeDockedTo = new bool[2] { true, false }; borderColours = new Color[4] { insideColour, Color.Green, insideColour, Color.Green }; textColour = Color.CadetBlue; break; case blockType.NOT: name = "NOT"; canBeDockedTo = new bool[2] { false, true }; borderColours = new Color[4] { Color.Red, insideColour, Color.Red, insideColour }; textColour = Color.CadetBlue; break; case blockType.TRUE: name = "True"; canBeDockedTo = new bool[2] { false, true }; borderColours = new Color[4] { Color.Red, insideColour, Color.Red, insideColour }; textColour = Color.CadetBlue; break; case blockType.FALSE: name = "False"; canBeDockedTo = new bool[2] { false, true }; borderColours = new Color[4] { Color.Red, insideColour, Color.Red, insideColour }; textColour = Color.CadetBlue; break; case blockType.MOVEFORWARD: name = "Forward"; canBeDockedTo = new bool[2] { true, false }; borderColours = new Color[4] { insideColour, Color.Green, insideColour, Color.Green }; textColour = Color.CadetBlue; break; } }
void makeTextures() { Bitmap tmpBmp = new Bitmap(tileWidth, tileHeight, PixelFormat.Format32bppArgb); RectangleF centerCircle = new RectangleF( (tileWidth / 2) - (tileWidth / 4), (tileHeight / 2) - (tileHeight / 4), (tileWidth / 4) * 2, (tileHeight / 4) * 2); RectangleF centerLine = new RectangleF( (tileWidth / 2) - (tileWidth / 8), (tileHeight / 2) - (tileHeight / 8), (tileWidth / 8) * 2, tileHeight); RectangleF entireTile = new RectangleF(0, 0, tileWidth, tileHeight); int t; int[] nb = null; Graphics g; g = Graphics.FromImage(tmpBmp); //g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; for (int idx = 0; idx < blockMax; idx++) { if (Enum.IsDefined(typeof(blockType), (byte)idx)) { blockType cBlockType = (blockType)Enum.Parse(typeof(blockType), idx.ToString()); switch (cBlockType) { case blockType.StoneButton: nb = new int[4]; //North,West,South,East for (int i = 0; i < 4; i++) { g.Clear(Color.White); g.FillRectangle(Brushes.Gray, 4, 14, 14, 19); g.RotateTransform(i * 90); nb[i] = glHelper.LoadTexture(tmpBmp); } //Why the hell did notch do it like this? //South,North,West,East t = nb[0]; nb[0] = nb[2]; nb[2] = nb[1]; nb[1] = t; textures[idx] = nb; break; case blockType.RedstoneTorchOn: //North,East,South,West nb = new int[5]; g.Clear(Color.White); g.FillRectangle(Brushes.Gray, centerLine); g.FillEllipse(Brushes.Red, centerCircle); for (int i = 0; i < 4; i++) { nb[i] = glHelper.LoadTexture(tmpBmp); tmpBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); } // Floor Torch g.Clear(Color.White); g.FillEllipse(Brushes.Red, centerCircle); nb[4] = glHelper.LoadTexture(tmpBmp); //Why the hell did notch do it like this? //South,North,West,East,Floor t = nb[0]; nb[0] = nb[2]; nb[2] = nb[3]; nb[3] = nb[1]; nb[1] = t; textures[idx] = nb; break; case blockType.RedstoneTorchOff: //South,North,West,East,Floor nb = new int[5]; g.Clear(Color.White); g.FillRectangle(Brushes.Gray, centerLine); g.FillEllipse(Brushes.Black, centerCircle); for (int i = 0; i < 4; i++) { nb[i] = glHelper.LoadTexture(tmpBmp); tmpBmp.RotateFlip(RotateFlipType.Rotate90FlipNone); } // Floor Torch g.Clear(Color.White); g.FillEllipse(Brushes.Black, centerCircle); nb[4] = glHelper.LoadTexture(tmpBmp); t = nb[0]; nb[0] = nb[2]; nb[2] = nb[3]; nb[3] = nb[1]; nb[1] = t; textures[idx] = nb; break; case blockType.RedstoneWire: nb = new int[1]; Pen thickLine = new Pen(Color.Red, 5); g.Clear(Color.White); g.DrawLine(thickLine, 10, 0, 10, 20); g.DrawLine(thickLine, 0, 10, 20, 10); nb[0] = glHelper.LoadTexture(tmpBmp); textures[idx] = nb; break; case blockType.Air: nb = new int[1]; g.Clear(Color.Transparent); nb[0] = glHelper.LoadTexture(tmpBmp); textures[idx] = nb; break; default: nb = new int[1]; g.Clear(Color.Yellow); nb[0] = glHelper.LoadTexture(tmpBmp); textures[idx] = nb; break; } } else { // block not defined, going to make it white with a black X in it Font boxFont = new Font("courier", 10, FontStyle.Regular); StringFormat strCenterBox = new StringFormat(); strCenterBox.Alignment = StringAlignment.Center; strCenterBox.LineAlignment = StringAlignment.Center; nb = new int[1]; g.Clear(Color.Yellow); g.Clear(Color.White); g.DrawString(idx.ToString(), SystemFonts.DefaultFont, Brushes.Black, entireTile, strCenterBox); nb[0] = glHelper.LoadTexture(tmpBmp); textures[idx] = nb; } } }
public gBlockTypeStruct(blockType iType, Bitmap[] tiles) { bType = iType; bmp = tiles; }
public List<Block> getBlocks(blockType type, blockWhat what) { return _queryBlocks.getBlocks(type, what); }
public gBlockTypeStruct getSet(blockType iType) { return(new gBlockTypeStruct(iType, textures[(int)iType])); }
public gBlockTypeStruct(blockType iType, int[] tiles) { bType = iType; bmp = tiles; X = 0; Y = 0; Z = 0; }
public void ShowInspectorGUI(string GUIlabel){ // should probably return the dirty bit from here... // lets extend this, to show only the fields required by the selected action type. // that will make it a lot friendlier in the editor if (serializedObject == null) serializedObject = new SerializedObject(this); EditorGUI.BeginChangeCheck(); type = (actionType)EditorGUILayout.EnumPopup("Action type",(System.Enum)type); if (type == actionType.enableInteraction){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); stringParam = EditorGUILayout.TextField("InteractionTAG",stringParam);// used for a lot of different things negate = EditorGUILayout.Toggle("disable",negate); // use to turn enable to disable, stop audio, etc. loop = EditorGUILayout.Toggle("append",loop); texture2D = (Texture2D)EditorGUILayout.ObjectField("iconTexture",texture2D,typeof(Texture2D),true); ease = EditorGUILayout.Toggle("remove icon",ease); // hackfully abuse this boolean } if (type == actionType.playAudio){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToPlay",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("MappedSoundName",stringParam);// used for a lot of different things audioClip = (AudioClip)EditorGUILayout.ObjectField("audioClip",audioClip,typeof(AudioClip),true); fadeLength = EditorGUILayout.FloatField("delay After",fadeLength); if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("LookAt",stringParam2); // fadeLength = EditorGUILayout.FloatField("fadeLength",fadeLength); // also used for wait, move // ease = EditorGUILayout.Toggle("ease",ease); // ease or linear movement/fade negate = EditorGUILayout.Toggle("stop",negate); // use to turn enable to disable, stop audio, etc. loop = EditorGUILayout.Toggle("loop",loop); } if (type == actionType.playAnimation){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAnimate",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("animation",stringParam);// used for a lot of different things if (eventScript == null) eventScript = ""; eventScript = EditorGUILayout.TextField("eventScript",eventScript); // fadeLength = EditorGUILayout.FloatField("fadeLength",fadeLength); // also used for wait, move // desiredAlpha = EditorGUILayout.FloatField("desiredAlpha",desiredAlpha); loop = EditorGUILayout.Toggle("loop",loop); } if (type == actionType.putMessage){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); fadeLength = EditorGUILayout.FloatField("delay",fadeLength); // see about adding local gameMessage to use in this script if (gameMsgForm == null){ gameMsgForm = gameObject.AddComponent<GameMsgForm>();//gameObject.AddComponent<GameMsgForm>(); // could just do this when we know we'll need one... gameMsgForm.map = gameObject.AddComponent<InteractionMapForm>(); //gameObject.AddComponent<InteractionMapForm>(); EditorUtility.SetDirty(this); } else { if (gameMsgForm.ShowInspectorGUI()) EditorUtility.SetDirty(this); } if (gameMsgForm.msgType==GameMsgForm.eMsgType.dialogMsg) dialogIfThen = EditorGUILayout.Toggle("Treat As If-Then-Else",dialogIfThen); // stringParam = EditorGUILayout.TextField("message tag",stringParam);// used for a lot of different things } if (type == actionType.move){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToMove",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); fadeLength = EditorGUILayout.FloatField("moveTime",fadeLength); // also used for wait, move moveTo = (Transform)EditorGUILayout.ObjectField("moveTo",moveTo,typeof(Transform),true); if (moveToName == null) moveToName = ""; moveToName = EditorGUILayout.TextField("moveToName",moveToName); offset = EditorGUILayout.Vector3Field("offset",offset); // in moveTo reference frame ease = EditorGUILayout.Toggle("ease",ease); // ease or linear movement/fade } if (type == actionType.fade){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); // stringParam = EditorGUILayout.TextField("stringParam",stringParam);// used for a lot of different things fadeLength = EditorGUILayout.FloatField("fadeLength",fadeLength); // also used for wait, move desiredAlpha = EditorGUILayout.FloatField("desiredAlpha",desiredAlpha); desiredColor = EditorGUILayout.ColorField("desiredColor",desiredColor); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("New Matl or Mesh",stringParam); ease = EditorGUILayout.Toggle("ease",ease); // ease or linear movement/fade } if (type == actionType.ifThenElse){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToTest",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (stringParam == null) stringParam = ""; stringParam = ValidateConditionalString("attribute conditional",stringParam);// used for a lot of different things } if (type == actionType.executeScript){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToExecute",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); scriptToExecute = (InteractionScript)EditorGUILayout.ObjectField("scriptToExecute",scriptToExecute,typeof(InteractionScript),true); if (scriptToExecute != null) stringParam2 = scriptToExecute.name; if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("script name",stringParam2); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("args",stringParam);// used for a lot of different things ease = EditorGUILayout.Toggle("pass args",ease); // reused boolean } if (type == actionType.queueScript){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToExecute",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); scriptToExecute = (InteractionScript)EditorGUILayout.ObjectField("scriptToExecute",scriptToExecute,typeof(InteractionScript),true); if (scriptToExecute != null) stringParam2 = scriptToExecute.name; if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("script name",stringParam2); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("args",stringParam);// used for a lot of different things ease = EditorGUILayout.Toggle("pass args",ease); // reused boolean loop = EditorGUILayout.Toggle("check to flush",loop); // reused boolean if (loop) stringParam2 = ""; //flush takes empty script } if (type == actionType.wait){ if (stringParam == null) stringParam = ""; stringParam = ValidateConditionalString("wait Condition",stringParam); if (stringParam != "" && stringParam != null) fadeLength = EditorGUILayout.FloatField("Timeout Value",fadeLength); else fadeLength = EditorGUILayout.FloatField("wait Time",fadeLength); // also used for wait, move if (preAttributes!="" || postAttributes != "" || stringParam != ""){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("object for Attributes",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("object Name for attributes",objectName); } loop = EditorGUILayout.Toggle("Hold Position",loop); // reused boolean } if (type == actionType.characterTask){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("characterToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("characterName",objectName); if (moveToName == null) moveToName = ""; moveToName = EditorGUILayout.TextField("Position",moveToName);// used for a lot of different things if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("Posture",stringParam); if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("LookAt",stringParam2); if (stringParam3 == null) stringParam3 = ""; stringParam3 = EditorGUILayout.TextField("Animation",stringParam3); fadeLength = EditorGUILayout.FloatField("delay",fadeLength); if (voiceTag == null) voiceTag = ""; voiceTag = EditorGUILayout.TextField("voiceTag",voiceTag); if (stringParam4 == null) stringParam4 = ""; stringParam4 = EditorGUILayout.TextField(":COMPLETE msg?",stringParam4); heading = EditorGUILayout.FloatField("Heading",heading); speed = EditorGUILayout.FloatField ("Speed",speed); if (attachmentOverride == null) attachmentOverride = ""; attachmentOverride = EditorGUILayout.TextField("attachmentOverride",attachmentOverride); if (eventScript == null) eventScript = ""; eventScript = EditorGUILayout.TextField("eventScript",eventScript); // I had no idea how to write this, but thanks to Unity forums, here is a nice Array custom inspector! serializedObject.Update(); EditorGUIUtility.LookLikeInspector(); SerializedProperty myIterator = serializedObject.FindProperty("syncToTasks"); while (true){ Rect myRect = GUILayoutUtility.GetRect(0f, 16f); bool showChildren = EditorGUI.PropertyField(myRect, myIterator); if (!myIterator.NextVisible(showChildren)) break; } serializedObject.ApplyModifiedProperties() ; EditorGUIUtility.LookLikeControls(); // end of Thanks to the Forums for the code! } if (type == actionType.attach){ negate = EditorGUILayout.Toggle("check for DETACH",negate); objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (attachmentOverride == null) attachmentOverride = ""; if (negate) attachmentOverride = EditorGUILayout.TextField("reparentOverride",attachmentOverride); else attachmentOverride = EditorGUILayout.TextField("target parent Override",attachmentOverride); offset = EditorGUILayout.Vector3Field("offset",offset); orientation = EditorGUILayout.Vector3Field("orientation",orientation); fadeLength = EditorGUILayout.FloatField("lerpTime",fadeLength); // stringParam = EditorGUILayout.TextField("parent name",stringParam);// used for a lot of different things } if (type == actionType.spawn){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("SpawnLocationObject",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("LocationObjectName",objectName); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("template",stringParam);// used for a lot of different things if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("newName",stringParam2); if (stringParam3 == null) stringParam3 = ""; stringParam3 = EditorGUILayout.TextField("newParent?",stringParam3); // loop = EditorGUILayout.Toggle("attach To Location?",loop); offset = EditorGUILayout.Vector3Field("attach offset",offset); } if (type == actionType.destroy){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); } if (type == actionType.unityMessage){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAnimate",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("method",stringParam);// used for a lot of different things if (stringParam2 == null) stringParam2 = ""; stringParam2 = EditorGUILayout.TextField("argumentString",stringParam2);// used for a lot of different things } if (type == actionType.lockPosition){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToLock",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("objectName",objectName); if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("lockScriptPriority",stringParam);// used for a lot of different things negate = EditorGUILayout.Toggle("check for UNLOCK",negate); } if (type == actionType.goToLine){ if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("abort or line#",stringParam); GUILayout.Label("BE CAREFUL WITH THOSE LINE NUMBERS!"); } if (type == actionType.setIKTarget){ objectToAffect = (GameObject)EditorGUILayout.ObjectField("taskCharacter",objectToAffect,typeof(GameObject),true); if (objectName == null) objectName = ""; objectName = EditorGUILayout.TextField("taskCharacterName",objectName); if (moveToName == null) moveToName = ""; moveToName = EditorGUILayout.TextField("targetName",moveToName);// used for a lot of different things if (stringParam == null) stringParam = ""; stringParam = EditorGUILayout.TextField("Left or Right",stringParam); fadeLength = EditorGUILayout.FloatField("blendTime",fadeLength); offset = EditorGUILayout.Vector3Field("offset",offset); orientation = EditorGUILayout.Vector3Field("orientation",orientation); if (stringParam2 == null) stringParam2 = "0"; stringParam2 = EditorGUILayout.TextField("Hold Time",stringParam2); } GUILayout.Space(10); if (comment == null) comment = ""; comment = EditorGUILayout.TextField("comment",comment); if (preAttributes == null) preAttributes = ""; preAttributes = EditorGUILayout.TextField("preAttributes",preAttributes); // set when line starts if (postAttributes == null) postAttributes = ""; postAttributes = EditorGUILayout.TextField("postAttributes",postAttributes); // set when line completes block = (blockType)EditorGUILayout.EnumPopup("IfThenElse bracket",(System.Enum)block); SetNamePrefix(block); executeOnlyOnce = EditorGUILayout.Toggle("executeOnlyOnce",executeOnlyOnce); waitForCompletion = EditorGUILayout.Toggle("waitForCompletion",waitForCompletion); sequenceEnd = EditorGUILayout.Toggle("sequenceEnd",sequenceEnd); breakpoint = EditorGUILayout.Toggle("debug breakpoint",breakpoint); bool dirty = EditorGUI.EndChangeCheck(); if (dirty){ if (objectToAffect != null && objectName == ""){ // default, or we could try looking up the name again... objectName = objectToAffect.name; } if (moveTo != null && moveToName == ""){ // default, or we could try looking up the name again... moveToName = moveTo.name; } if (scriptToExecute != null && stringParam2 == ""){ // default, or we could try looking up the name again... stringParam2 = scriptToExecute.name; } EditorUtility.SetDirty(this); } /* cut and paste reference for new inspector types * objectToAffect = (GameObject)EditorGUILayout.ObjectField("objectToAffect",objectToAffect,typeof(GameObject)); objectName = EditorGUILayout.TextField("objectName",objectName); stringParam = EditorGUILayout.TextField("stringParam",stringParam);// used for a lot of different things audioClip = (AudioClip)EditorGUILayout.ObjectField("audioClip",audioClip,typeof(AudioClip)); fadeLength = EditorGUILayout.FloatField("fadeLength",fadeLength); // also used for wait, move desiredAlpha = EditorGUILayout.FloatField("desiredAlpha",desiredAlpha); desiredColor = EditorGUILayout.ColorField("desiredColor",desiredColor); moveTo = (Transform)EditorGUILayout.ObjectField("moveTo",moveTo,typeof(Transform)); ease = EditorGUILayout.Toggle("ease",ease); // ease or linear movement/fade negate = EditorGUILayout.Toggle("negate",negate); // use to turn enable to disable, stop audio, etc. loop = EditorGUILayout.Toggle("loop",loop); waitForCompletion = EditorGUILayout.Toggle("waitForCompletion",waitForCompletion); executeOnlyOnce = EditorGUILayout.Toggle("executeOnlyOnce",executeOnlyOnce); ifBranch = EditorGUILayout.TextField("ifBranch",ifBranch); elseBranch = EditorGUILayout.TextField("elseBranch",elseBranch); */ /* if (GUILayout.Button("SERIALIZE")){ // ScriptedActionInfo info = ToInfo (this); ScriptedObject pop = this.transform.parent.parent.GetComponent<ScriptedObject>(); ScriptedObject.ScriptedObjectInfo info = pop.ToInfo (pop); XmlSerializer serializer = new XmlSerializer(typeof(ScriptedObject.ScriptedObjectInfo)); FileStream stream = new FileStream("TESTSOSERIAL.xml", FileMode.Create); serializer.Serialize(stream, info); stream.Close(); } */ }
// Constructors, MUST have the bmp to get refrences to images. public redstoneObj(gBlockTypeStruct bData) { bmp = bData.bmp; bType = bData.bType; }
public gBlockStruct(blockType iType, byte data, int x, int y, int z) { bType = iType; Data = data; X=x; Y=y; Z=z; }
public gBlockStruct(blockType iType, byte data) { bType = iType; Data = data; X=0; Y=0; Z=0; }