public override void Selected(Game Game, Gem.Gui.UIItem GuiRoot) { this.SelectedBlock = null; BlockContainer = new Gem.Gui.UIItem(Gem.Gui.Shape.CreateQuad(96, 8, 512, 128), new Gem.Gui.GuiProperties { Transparent = false, BackgroundColor = new Microsoft.Xna.Framework.Vector3(0.8f, 0.2f, 0.2f) }); GuiRoot.AddChild(BlockContainer); var x = 96 + 8; foreach (var template in Game.Sim.Blocks.Templates) { var lambdaTemplate = template; var child = HoverTest.CreateGuiSprite(new Rectangle(x, 16, 32, 32), template.Value.Preview, Game.Sim.Blocks.Tiles); child.Properties[0].Values.Upsert("click-action", new Action(() => { this.SelectedBlock = lambdaTemplate.Value; GuiRoot.RemoveChild(BlockContainer); BlockContainer = null; })); BlockContainer.AddChild(child); x += 32; } }
public void SwapGems(Gem currentGem) { if(lastGem == null) { lastGem = currentGem; } else if(lastGem == currentGem) { lastGem = null; } else { if(lastGem.IsNeighborWith(currentGem)) { gem1Start = lastGem.transform.position; gem1End = currentGem.transform.position; gem2Start = currentGem.transform.position; gem2End = lastGem.transform.position; startTime = Time.time; gem1 = lastGem; gem2 = currentGem; isSwapping = true; } else { lastGem.ToggleSelector(); lastGem = currentGem; } } }
public override void Create(Gem.PropertyBag Properties) { Properties.Upsert("render-mesh", Gem.Geo.Gen.TransformCopy(Gem.Geo.Gen.CreateTexturedFacetedCube(), Matrix.CreateTranslation(0, 0, 0.5f) * Matrix.CreateScale(1, 1, 0.25f))); Properties.Upsert("nav-mesh", Gem.Geo.Gen.TransformCopy(Gem.Geo.Gen.CreateQuad(), Matrix.CreateTranslation(0, 0, 0.25f))); base.Create(Properties); }
public WorldSceneNode(CellGrid World, Gem.PropertyBag Properties) { this.World = World; this.Blocks = Properties.GetPropertyAsOrDefault<BlockSet>("block-set"); this.HiliteTexture = Properties.GetPropertyAsOrDefault<int>("hilite-texture"); this.Orientation = new Gem.Euler(); }
public void ConstructMatchList(string color,Gem gem,int XCoord,int YCoord, ref List<Gem> MatchList) { if(gem == null) { return; } else if(gem.color != color) { return; } else if(MatchList.Contains(gem)) { return; } else { MatchList.Add(gem); if(XCoord == gem.XCoord || YCoord == gem.YCoord) { foreach(Gem g in gem.Neighbors) { ConstructMatchList(color,g,XCoord,YCoord,ref MatchList); } } } }
public override void Create(Gem.PropertyBag Properties) { base.Create(Properties); var branch = new Gem.Render.BranchNode(); var Mesh = Gem.Geo.Gen.CreateQuad(); //Gem.Geo.Gen.Transform(Mesh, Matrix.CreateRotationZ((float)Math.PI)); Gem.Geo.Gen.Transform(Mesh, Matrix.CreateTranslation(0, 0.5f, 0)); Gem.Geo.Gen.Transform(Mesh, Matrix.CreateScale(Properties.GetPropertyAs<float>("width"), Properties.GetPropertyAs<float>("height"), 1)); Gem.Geo.Gen.Transform(Mesh, Matrix.CreateRotationX((float)(Math.PI / 8) * 3)); Mesh = Gem.Geo.Gen.FacetCopy(Mesh); Gem.Geo.Gen.CalculateTangentsAndBiNormals(Mesh); var shadowMesh = Gem.Geo.Gen.CreateQuad(); shadowMesh = Gem.Geo.Gen.FacetCopy(shadowMesh); Gem.Geo.Gen.CalculateTangentsAndBiNormals(shadowMesh); ShadowNode = new Gem.Render.MeshNode(shadowMesh, Properties.GetPropertyAs<Texture2D>("drop-shadow"), null, ShadowOrientation); ShadowNode.InteractWithMouse = false; MeshNode = new Gem.Render.MeshNode(Mesh, Properties.GetPropertyAs<Texture2D>("sprite"), Properties.GetPropertyAs<Texture2D>("normal-map"), Orientation); branch.Add(ShadowNode); branch.Add(MeshNode); Renderable = branch; MeshNode.AlphaMouse = true; }
public void AddGem(Gem gem) { gems.Add(gem); gem.transform.SetParent(transform); maxScore += gem.Score; }
public override void Draw(Gem.Render.RenderContext context) { if (Hidden) return; context.Color = Color; if (Texture != null) context.Texture = Texture; if (NormalMap != null) context.NormalMap = NormalMap; else context.NormalMap = context.NeutralNormals; context.World = WorldTransform; context.UVTransform = UVTransform; context.LightingEnabled = true; context.Alpha = Alpha; context.ApplyChanges(); context.Draw(Mesh); context.NormalMap = context.NeutralNormals; if (Hilite && HiliteMesh != null) { context.Texture = context.White; context.Color = HiliteColor; context.LightingEnabled = false; context.ApplyChanges(); context.Draw(HiliteMesh); } context.UVTransform = Matrix.Identity; }
public void CollectGem(Gem gem) { gemsCollected++; if (gemsCollected == NumGems -1) { OpenDoor(); } }
//include setters for manually setting stats void PickedUp(Player player) { switch (gemType) { case 1: gem = new StrengthGem(); break; case 2: gem = new AgilityGem(); break; case 3: gem = new IntelligenceGem(); break; case 4: gem = new HealthGem(); break; case 5: gem = new ManaGem(); break; case 6: Debug.Log("Would be skill Gem"); //insert skill gem here when done break; } gem.setOwner(player); gem.Initialize(quality); //MUST CALL. think of this as running the Start() function, but Gem does not inherit from monobehaviour. Its its own man, taking orders from no base class. Debug.Log(gem.getDescription()); //Set stats for gem before adding to play player.GetComponent<GemManager>().addGem(gem); Destroy(gameObject); }
public static void playShotSound(Gem gem) { float vol = Random.Range(instance.volLowRange, instance.volHighRange); // Play the corresponding sound switch (gem) { case Gem.Red: instance.sound.PlayOneShot(instance.fireGemSound, vol); break; case Gem.Green: instance.sound.PlayOneShot(instance.healGemSound, vol); break; case Gem.Blue: instance.sound.PlayOneShot(instance.iceGemSound, vol); break; case Gem.Purple: instance.sound.PlayOneShot(instance.stealthGemSound, vol); break; case Gem.Yellow: instance.sound.PlayOneShot(instance.lightningGemSound, vol); break; default: instance.sound.PlayOneShot(instance.aoeGemSound, vol); break; } }
public virtual void Create(Gem.PropertyBag Properties) { CurrentAction = null; NextAction = null; this.Properties = Properties.Clone(); }
public virtual void Create(Gem.PropertyBag Properties) { RenderMesh = Properties.GetPropertyAs<Gem.Geo.Mesh>("render-mesh"); NavigationMesh = Properties.GetPropertyAs<Gem.Geo.Mesh>("nav-mesh", () => null); Texture = Properties.GetPropertyAs<Texture2D>("texture"); NormalMap = Properties.GetPropertyAs<Texture2D>("normal-map", () => null); }
public void spawnGem(Gem gem) { int x = 0; int y = 0; int z = 0; float voxelsDeep = VoxelWorld.Inst.ChunksDeep * VoxelWorld.Inst.ChunkVoxelSize * VoxelWorld.Inst.PhysicalVoxelSize; float voxelsWide = VoxelWorld.Inst.ChunksWide * VoxelWorld.Inst.ChunkVoxelSize * VoxelWorld.Inst.PhysicalVoxelSize; float voxelsHigh = VoxelWorld.Inst.ChunksHigh * VoxelWorld.Inst.ChunkVoxelSize * VoxelWorld.Inst.PhysicalVoxelSize; while (y == 0) { x = (int)(Random.value * voxelsWide); z = (int)(Random.value * voxelsDeep); for (int i = 0; i < voxelsHigh - 3; ++i) { if (VoxelWorld.Inst.GetVoxel(new IntVec3(x, i, z)).TypeDef.Type == VoxelType.Air) { y = i; break; } } } spawnGem(gem, x, y, z); }
List<Position> MatchedGemsAt(Gem[,] gemArray,Position origin) { GemColor myColor = gemArray[origin.Row, origin.Column].Color; List<Position> matchingGemsLeft = new List<Position>(); for (int column = origin.Column - 1; column >= 0; column--) { if (gemArray[origin.Row, column].Color == myColor) matchingGemsLeft.Add(new Position(origin.Row, column)); else break; } List<Position> matchingGemsRight = new List<Position>(); for (int column = origin.Column + 1; column < 8; column++) { if (gemArray[origin.Row, column].Color == myColor) matchingGemsRight.Add(new Position(origin.Row, column)); else break; } List<Position> matchingGemsAbove = new List<Position>(); for (int row = origin.Row - 1; row >= 0; row--) { if (gemArray[row, origin.Column].Color == myColor) matchingGemsAbove.Add(new Position(row, origin.Column)); else break; } List<Position> matchingGemsBelow = new List<Position>(); for (int row = origin.Row + 1; row < 8; row++) { if (gemArray[row, origin.Column].Color == myColor) matchingGemsBelow.Add(new Position(row, origin.Column)); else break; } List<Position> horizontalMatch = new List<Position>(matchingGemsLeft); horizontalMatch.AddRange(matchingGemsRight); List<Position> verticalMatch = new List<Position>(matchingGemsAbove); verticalMatch.AddRange(matchingGemsBelow); if (horizontalMatch.Count < 2) horizontalMatch.RemoveRange(0, horizontalMatch.Count); if (verticalMatch.Count < 2) verticalMatch.RemoveRange(0, verticalMatch.Count); if (horizontalMatch.Count >= 3) { //fire gem will be created } else if(horizontalMatch.Count >= 2 && verticalMatch.Count >= 2) { //star gem will be created } List<Position> involvedGems = new List<Position>(horizontalMatch); involvedGems.AddRange(verticalMatch); return involvedGems; }
/** * Checks if a gem has been unlocked */ public bool CheckIfGemUnlocked(Gem gem) { if (PlayerPrefs.HasKey (gem.ToString ()) && PlayerPrefs.GetString (gem.ToString ()).Equals ("unlocked")) { return true; } else { return false; } }
public Card(Price price, Gem product, int level, int vp, int id) { Price = price; GemProduct = product; Level = level; Vp = vp; Id = id; }
public void DebugRender(Gem.Render.RenderContext Context) { Context.Color = new Vector3(1, 0, 0); Context.LightingEnabled = false; Context.ApplyChanges(); foreach (var edge in Mesh.Edges) Context.DrawLineIM(Mesh.Verticies[edge.Verticies[0]], Mesh.Verticies[edge.Verticies[1]]); }
public void DebugRenderFace(Gem.Render.RenderContext Context, Gem.Geo.EMFace Face) { Context.Color = new Vector3(0, 1, 1); Context.LightingEnabled = false; Context.ApplyChanges(); foreach (var edge in Face.edges) Context.DrawLineIM(Mesh.Verticies[edge.Verticies[0]], Mesh.Verticies[edge.Verticies[1]]); }
public bool IsNeighborWith(Gem gem) { if (neighbors.Contains(gem)) { return true; } else { return false; } }
public bool IsNeighborWith(Gem g) { if(Neighbors.Contains(g)) { return true; } return false; }
public Move GetBestMove(Gem[,] gems, int movesToLookAhead, List<Position> lockedOutPositions) { if (movesToLookAhead < 1) throw new Exception(); List<Move> possibleMoves = new List<Move>(); //for now simply return the first match (from the top left) we find for (int row = 0; row < 8; row++) { for (int column = 0; column < 8; column++) { Position position = new Position(row, column); if (lockedOutPositions.Contains(position)) continue; List<Direction> validDirections = new List<Direction>(); if (row > 0) validDirections.Add(Direction.Up); if (row < 7) validDirections.Add(Direction.Down); if (column > 0) validDirections.Add(Direction.Left); if (column < 7) validDirections.Add(Direction.Right); foreach (Direction direction in validDirections) { int newRow = row; int newColumn = column; switch (direction) { case Direction.Up: newRow = row - 1; break; case Direction.Down: newRow = row + 1; break; case Direction.Left: newColumn = column - 1; break; case Direction.Right: newColumn = column + 1; break; } Position newPosition = new Position(newRow, newColumn); if (lockedOutPositions.Contains(newPosition)) continue; Gem[,] newArray = (Gem[,])gems.Clone(); SwapSlots(newArray, row, column, newRow, newColumn); List<Position> involvedGems = MatchedGemsAt(newArray, new Position(newRow, newColumn)); if (involvedGems.Count >= 2) possibleMoves.Add(new Move(new Position(row, column), new Position(newRow, newColumn), involvedGems) { GuaranteedScore = involvedGems.Count * 100 }); } } } if (possibleMoves.Count == 0) return new Move(new Position(0, 0), new Position(0, 0)) {ValidMove = false}; Random rand = new Random(); return possibleMoves[rand.Next(possibleMoves.Count)]; }
public static Mesh MorphToSplineCopy( Mesh mesh, Vector3 axis, Gem.Math.Spline spline) { var result = Copy(mesh); MorphToSpline(result, axis, spline); return result; }
public void ToggleOtherPhysics(bool isOn, Gem first, Gem second) { foreach(Gem g in gems) { if (g != first && g != second) { Rigidbody rb = g.GetComponent<Rigidbody>(); rb.isKinematic = isOn; } } }
public void AddRune(Gem gem) { if (gemSlotIndex <= gemSlots.Length) { Debug.Log("Tower get's rune: " + gem.itemName); gemSlots[gemSlotIndex].SetGem(gem); gemSlotIndex++; } }
public void MoveNegGem(Gem gemToMove,Vector3 toPos,Vector3 fromPos) { Vector3 center = (fromPos + toPos) *.5f; center -= new Vector3(0,0,-.1f); Vector3 riseRelCenter = fromPos - center; Vector3 setRelCenter = toPos - center; float fracComplete = (Time.time - startTime)/SwapRate; gemToMove.transform.position = Vector3.Slerp(riseRelCenter,setRelCenter,fracComplete); gemToMove.transform.position += center; }
public bool addGem(Gem gem) { if (gems.Count < gemLimitCount) { gems.Add (gem); updateSkill (); return true; } else { return false; } }
public override void Create(Gem.PropertyBag Properties) { base.Create(Properties); Renderable = new Gem.Render.MeshNode( Properties.GetPropertyAs<Gem.Geo.Mesh>("mesh"), Properties.GetPropertyAs<Texture2D>("texture"), null, Orientation); }
public static Mesh AlignToSplineCopy( Mesh mesh, Vector3 axis, Vector3 splineRotationAxis, Gem.Math.Spline spline, float distance) { var result = Copy(mesh); AlignToSpline(result, axis, splineRotationAxis, spline, distance); return result; }
public void SetGem(Gem newGem) { gem = newGem; tower.GemChanged(); if(gem != null){ this.GetComponent<Renderer>().material.color = gem.itemColour; } else { this.GetComponent<Renderer>().material.color = Color.white; } }
bool SameGem(Gem other) { return(other.getVal() == this.val); }
void Awake() { _gem = gameObject.GetComponent <Gem>(); }
public GameboardElement(Gem gemType, Point point) { GemType = gemType; BoardPosition = point; }
private void Select() { isSelected = true; render.color = selectedColor; previousSelected = gameObject.GetComponent <Gem>(); }
/// <summary> /// Initializes a new instance of the <see cref="GemViewModel" /> class. /// </summary> /// <param name="gem">The gem.</param> /// <param name="showLevel">if set to <c>true</c> [show level].</param> public GemViewModel(Gem gem, bool showLevel = true) : base(gem) { this._gem = gem; this.ShowLevel = showLevel; }
// Player 2 to Player 1 public void LinkNetworkGem(Gem gem, bool link) { PhotonView p = gem.GetComponent <PhotonView>(); photonView.RPC("LinkNetworkGem_RPC", PhotonTargets.Others, p.instantiationId, link); }
public bool GemsCanBeChanged(Gem current, Gem other) => current != null && current != other && AreAdjacent(current.ListIndex, other.ListIndex);
public Cell() { IsEmpty = true; GemInside = null; }
void Start() { teleporterManager = GameObject.FindGameObjectWithTag("Teleporters").GetComponent <TeleporterManager>(); gem = GameObject.FindGameObjectWithTag("Gem").GetComponent <Gem>(); gameObject.SetActive(false); }
private void Deselect() { isSelected = false; render.color = Color.white; previousSelected = null; }
// Add the item to the drop list private void buttonAdd_Click(object sender, EventArgs e) { int.TryParse(textBoxItemOdds.Text, out int dropChance); if (dropChance < 1) { dropChance = 1; } string quest = QuestOnlyCheckBox.Checked ? "Q" : ""; try { switch (tabControlSeperateItems.SelectedTab.Tag.ToString()) { case "Weapon": Weapon.Add(new DropItem { Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Armour": Armour.Add(new DropItem { Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Helmet": Helmet.Add(new DropItem { Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Necklace": Necklace.Add(new DropItem { Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bracelet": Bracelet.Add(new DropItem { Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ring": Ring.Add(new DropItem { Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Amulet": Amulet.Add(new DropItem { Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Belt": Belt.Add(new DropItem { Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Boots": Boot.Add(new DropItem { Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Stone": Stone.Add(new DropItem { Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Torch": Torch.Add(new DropItem { Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Potion": Potion.Add(new DropItem { Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ore": Ore.Add(new DropItem { Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Meat": Meat.Add(new DropItem { Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "CraftingMaterial": CraftingMaterial.Add(new DropItem { Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance) }); break; case "Scroll": Scrolls.Add(new DropItem { Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Gem": Gem.Add(new DropItem { Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mount": Mount.Add(new DropItem { Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Book": Book.Add(new DropItem { Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Nothing": Nothing.Add(new DropItem { Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Script": Script.Add(new DropItem { Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Reins": Reins.Add(new DropItem { Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bells": Bells.Add(new DropItem { Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Saddle": Saddle.Add(new DropItem { Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ribbon": Ribbon.Add(new DropItem { Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mask": Mask.Add(new DropItem { Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Food": Food.Add(new DropItem { Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Hook": Hook.Add(new DropItem { Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Float": Float.Add(new DropItem { Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bait": Bait.Add(new DropItem { Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Finder": Finder.Add(new DropItem { Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Reel": Reel.Add(new DropItem { Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Fish": Fish.Add(new DropItem { Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Quest": Quest.Add(new DropItem { Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Awakening": Awakening.Add(new DropItem { Name = listBoxAwakening.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Pets": Pets.Add(new DropItem { Name = listBoxPets.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Transform": Transform.Add(new DropItem { Name = listBoxTransform.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; } UpdateDropFile(); } catch { //No item selected when trying to add an item to the drop } }
void onWin(Gem winningGem) { winningGem.ShootFireworks(); StartCoroutine(ReloadLevel(8)); }
public void setGem1(Gem gem) { this.gem1 = gem; }
public void RemoveGem(Gem item) { Gems[item.Cell.X, item.Cell.Y] = null; }
public void CreateLevel(byte state) { LevelGenerator generator = new LevelGenerator(this); enemies.Clear(); blocks.Clear(); gems.Clear(); background.xBack = 0; switch (state) { case 1: currentLevel++; level = generator.Generate(); break; default: Score = 0; break; case 2: level = generator.Generate(); break; } levelMap = new byte[level[0].Length, level.Length]; levelLength = 50 * level[0].Length; int x = 0; int y = 0; int i = 0; int j = 0; foreach (string str in level) { foreach (char c in str) { if (c != '0') { switch (c) { case 'G': { Rectangle gemRect = new Rectangle(x + 10, y + 10, 30, 30); Gem gem = new Gem(gemRect, gemTexture, this); gems.Add(gem); } break; case 'X': { Rectangle rect = new Rectangle(x, y, 50, 50); Block block = new Block(rect, blockTexture, this); blocks.Add(block); levelMap[i, j] = 1; } break; case 'Y': { Rectangle rect = new Rectangle(x, y, 50, 50); Block block = new Block(rect, blockTexture2, this); blocks.Add(block); levelMap[i, j] = 1; } break; default: { Rectangle enemyRect = new Rectangle(x - 20, y - 41, 90, 90); AnimatedSprite enemy = null; switch (c) { case '★': enemy = new Enemy_1(enemies.Count, enemyRect, enemyIdleTexture, enemyRunTexture, enemyRunTexture, 2, 9, this); break; } enemies.Add(enemy); enemy.Run(true); } break; case 'P': { hero = new Hero(new Rectangle(x - 20, y - 41, 90, 90), 3, 8.2f, 100, this); Rectangle enterRect = new Rectangle(x - 50, y, 150, 150); enter = new Enter(enterRect, this); enter.LoadContent(Game.Content); hero.LoadContent(Game.Content); } break; case 'Q': { Rectangle quitRect = new Rectangle(x - 50, y, 150, 150); quit = new Quit(quitRect, this); quit.LoadContent(Game.Content); } break; } } x += 50; i++; } x = 0; i = 0; j++; y += 50; } //Game.Components.Add(new Preview(Game, this)); levelState = LevelState.Active; }
// Load the monster.txt drop file. private void LoadDropFile(bool edit) { var lines = (edit == false) ? File.ReadAllLines(Path.Combine(Settings.DropPath, String.Format("{0}.txt", listBoxMonsters.SelectedItem))) : textBoxDropList.Lines; for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";Gold")) { if (lines[i + 1].StartsWith("1/")) { var workingLine = lines[i + 1].Split(' '); GoldOdds = workingLine[0].Remove(0, 2); Gold = workingLine[2]; break; } else { GoldOdds = "0"; Gold = "0"; } } } string[] Headers = new string[37] { ";Weapons", ";Armours", ";Helmets", ";Necklaces", ";Bracelets", ";Rings", ";Amulets", ";Belts", ";Boots", ";Stones", ";Torches", ";Potions", ";Ores", ";Meat", ";Crafting Materials", ";Scrolls", ";Gems", ";Mount", ";Books", ";Nothing", ";Script", ";Reins", ";Bells", ";Saddle", ";Ribbon", ";Mask", ";Food", ";Hook", ";Float", ";Bait", ";Finder", ";Reel", ";Fish", ";Quest", ";Awakening", ";Pets", ";Transform" }; for (int i = 0; i < Headers.Length; i++) { for (int j = 0; j < lines.Length; j++) { if (lines[j].StartsWith(Headers[i])) { for (int k = j + 1; k < lines.Length; k++) { if (lines[k].StartsWith(";")) { break; } var workingLine = lines[k].Split(' '); if (workingLine.Length < 2) { continue; } var quest = ""; if (workingLine.Length > 2 && workingLine[2] == "Q") { quest = workingLine[2]; } DropItem newDropItem = new DropItem { Odds = workingLine[0], Name = workingLine[1], Quest = quest }; switch (i) { case 0: Weapon.Add(newDropItem); break; case 1: Armour.Add(newDropItem); break; case 2: Helmet.Add(newDropItem); break; case 3: Necklace.Add(newDropItem); break; case 4: Bracelet.Add(newDropItem); break; case 5: Ring.Add(newDropItem); break; case 6: Amulet.Add(newDropItem); break; case 7: Belt.Add(newDropItem); break; case 8: Boot.Add(newDropItem); break; case 9: Stone.Add(newDropItem); break; case 10: Torch.Add(newDropItem); break; case 11: Potion.Add(newDropItem); break; case 12: Ore.Add(newDropItem); break; case 13: Meat.Add(newDropItem); break; case 14: CraftingMaterial.Add(newDropItem); break; case 15: Scrolls.Add(newDropItem); break; case 16: Gem.Add(newDropItem); break; case 17: Mount.Add(newDropItem); break; case 18: Book.Add(newDropItem); break; case 19: Nothing.Add(newDropItem); break; case 20: Script.Add(newDropItem); break; case 21: Reins.Add(newDropItem); break; case 22: Bells.Add(newDropItem); break; case 23: Saddle.Add(newDropItem); break; case 24: Ribbon.Add(newDropItem); break; case 25: Mask.Add(newDropItem); break; case 26: Food.Add(newDropItem); break; case 27: Hook.Add(newDropItem); break; case 28: Float.Add(newDropItem); break; case 29: Bait.Add(newDropItem); break; case 30: Finder.Add(newDropItem); break; case 31: Reel.Add(newDropItem); break; case 32: Fish.Add(newDropItem); break; case 33: Quest.Add(newDropItem); break; case 34: Awakening.Add(newDropItem); break; case 35: Pets.Add(newDropItem); break; case 36: Transform.Add(newDropItem); break; default: break; } } } } } }
public Level Init(LevelDef def, Block blockPrefab, Exit exitPrefab, Coin coinPrefab, Gem gemPrefab, int seed, Color[] colors) { Def = def; PRNG = new PRNG(); BlockPrefab = blockPrefab; ExitPrefab = exitPrefab; CoinPrefab = coinPrefab; GemPrefab = gemPrefab; Colors = PRNG.Shuffle(colors, Def.ColorCount); Blocks = new Block[def.Width, def.Depth + 2]; Blocks.Fill((x, y) => CreateBlock(x, y)); Blocks.GetRow(0).ToList() .FindAll(block => block != null) .ForEach(block => { DestroyBlock(block, false); }); CreateBottom(); Exit = CreateExit(); BlockGroupSystem = GetComponent <BlockGroupSystem>().Init(this); AddGemRandomlyInRows(); Coins = new Coin[def.Width, def.Depth + 2]; Coins.Fill(CreateCoin); Coins.ForEach(item => { if (!item) { return; } DestroyBlock(item.Cell, false); }); return(this); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Gear gear = value as Gear; double opacity = 1; if (parameter != null) { opacity = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture); } if (gear != null) { switch (gear.Rarity) { case Rarity.Normal: return(new SolidColorBrush(Colors.White) { Opacity = opacity }); case Rarity.Magic: return(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8888F1")) { Opacity = opacity }); case Rarity.Rare: return(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F1FF77")) { Opacity = opacity }); case Rarity.Unique: return(new SolidColorBrush(Colors.Orange) { Opacity = opacity }); } } Currency currency = value as Currency; if (currency != null) { return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDF8E")) { Opacity = opacity } } ; Gem gem = value as Gem; if (gem != null) { return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1BA29B")) { Opacity = opacity } } ; Map map = value as Map; if (map != null) { return new SolidColorBrush(Colors.PaleGreen) { Opacity = opacity } } ; throw new NotImplementedException(); }
public void RemoveNeighbor(Gem gem) { neighbors.Remove(gem); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Gear gear = value as Gear; double opacity = 1; if (parameter != null) { opacity = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture); } if (gear != null) { switch (gear.Rarity) { case Rarity.Normal: return(new SolidColorBrush(NormalItemColor) { Opacity = opacity }); case Rarity.Magic: return(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8888F1")) { Opacity = opacity }); case Rarity.Rare: return(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F1FF77")) { Opacity = opacity }); case Rarity.Unique: return(new SolidColorBrush(Colors.Orange) { Opacity = opacity }); } } Currency currency = value as Currency; if (currency != null) { return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDF8E")) { Opacity = opacity } } ; Gem gem = value as Gem; if (gem != null) { return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1BA29B")) { Opacity = opacity } } ; Map map = value as Map; if (map != null) { return new SolidColorBrush(Colors.PaleGreen) { Opacity = opacity } } ; Prophecy prophecy = value as Prophecy; if (prophecy != null) { return new SolidColorBrush(Colors.Purple) { Opacity = 1 } } ; //This was throwing an exception and killing the application - this is not ideal - I will default to normal item color when handle=ing new types return(new SolidColorBrush(NormalItemColor) { Opacity = opacity }); }
public static Currency GenerateForValue(double value) { if (value < 0.0) { throw new InvalidOperationException("Error Generating Currency: Value cannot be less than zero"); } value = Math.Round(value, 2); var currency = new Currency(); if (RandomNumberGenerator.NextDouble() < 0.01) { (value, currency.TenLbGoldBar) = GetRandomQuantity(value, Currency.TenLbGoldBarValue); } if (RandomNumberGenerator.NextDouble() < 0.05) { (value, currency.FiveLbGoldBar) = GetRandomQuantity(value, Currency.FiveLbGoldBarValue); } if (RandomNumberGenerator.NextDouble() < 0.1) { (value, currency.TwoLbGoldBar) = GetRandomQuantity(value, Currency.TwoLbGoldBarValue); } if (RandomNumberGenerator.NextDouble() < 0.25) { (value, currency.OneLbGoldBar) = GetRandomQuantity(value, Currency.OneLbGoldBarValue); } if (RandomNumberGenerator.NextDouble() < 0.05) { (value, currency.TenLbSilverBar) = GetRandomQuantity(value, Currency.TenLbSilverBarValue); } if (RandomNumberGenerator.NextDouble() < 0.1) { (value, currency.FiveLbSilverBar) = GetRandomQuantity(value, Currency.FiveLbSilverBarValue); } if (RandomNumberGenerator.NextDouble() < 0.25) { (value, currency.TwoLbSilverBar) = GetRandomQuantity(value, Currency.TwoLbSilverBarValue); } if (RandomNumberGenerator.NextDouble() < 0.5) { (value, currency.OneLbSilverBar) = GetRandomQuantity(value, Currency.OneLbSilverBarValue); } if (RandomNumberGenerator.NextDouble() < 0.5) { for (int x = 0; x < 5; x++) { var gem = new Gem(); if (gem.Value < value) { value -= gem.Value; currency.Gems.Add(gem); } } } (value, currency.PlatinumCoins) = GetRandomQuantity(value, Currency.PlatinumCoinValue); if (RandomNumberGenerator.NextDouble() < 0.2) { (value, currency.ElectrumCoins) = GetRandomQuantity(value, Currency.ElectrumCoinValue); } (value, currency.GoldCoins) = GetRandomQuantity(value, Currency.GoldCoinValue, true); (value, currency.SilverCoins) = GetRemainingQuantity(value, Currency.SilverCoinValue); (_, currency.CopperCoins) = GetRemainingQuantity(value, Currency.CopperCoinValue); return(currency); }
void OnTriggerEnter(Collider other) { if (other.tag == "LadderTop") { ladderTopReached = true; } if (other.tag == "Ladder") { climbingLadder = true; } if (other.tag == "Minecart") { if (gemPouch.Count != 0) { float scoreObtained = 0; float scoreMultiplier = 1f; int currentGems = gemPouch.Count; if (GameManager.isLocalGame || GameManager.isHost) { other.GetComponent <Minecart>().ComboText(currentGems); } for (int i = 0; i < currentGems; i++) { Gem gem = gemPouch.Dequeue(); scoreObtained += gem.value; currentPouchSize--; scoreMultiplier += scoreIncrementPerGemStored; if (gemPool != null) { gemPool.ReturnObjectToPool(gem.gameObject); } else { gemPool = FindObjectOfType <GemPool>(); if (gemPool != null) { gemPool.ReturnObjectToPool(gem.gameObject); } else { Debug.LogError("Gem Pool Not Found"); } } } if (currentPouchSize < 0) { currentPouchSize = 0; } AddScore(Mathf.CeilToInt(scoreObtained * scoreMultiplier)); UpdateSpeed(); CheckPouchFull(); ChangePouchSize(); } } }
public GameboardElement(Gem gemType) { GemType = gemType; }
public override CraftingResult Craft(Recipe recipe, List <Loot> lootToConvert) { if (recipe == null) { return(ReturnCraftingError("Recipe not set")); } if (recipe.MagicDustRequired > 0) { var magicDust = lootToConvert.Where(i => i is MagicDust).Cast <MagicDust>().FirstOrDefault(); if (magicDust == null || magicDust.Count != recipe.MagicDustRequired) { return(ReturnCraftingError("Invalid amount of Magic Dust")); } } lootToConvert = lootToConvert.Where(i => !(i is MagicDust)).ToList(); var eqs = lootToConvert.Where(i => i is Equipment).Cast <Equipment>().ToList(); if (eqs.Any(i => i.Class == EquipmentClass.Unique)) { return(ReturnCraftingError("Unique items can not crafted")); } if (lootToConvert.Any()) { var sulfCount = GetStackedCount <StackedLoot>(lootToConvert, "Sulfur"); var hoochCount = GetStackedCount <Hooch>(lootToConvert); if (lootToConvert.Count == 2 && recipe.Kind == RecipeKind.Custom) { return(HandleCustomRecipe(lootToConvert)); } else if (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.UnEnchantEquipment) { var eqsToUncraft = Filter <Equipment>(lootToConvert); if (eqsToUncraft.Count != 1 || eqsToUncraft[0].Enchants.Count == 0) { return(ReturnCraftingError("One enchanted piece of equipment is required")); } var eq = eqsToUncraft[0]; var enchs = eqsToUncraft[0].Enchants.Select(i => i.Enchanter).ToList(); enchs.ForEach(i => i.Count = 1); foreach (var ench in eqsToUncraft[0].Enchants) { foreach (var stat in ench.StatKinds) { eq.RemoveMagicStat(stat, ench.StatValue); } } eq.Enchants = new List <Enchant>(); var lootItems = new List <Loot>() { eqsToUncraft[0] }; lootItems.AddRange(enchs); return(ReturnCraftedLoot(lootItems));//deleteCraftedLoot:false } else if (recipe.Kind == RecipeKind.CraftSpecialPotion && lootToConvert.Count == 2) { var healthPotion = lootToConvert.Where(i => i.IsPotion(PotionKind.Health)); var manaPotion = lootToConvert.Where(i => i.IsPotion(PotionKind.Mana)); if (healthPotion != null || manaPotion != null) { var toad = lootToConvert.Where(i => i.IsToadstool()); if (toad != null) { Potion pot = null; if (healthPotion != null) { pot = new SpecialPotion(SpecialPotionKind.Strength, SpecialPotionSize.Small); } else { pot = new SpecialPotion(SpecialPotionKind.Magic, SpecialPotionSize.Small); } return(ReturnCraftedLoot(pot)); } } } else if (recipe.Kind == RecipeKind.RechargeMagicalWeapon) { var equips = lootToConvert.Where(i => i is Weapon wpn0 && wpn0.IsMagician).Cast <Weapon>().ToList(); var equipsCount = equips.Count(); if (equipsCount != 1) { return(ReturnCraftingError("One charge emitting weapon is needed by the Recipe")); } var wpn = equips[0]; //foreach (var wpn in equips) { (wpn.SpellSource as WeaponSpellSource).Restore(); wpn.UpdateMagicWeaponDesc(); } return(ReturnCraftedLoot(wpn, false)); } else if (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.AntidotePotion) { var plants = GetStackedCount <Plant>(lootToConvert); if (plants != 1 || Filter <Plant>(lootToConvert).Where(i => i.Kind == PlantKind.Thistle).Count() != 1) { return(ReturnCraftingError("One thistle is needed by the Recipe")); } var hoohCount = GetStackedCount <Hooch>(lootToConvert); if (hoohCount != 1) { return(ReturnCraftingError("One hooch is needed by the Recipe")); } return(ReturnCraftedLoot(new Potion(PotionKind.Antidote), true)); } else if (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.Pendant) { var cords = GetStackedCount <Cord>(lootToConvert); if (cords == 0) { return(ReturnCraftingError("Cord is needed by the Recipe")); } var amulet = Equipment.CreatePendant(); return(ReturnCraftedLoot(amulet)); } else if (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.EnchantEquipment) { var equips = lootToConvert.Where(i => i is Equipment); var equipsCount = equips.Count(); if (equipsCount == 0) { return(ReturnCraftingError("Equipment is needed by the Recipe")); } if (equipsCount > 1) { return(ReturnCraftingError("One equipment is needed by the Recipe")); } var enchanters = lootToConvert.Where(i => !(i is Equipment)).ToList(); if (enchanters.Any(i => !(i is Enchanter))) { return(ReturnCraftingError("Only enchanting items (gems, claws,...)are alowed by the Recipe")); } var eq = equips.ElementAt(0) as Equipment; if (!eq.Enchantable) { return(ReturnCraftingError("Equipment is not " + Translations.Strings.Enchantable.ToLower())); } var freeSlots = eq.EnchantSlots - eq.Enchants.Count; if (freeSlots < enchanters.Count()) { return(ReturnCraftingError("Too many enchantables added")); } string err; foreach (var ench in enchanters.Cast <Enchanter>()) { if (!ench.ApplyTo(eq, out err)) { return(ReturnCraftingError(InvalidIngredients)); } } return(ReturnCraftedLoot(eq, false)); } else if ((recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.ExplosiveCocktail) && sulfCount > 0 && hoochCount > 0) { if (sulfCount != hoochCount) { return(ReturnCraftingError("Number of ingradients must be the same (except for Magic Dust)")); } return(ReturnCraftedLoot(new ProjectileFightItem(FightItemKind.ExplosiveCocktail, null))); } var allGems = lootToConvert.All(i => i is Gem); if ((recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.ThreeGems) && allGems && lootToConvert.Count == 1 && GetStackedCount <Gem>(lootToConvert) == 3) { return(HandleAllGems(lootToConvert)); } var hpCount = lootToConvert.Where(i => i.IsPotion(PotionKind.Health)).Count(); var mpCount = lootToConvert.Where(i => i.IsPotion(PotionKind.Mana)).Count(); var toadstools = lootToConvert.Where(i => i.IsToadstool()).ToList(); var toadstoolsCount = GetStackedCount <StackedLoot>(toadstools); if ((recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.TransformPotion) && (lootToConvert.Count == 2 && toadstoolsCount == 1 && (hpCount == 1 || mpCount == 1))) { //if ((lootToConvert[0] as Potion).Count == 1)//TODO allow many conv (use many M Dust) var potion = lootToConvert.Where(i => i.IsPotion()).Single(); { if (potion.AsPotion().Kind == PotionKind.Mana) { if (toadstools.Single().AsToadstool().MushroomKind == MushroomKind.RedToadstool) { return(ReturnCraftedLoot(new Potion(PotionKind.Health))); } } else { if (toadstools.Single().AsToadstool().MushroomKind == MushroomKind.BlueToadstool) { return(ReturnCraftedLoot(new Potion(PotionKind.Mana))); } } } } if (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.Toadstools2Potion) { var allToadstool = lootToConvert.All(i => i.IsToadstool()) && GetToadstoolsCount(lootToConvert) == 1; if (allToadstool) { //var toadstools = lootToConvert.Cast<Mushroom>().GroupBy(i => i.MushroomKind); //if (toadstools[0] as Mushroom)//same kind? { var toadstool = lootToConvert[0].AsToadstool(); if (toadstool != null && toadstool.Count == 3) { Potion potion = null; if (toadstool.MushroomKind == MushroomKind.BlueToadstool) { potion = new Potion(PotionKind.Mana); } else { potion = new Potion(PotionKind.Health); } return(ReturnCraftedLoot(potion)); } } } } } if (lootToConvert.Count == 1) { var srcEq = lootToConvert[0] as Equipment; if (srcEq != null && (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.OneEq)) { return(CraftOneEq(srcEq)); } else if (lootToConvert[0] is Gem && (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.TransformGem)) { var srcGem = lootToConvert[0] as Gem; var destKind = RandHelper.GetRandomEnumValue <GemKind>(new GemKind[] { srcGem.GemKind }); var destGem = new Gem(destKind); destGem.EnchanterSize = srcGem.EnchanterSize; destGem.SetProps(); return(ReturnCraftedLoot(destGem)); } } else if (lootToConvert.Count == 2 && eqs.Count == 2 && (recipe.Kind == RecipeKind.Custom || recipe.Kind == RecipeKind.TwoEq)) { return(CraftTwoEq(eqs)); } else if (recipe.Kind == RecipeKind.Custom && eqs.Count == 1) { if (eqs[0].EquipmentKind == EquipmentKind.Weapon) { var spsCount = GetStackedCount <SpecialPotion>(lootToConvert); if (spsCount == lootToConvert.Count - 1 && spsCount <= 2) { return(ReturnStealingEq(eqs, Filter <SpecialPotion>(lootToConvert))); } } } else if (recipe.Kind == RecipeKind.Custom && lootToConvert.Count == 2) { //turn one Toadstool kind into other (using Potion) var toadstoolsCount = GetToadstoolsCount(lootToConvert); var potions = lootToConvert.Where(i => i.IsPotion()).ToList(); if (toadstoolsCount == 1 && potions.Count == 1) { var tk = GetToadstools(lootToConvert)[0].MushroomKind; var pk = (potions[0].AsPotion()).Kind; if (tk == MushroomKind.RedToadstool && pk == PotionKind.Mana) { return(ReturnCraftedLoot(new Mushroom(MushroomKind.BlueToadstool))); } else if (tk == MushroomKind.BlueToadstool && pk == PotionKind.Health) { return(ReturnCraftedLoot(new Mushroom(MushroomKind.RedToadstool))); } } } return(ReturnCraftingError(InvalidIngredients)); }
public IEnumerator PowerAttack() { float pulseTime = GameManager.Instance.Definitions.PulseTime; ResetPowerCharge(); yield return(StartCoroutine(Scale(pulseTime))); switch (_power._type) { case LevelData.Power.Types.DAMAGE: StartCoroutine(Effects.Pulse(GameManager.Instance.Definitions.PulseFlyTime, GameManager.Instance.Definitions.PulseFlyWaitTime, GameManager.Instance.Definitions.PulseHitTime, null, GameManager.Instance.Definitions.ParticlePowerDamageFly, GameManager.Instance.Definitions.ParticlePowerDamage, transform.position, GameManager.Instance.HUD.Health.GetBarCenter(), true)); yield return(new WaitForSeconds(GameManager.Instance.Definitions.PulseFlyWaitTime)); GameManager.Instance.HUD.Health.Add(-((int)(ActionPoints * _power._f + 0.5f) + _power._i)); yield return(new WaitForSeconds(GameManager.Instance.Definitions.PulseHitTime)); break; case LevelData.Power.Types.DAMAGE_FIGURES_SELF: case LevelData.Power.Types.DAMAGE_FIGURES_TARGET: { bool anyDead = false; int count = _hero ? GameManager.Instance.EnemyManager.GetEnemiesCount():GameManager.Instance.HeroManager.GetHeroesCount(); for (int i = 0; i < count; i++) { Figure figure = _hero ? GameManager.Instance.EnemyManager.GetEnemyAtIndex(i) : GameManager.Instance.HeroManager.GetHeroAtIndex(i); if (figure && !figure.GetGemScript().IsDead()) { yield return(StartCoroutine(Effects.Pulse(GameManager.Instance.Definitions.PulseFlyTime, GameManager.Instance.Definitions.PulseFlyWaitTime, GameManager.Instance.Definitions.PulseHitTime, null, GameManager.Instance.Definitions.ParticlePowerDamageFigureFly, GameManager.Instance.Definitions.ParticlePowerDamageFigure, transform.position, figure.transform.position, true))); int points = _power._type == LevelData.Power.Types.DAMAGE_FIGURES_SELF ? ActionPoints : figure.ActionPoints; figure.ActionPoints -= (int)(points * _power._f + 0.5f) + _power._i; anyDead |= figure.GetGemScript().IsDead(); } } if (anyDead) { yield return(StartCoroutine(Puzzle.CollapseField(Directions.Down, null))); } break; } case LevelData.Power.Types.ABSORB_GEMS: { bool any = false; for (int i = 0; i < _power._i; i++) { Vector2i gemPos = GameManager.Instance.Grid.FindNearest(_gem.GetGridPosition(), _power._et); if (gemPos.x == -1) { break; } StartCoroutine(Effects.Pulse(GameManager.Instance.Definitions.PulseFlyTime, GameManager.Instance.Definitions.PulseFlyWaitTime, GameManager.Instance.Definitions.PulseHitTime, GameManager.Instance.Definitions.ParticlePowerAbsorbHealthGem, GameManager.Instance.Definitions.ParticlePowerAbsorbHealthFly, GameManager.Instance.Definitions.ParticlePowerAbsorbHealth, GameManager.Instance.Grid.Get(gemPos).transform.position, transform.position, true)); yield return(new WaitForSeconds(pulseTime)); Gem gem = GameManager.Instance.Grid.Get(gemPos); gem.SetupFadeOut(pulseTime); yield return(StartCoroutine(Scale(pulseTime))); ActionPoints += _power._i2; gem.SetGemType(GameManager.Instance.LevelData.GetEmptyGemType()); gem.TweenColor(0, new Color(0, 0, 0, 0), Tweener.Method.EaseIn); gem.Die(); any = true; } if (any) { yield return(StartCoroutine(Puzzle.CollapseField(Directions.Down, null))); } break; } case LevelData.Power.Types.COLLECT_GEMS: { Vector2i gridPos; for (int j = 0; j < 4; j++) { for (int i = 1; i <= _power._i; i++) { gridPos = _gem.GetGridPosition() + Vector2i.Directions[j] * i; if (Grid.Valid(gridPos)) { Gem gem = GameManager.Instance.Grid.Get(gridPos); LevelData.GemEffectType et = GameManager.Instance.LevelData.GetGemTypeInfo(gem.GetGemType())._effectType; if (_hero && et == LevelData.GemEffectType.ET_ENEMY || !_hero && et == LevelData.GemEffectType.ET_HERO) { Figure figure = _hero ? GameManager.Instance.EnemyManager.GetAtPosition(gridPos) : GameManager.Instance.HeroManager.GetAtPosition(gridPos); figure.ActionPoints -= (int)((float)ActionPoints * _power._f) + _power._i2; StartCoroutine(Effects.Sparkle(pulseTime, GameManager.Instance.Definitions.ParticlePowerCollectGemEnemy, gem.transform.position)); } else if (et != LevelData.GemEffectType.ET_HERO) { gem.Die(); StartCoroutine(Effects.Sparkle(pulseTime, GameManager.Instance.Definitions.ParticlePowerCollectGem, gem.transform.position)); } } } } yield return(new WaitForSeconds(pulseTime)); yield return(StartCoroutine(Puzzle.CollapseField(Directions.Down, null))); break; } case LevelData.Power.Types.TRANSFORM_RANDOM_GEMS: { Vector2i pos; Coroutine c = null; LevelData.GemTypeInfo gti = GameManager.Instance.LevelData.GetGemTypeInfo(_power._i2); int excludeColor = gti._colored ? gti._effectData : -1; for (int j = 0; j < _power._i; j++) { pos = GameManager.Instance.Grid.FindValidPosition(Grid.RandomGridPosition(), LevelData.GetBasicGemTypes(), excludeColor); c = StartCoroutine(GameManager.Instance.Grid.Get(pos).ChangeGemType(_power._i2, GameManager.Instance.Definitions.ParticlePowerTransformGem)); yield return(new WaitForSeconds(GameManager.Instance.Definitions.TransformGemWaitTime)); } yield return(c); yield return(StartCoroutine(Puzzle.CollapseField(Directions.Down, null))); break; } } }
public void HoldItem(Gem item) { this.heldItem = item; }
public void SetGem(Gem newGem) { _gem = newGem; }
// Both ways public void CreateRepel(Gem gem) { PhotonView p = gem.GetComponent <PhotonView>(); photonView.RPC("CreateRepel_RPC", PhotonTargets.Others, p.instantiationId); }
public void OnEnable() { trg = target as Gem; id = trg.id; }
void Update() { // State machine switch (state) { case PlayerState.Free: Movement(moveSpeed); FindInteractables(); BuildingTracks(); ThrowPickAxe(); if (minecart) { state = PlayerState.Minecart; } else if (gemHolding) { state = PlayerState.Carry; } break; case PlayerState.Minecart: BuildingTracks(); ThrowPickAxe(); if (minecart && (minecart.transform.position - transform.position).magnitude > 5f) { minecart = null; } if (!minecart) { state = PlayerState.Free; break; } if (minecart.gems >= 3) { audioSource.PlayOneShot(railPurchased); } while (minecart.gems >= 3) { minecart.gems -= 3; tracksHeld += 4; } animator.SetBool("isJumping", false); animator.SetBool("isRunning", false); if (minecart.velocity.x != 0) { spriteRenderer.flipX = minecart.velocity.x < 0; } minecart.Movement(); Vector3 minecartPos = minecart.transform.position; transform.position = new Vector3(minecartPos.x, minecartPos.y + 0.5f, minecartPos.z); if (Input.GetKeyDown(KeyCode.Space)) { velocity.y = jumpVelocity + Mathf.Clamp(minecart.velocity.y, 0, 3); minecart = null; } break; case PlayerState.Carry: Movement(carryMoveSpeed); BuildingTracks(); if (gemHolding.collected || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.Space)) { gemHolding = null; } if (!gemHolding) { state = PlayerState.Free; break; } gemHolding.transform.position = transform.position; gemHolding.transform.rotation = Quaternion.AngleAxis(90, Vector3.forward); break; case PlayerState.Dead: Movement(0f, false); break; } if (displayInterAction) { UIObject.actionStr = closestInteractable.action; displayInterAction = false; } else { UIObject.actionStr = ""; } }