public override string ToString() { string mapString = ""; for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { TILETYPE currentType = map[x, y].TileType; if (currentType == TILETYPE.HERO) { mapString += 'H'; } else if (currentType == TILETYPE.ENEMY) { mapString += 'G'; } else if (currentType == TILETYPE.EMPTY) { mapString += '.'; } else if (currentType == TILETYPE.OBSTACLE) { mapString += 'X'; } } mapString += "/n"; } }
public void SetInfo(List <int> coords, int tileNum, int corruptV, int buildVal, int activeChild) { for (int i = 0; i < transform.childCount; i++) { children.Add(transform.GetChild(i).gameObject); } CardData temp = GameManager.instance.Info(tileNum); cardNumber = tileNum; xCoord = coords[0]; yCoord = coords[1]; type = temp.TYPE(); buildTime = buildVal; tileValue = temp.TVALUE(); corruptVal = corruptV; buildValue = bVal(); if (activeChild > 0) { children[activeChild].SetActive(true); if (activeChild > 2 && activeChild < 6) { scheduledDemo = true; } } if (type == TILETYPE.EVENT) { gameObject.GetComponent <BoxCollider2D>().enabled = false; scheduledDemo = true; } }
public bool TileCheck(int x, int y, TILETYPE type, bool test) { bool retVal = false; if (test) { if ((x >= 0 && x < rows) && (y >= 0 && y < cols)) { if (gameplayObj[x, y] >= 0) { retVal = true; } } } else { if ((x >= 0 && x < rows) && (y >= 0 && y < cols)) { if (gameplayObj[x, y] >= 0) { retVal = GameManager.instance.cardData[gameplayObj[x, y]].TYPE() == type; } } } return(retVal); }
public Gold(int x, int y, TILETYPE tileType) : base(x, y, TILETYPE.GOLD) { this.x = x; this.y = y; this.tileType = tileType; numGold = Roll.Next(1, 5); }
public Location(Vector2 inCoords, Level inLevel) { tile=generateTile(); coords=inCoords; level=inLevel; if (!(displayHolder)) displayHolder=GameObject.Find("Display"); }
public Tile(int X, int Y, TILETYPE tileType) { this.X = X; this.Y = Y; tileType = TILETYPE.HERO; tileType = TILETYPE.ENEMY; tileType = TILETYPE.GOLD; tileType = TILETYPE.WEAPEN; tileType = TILETYPE.OBSTACLE; }
public void SetData(int x, int y, TILETYPE t, bool r, bool p, bool com, bool f, int c, string n) { type = t; buildTime = x; tileValue = y; recycle = r; corruptValue = c; party = p; commute = com; name = n; funded = f; }
public void SetData(int x, int y, SPELLTYPE t, bool r, bool p, bool com, bool f, string n) { spell = t; buildTime = x; tileValue = y; recycle = r; name = n; type = TILETYPE.SPELL; party = p; commute = com; funded = f; }
// EVEN = [-1,-1] [-1, 0] [0, -1] [0, +1] [+1, 0] [+1, -1] // ODD = [-1, 0] [-1, +1] [0, -1] [0, +1] [+1, 0] [+1, +1] public bool placeTile(List <int> coords, TILETYPE tileType, bool first, bool completeFirst) { bool retVal = false; int x = coords[0]; // row int y = coords[1]; // col bool oddN = (x + 1) % 2 == 0; List <bool> results = new List <bool>(); if (!completeFirst) { if (oddN) { results.Add(TileCheck(x - 1, y, tileType, first)); results.Add(TileCheck(x - 1, y + 1, tileType, first)); results.Add(TileCheck(x, y - 1, tileType, first)); results.Add(TileCheck(x, y + 1, tileType, first)); results.Add(TileCheck(x + 1, y, tileType, first)); results.Add(TileCheck(x + 1, y + 1, tileType, first)); } else { results.Add(TileCheck(x - 1, y - 1, tileType, first)); results.Add(TileCheck(x - 1, y, tileType, first)); results.Add(TileCheck(x, y - 1, tileType, first)); results.Add(TileCheck(x, y + 1, tileType, first)); results.Add(TileCheck(x + 1, y, tileType, first)); results.Add(TileCheck(x + 1, y - 1, tileType, first)); } int count = 0; for (int i = 0; i < results.Count; i++) { if (results[i]) { count++; } } if (count > 0) { retVal = true; } } else { retVal = true; } return(retVal); }
public string[] all_Directions = new string[] { "Left", "Right", "Up", "Down" }; //All specified directions. In this case Left will always have the index 0 for every direction array used as a vector for the movement methods. //constructor public Tile(TILETYPE type, Point firstPoint, Image baseImage) { MyType = type; Check_Tile_Type(); pointTracker = firstPoint; myImage = baseImage; if (MyType == TILETYPE.BLOCK) { myImage = Image.FromFile(@"..\..\Resources\Block.jpg"); } else if (MyType == TILETYPE.TILE) { myImage = Image.FromFile(@"..\..\Resources\Tile.jpg"); } Possible_moves(); }
public bool surroundCheck(int x, int y, TILETYPE type) { bool retVal = false; if ((x >= 0 && x < rows) && (y >= 0 && y < cols)) { if (gameplayObj[x, y] != -1) { retVal = GameManager.instance.cardData[gameplayObj[x, y]].TYPE() != type; } } else { retVal = true; } return(retVal); }
public void SetInfo(List <int> coords, int tileNum) { CardData temp = GameManager.instance.Info(tileNum); cardNumber = tileNum; xCoord = coords[0]; yCoord = coords[1]; type = temp.TYPE(); buildTime = temp.BUILD(); tileValue = temp.TVALUE(); corruptVal = temp.CORRUPT(); buildValue = bVal(); if (type == TILETYPE.EVENT) { gameObject.GetComponent <BoxCollider2D>().enabled = false; } }
public bool firstTile(TILETYPE t) { bool retVal = false; int count = 0; for (int i = 0; i < currentTiles.Count; i++) { if (currentTiles[i].type == t) { count++; } } if (count == 0) { retVal = true; } return(retVal); }
public Tile Create(TILETYPE tileType) { int x = random.Next(0, WIDTH); int y = random.Next(0, HEIGHT); while (map[x, y].tileType != TILETYPE.EMPTY) { x = random.Next(0, WIDTH); y = random.Next(0, HEIGHT); } if (tileType == TILETYPE.HERO) { map[x, y] = new Hero(x, y, 10); } else if (tileType == TILETYPE.ENEMY) { map[x, y] = new Goblim(x, y); } return(new EmptyTile(x, y)); }
public TargetTileTypeFiltter(TILETYPE tileType, int ID) : base(ID) { this.tileType = tileType; switch (tileType) { case TILETYPE.BASENEXO: cardTargetType = CARDTARGETTYPE.BASENEXO; break; case TILETYPE.SPAWN: cardTargetType = CARDTARGETTYPE.SPAWN; break; case TILETYPE.BATTLEFILED: cardTargetType = CARDTARGETTYPE.BATTLEFIELD; break; default: cardTargetType = CARDTARGETTYPE.BATTLEFIELD; break; } }
public void SetInfo(int cardNum, string name, TILETYPE type, CollectionManager c) { this.cardNum = cardNum; currentAmt = 1; numberInfo.text = ""; ButtonInfo.text = name; cm = c; switch (type) { case TILETYPE.COMMERCIAL: buttonImg.sprite = cardColors[0]; break; case TILETYPE.SPELL: buttonImg.sprite = cardColors[2]; break; case TILETYPE.RESIDENTIAL: buttonImg.sprite = cardColors[1]; break; } }
public Enemy(int x, int y, int Damage, int HP, TILETYPE tileType) : base(x, y, TILETYPE.ENEMY) { this.Damage = Damage; this.HP = HP; this.maxHP = HP; }
public Mage(int x, int y, int Damage, int HP, TILETYPE tileType) : base(x, y, 5, 5, TILETYPE.ENEMY) { this.Damage = 5; this.maxHP = 5; }
public Item(int x, int y, TILETYPE tileType) : base(x, y, TILETYPE.EMPTY) { }
public bool surrounded(TILETYPE t) { bool retVal = false; List <TileInfo> to = new List <TileInfo>(); foreach (TileInfo tile in GameManager.instance.currentTiles) { if (tile.type == t) { to.Add(tile); } } List <bool> surrounded = new List <bool>(); int count = 0; if (to.Count > 0) { bool oddN; foreach (TileInfo x in to) { int temp = 0; oddN = (x.xCoord + 1) % 2 == 0; if (oddN) { surrounded.Add(surroundCheck(x.xCoord - 1, x.yCoord, t)); surrounded.Add(surroundCheck(x.xCoord - 1, x.yCoord + 1, t)); surrounded.Add(surroundCheck(x.xCoord, x.yCoord - 1, t)); surrounded.Add(surroundCheck(x.xCoord, x.yCoord + 1, t)); surrounded.Add(surroundCheck(x.xCoord + 1, x.yCoord, t)); surrounded.Add(surroundCheck(x.xCoord + 1, x.yCoord + 1, t)); } else { surrounded.Add(surroundCheck(x.xCoord - 1, x.yCoord - 1, t)); surrounded.Add(surroundCheck(x.xCoord - 1, x.yCoord, t)); surrounded.Add(surroundCheck(x.xCoord, x.yCoord - 1, t)); surrounded.Add(surroundCheck(x.xCoord, x.yCoord + 1, t)); surrounded.Add(surroundCheck(x.xCoord + 1, x.yCoord, t)); surrounded.Add(surroundCheck(x.xCoord + 1, x.yCoord - 1, t)); } for (int i = 0; i < surrounded.Count; i++) { if (surrounded[i]) { temp++; } } if (temp == surrounded.Count) { count++; } } } if (count == to.Count) { retVal = true; } return(retVal); }
private void radioButton6_CheckedChanged(object sender, EventArgs e) { tileType = TILETYPE.WALL; }
void Update() { if(PathStack.Count == 0){ setDamage_now(0); } if(!NowBreaking){ if(Input.GetButtonDown("Fire1")){ Vector2 V2 = new Vector2(Input.mousePosition.x,Input.mousePosition.y); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if(Physics.Raycast(ray, out hit)) { if(player.transform == hit.transform){ Application.LoadLevel(4); } } // // } // else if(Input.touchCount != 0){ // Vector2 V2 = Input.GetTouch(0).position; // Ray ray = Camera.main.ScreenPointToRay(new Vector3(V2.x,V2.y,0)); // RaycastHit hit = new RaycastHit(); // if(Physics.Raycast(ray, out hit)) { foreach(Tile tiles in main_Tile){ if(tiles.myTile.transform == hit.transform){ Add(new Vector2(tiles.myStatus.myX,tiles.myStatus.myY)); } } } } // else{ else if(Input.GetButtonDown("Fire2")){ int count = PathStack.Count; TILETYPE type = new TILETYPE(); bool isEnemyAttacked = false; while(PathStack.Count != 0){ Vector2 now = (Vector2)PathStack.Pop(); int nx,ny; nx = (int)now.x; ny = (int)now.y; main_Tile[ny,nx].SetScale (1.0f); if(count >= 3){ if(!(type == TILETYPE.Sword && main_Tile[ny,nx].myStatus.myType == TILETYPE.Enemy) ){ type = main_Tile[ny,nx].myStatus.myType; } if(main_Tile[ny,nx].myStatus.myType == TILETYPE.Enemy){ isEnemyAttacked = true; } main_Tile[ny,nx].BeAttacked (Damage_now); } touch_Check[ny,nx] = false; } DestroyTile(); if(count >= 3){ if(isEnemyAttacked){ UserData.Instance.Xien = 0; } GameObject.Find ("ComboBox").GetComponent<ComboLogic>().AddCombo(type); if(type == TILETYPE.Coin){ UserData.Instance.Coin += count; } else if(type == TILETYPE.Potion){ UserData.Instance.Hp += count; } else if(type == TILETYPE.Wand){ UserData.Instance.Xien += count; } GameObject.Find ("UserText").GetComponent<UserText>().setStat(); } } if (Input.GetKeyDown(KeyCode.Escape)){ Application.LoadLevel(1); } } }
public Character(int x, int y, TILETYPE tileType) : base(x, y, tileType) { vision = new Tile[4]; }
public Tile(int x, int y, TILETYPE tileType) { this.x = x; this.y = y; this.tileType = tileType; }
public bool reorganizeHand(GameObject currentCard, Vector2 droppedPos, int value) { bool retVal = true; RaycastHit2D[] touches = Physics2D.RaycastAll(droppedPos, droppedPos, 0.5f); if (touches.Length > 1) { var hit = touches[1]; if (hit.transform != null) { if (hit.transform.tag == "Hex") { GameObject position = hit.transform.gameObject; SpriteRenderer hitTile = position.GetComponent <SpriteRenderer>(); if (!cm.containsTile(hitTile.sprite) && !cm.isSpell(currentCard.GetComponent <SpriteRenderer>().sprite)) { TILETYPE t = GameManager.instance.cardData[cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)].TYPE(); if ((t == TILETYPE.INDUSTRIAL && hexGrid.industryCheck(hexGrid.COORDS(position)) || (t != TILETYPE.INDUSTRIAL))) { if (hexGrid.placeTile(hexGrid.COORDS(position), t, GameManager.instance.firstTile(t), GameManager.instance.currentTiles.Count == 0)) { hit.transform.gameObject.AddComponent <TileInfo>().SetInfo(hexGrid.updateGRID(position, cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)), cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)); GameManager.instance.currentTiles.Add(hit.transform.gameObject.GetComponent <TileInfo>()); currentCard.transform.position = new Vector2(-100, -100); hitTile.sprite = currentCard.GetComponent <SpriteRenderer>().sprite; GameManager.instance.playedCard(cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)); } else { if (hexGrid.surrounded(t) && !GameManager.instance.firstTile(t)) { hit.transform.gameObject.AddComponent <TileInfo>().SetInfo(hexGrid.updateGRID(position, cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)), cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)); GameManager.instance.currentTiles.Add(hit.transform.gameObject.GetComponent <TileInfo>()); currentCard.transform.position = new Vector2(-100, -100); hitTile.sprite = currentCard.GetComponent <SpriteRenderer>().sprite; GameManager.instance.playedCard(cm.cardValue(currentCard.GetComponent <SpriteRenderer>().sprite)); } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; warning = 1; } } } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; warning = 0; } } else { if (cm.spellType(value) == SPELLTYPE.TARGETED) { if (cm.containsTile(hitTile.sprite)) { TileInfo tile = position.GetComponent <TileInfo>(); if (tile) { if (GameManager.instance.playSpell(value, tile)) { currentCard.transform.position = new Vector2(-100, -100); //TODO : DO TURN ON SPELL MODIFIERS AND SUCH. GameManager.instance.playedCard(value); } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; } } else { // NO TILE INFO, SO WATER. currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; } } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; warning = 7; } } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; } } // touchOffset = (Vector2)hit.transform.position - inputPosition; // draggedObject.transform.localScale = new Vector3(1.2f,1.2f,1.2f); // draggedObject.GetComponent<SpriteRenderer>().sprite = cm.changetoTile(draggedObject.GetComponent<SpriteRenderer>().sprite); } else if (hit.transform.tag == "SpellArea") { // PLAY THE CARD if (GameManager.instance.playSpell(value, null)) { currentCard.transform.position = new Vector2(-100, -100); //TODO : DO TURN ON SPELL MODIFIERS AND SUCH. GameManager.instance.playedCard(value); } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; } // cm.spellArea.color = new Color(1,1,1,0); // TODO: FADE? cm.spellSpot.SetActive(false); } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; // not placed on anything. warning = 5; } } } else { currentCard.transform.position = cardPositions[indexOfCard(currentCard)]; retVal = false; warning = 9; // not placed on anything. } if (!retVal && cm.isSpell(currentCard.GetComponent <SpriteRenderer>().sprite)) { // cm.spellArea.color = new Color(1,1,1,0); // TODO: FADE? cm.spellSpot.SetActive(false); } if (!retVal) { setWarningTxt(); } return(retVal); }
public Character(int x, int y, TILETYPE tileType) : base(x, y, tileType) { }
public GameObject getDisplayObject(TILETYPE tile) { GameObject tempGameObject=null; switch (tile) { case TILETYPE.SPACE: tempGameObject=(GameObject) Instantiate(spacetile); break; case TILETYPE.WALL: tempGameObject=(GameObject) Instantiate(walltile); break; } return tempGameObject; }
void Update() { if(!NowBreaking){ if(Input.GetButtonUp("Fire1")){ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); int what = 0; foreach(Tile x in main_Tile){ x.SetDieEffect(false); } if(Physics.Raycast(ray, out hit)) { foreach(Tile tiles in main_Tile){ if(tiles.myTile.transform == hit.transform && before == tiles.myTile){ PathQ = new Vector2[50]; PQc = 0; Add(new Vector2(tiles.myStatus.myX,tiles.myStatus.myY)); what = 1; } } } tk2dTextMesh DMG_Text = GameObject.Find ("DMG Text").GetComponent<tk2dTextMesh>(); tk2dTextMesh DMG_Gap = GameObject.Find("DMG Gap").GetComponent<tk2dTextMesh>(); DMG_Text.text = ""; DMG_Gap.text = ""; DMG_Text.Commit (); DMG_Gap.Commit (); for(int i=0;i<TILE_SIZE;i++){ for(int j=0;j<TILE_SIZE;j++){ main_Tile[i,j].SetScale (1.0f); } } before = null; if(what == 1){ int count = PQc; TILETYPE type = new TILETYPE(); while(PQc != 0){ Vector2 now = (Vector2)PathQ[PQc-1]; PQc--; int nx,ny; nx = (int)now.x; ny = (int)now.y; main_Tile[ny,nx].SetScale (1.0f); if(count >= 3){ if(!(type == TILETYPE.Sword && main_Tile[ny,nx].myStatus.myType == TILETYPE.Enemy)){ type = main_Tile[ny,nx].myStatus.myType; } main_Tile[ny,nx].BeAttacked (Damage_now); } } if(count >= 3){ DestroyTile(); GameObject.Find ("ComboBox").GetComponent<ComboLogic>().AddCombo(type); if(type == TILETYPE.Coin){ UserData.Instance.Coin += count; } else if(type == TILETYPE.Potion){ UserData.Instance.UpHp(count); } else if(type == TILETYPE.Storm){ UserData.Instance.UpMp(count); } GameObject.Find ("UserText").GetComponent<UserText>().setStat(); } } } if(Input.GetButtonDown("Fire1")){ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if(Physics.Raycast(ray, out hit)) { if(player.transform == hit.transform){ Application.LoadLevel(4); } } int what = 0; if(Physics.Raycast(ray, out hit)) { foreach(Tile tiles in main_Tile){ if(tiles.myTile.transform == hit.transform && tiles.myStatus.myType != TILETYPE.X){ before = tiles.myTile; PathQ = new Vector2[50]; PQc = 0; Add(new Vector2(tiles.myStatus.myX,tiles.myStatus.myY)); what = 1; } } } if(what == 1 && PQc >= 3){ int count = PQc; int upcount = 0; TILETYPE type = main_Tile[(int)PathQ[0].y,(int)PathQ[0].x].myStatus.myType; tk2dTextMesh DMG_Text = GameObject.Find ("DMG Text").GetComponent<tk2dTextMesh>(); tk2dTextMesh DMG_Gap = GameObject.Find("DMG Gap").GetComponent<tk2dTextMesh>(); for(int i=0;i<PQc;i++){ Vector2 now = (Vector2)PathQ[i]; int nx,ny; nx = (int)now.x; ny = (int)now.y; main_Tile[ny,nx].SetScale(1.3f); } if(type == TILETYPE.Coin){ DMG_Text.text = "CNT"; upcount = count; } else if(type == TILETYPE.Potion){ DMG_Text.text = "HP"; upcount = UserData.Instance.UpHpGap(count); } else if(type == TILETYPE.Storm){ DMG_Text.text = "STM" ; upcount = UserData.Instance.UpMpGap (count); } else{ upcount = 1; for(int i=0 ; i<PQc ; i++){ Vector2 now = (Vector2)PathQ[i]; int nx,ny; nx = (int)now.x; ny = (int)now.y; if(main_Tile[ny,nx].myStatus.myType == TILETYPE.Sword){ upcount += UserData.Instance.Atk; } } Damage_now = upcount; DMG_Text.text = "DMG"; for(int i=0 ; i<PQc ; i++){ Vector2 now = (Vector2)PathQ[i]; int nx,ny; nx = (int)now.x; ny = (int)now.y; if(main_Tile[ny,nx].myStatus.myType == TILETYPE.Enemy && main_Tile[ny,nx].myStatus.myHp <= Damage_now){ main_Tile[ny,nx].SetDieEffect(true); } } } DMG_Gap.text = upcount.ToString(); DMG_Text.Commit (); DMG_Gap.Commit (); } } if (Input.GetKeyDown(KeyCode.Escape)){ Application.LoadLevel(1); } } }