public override void _Ready() { sprites = new GridSprite[Instance.maxX][]; grid = GetNode <GridContainer>("NumberGrid"); Grid g = new Grid(5, 5); Random rand = new Random(2); var path = g.RandomPath(rand); g.FillPath(30, 90, path, rand); grid.Columns = Instance.maxX; for (int x = 0; x < Instance.maxX; x++) { sprites[x] = new GridSprite[Instance.maxY]; for (int y = 0; y < Instance.maxY; y++) { sprites[x][y] = new GridSprite { type = g.At(x, y).op, number = g.At(x, y).value }; grid.AddChild(sprites[x][y]); } } foreach (var xy in path) { sprites[xy.x][xy.y].Modulate = Color.ColorN("red"); } }
void OnCollisionStay2D(Collision2D col) { if (col.collider.tag == "Wall") { if (itemInfo != null) { if (itemInfo.GetItemKind() == PlayerItem.ItemKind.Pickax) { GridSprite gridInfo = col.collider.gameObject.GetComponent <GridSprite>(); if (gridInfo) { if (isWallBreakEnabled) { Utils.Util.DeleteGameObj(col.collider.gameObject); toolAnimator.SetTrigger("Chop"); isWallBreakEnabled = false; Utils.Util.CoSeconds(() => { isWallBreakEnabled = true; }, 0.1f); playerSprite.color = Color.white; } else { playerSprite.color = Color.red; } } else { playerSprite.color = Color.blue; } } } } }
void Awake() { this.sprite = GetComponent <GridSprite>(); animations = new Dictionary <string, SpriteAnimation>(); }
void Start() { hp = 20; sprite = GetComponent <GridSprite>(); }