private String GetFoodStepAudioID() { MovingEntity movingEntity = (MovingEntity)MyController; Grid grid = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot = grid.GetSlot(movingEntity.Position); String text = null; ETerrainType terrainType = slot.TerrainType; if ((terrainType & ETerrainType.WATER) > ETerrainType.NONE) { text = m_foodstepSoundWater; } else if ((terrainType & ETerrainType.ROUGH) > ETerrainType.NONE) { text = m_foodstepSoundRough; } else if ((terrainType & ETerrainType.FOREST) > ETerrainType.NONE) { text = m_foodstepSoundForest; } else if ((terrainType & ETerrainType.LAVA) > ETerrainType.NONE) { text = m_foodstepSoundLava; } if (String.IsNullOrEmpty(text)) { text = "Move_Party"; } return(text); }
internal Int32 DistSortAsc(GridSlot a, GridSlot b) { Single num = Position.DistanceSquared(a.Position, m_owner.Position); Single value = Position.DistanceSquared(b.Position, m_owner.Position); return(num.CompareTo(value)); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { m_grid = LegacyLogic.Instance.MapLoader.Grid; Party party = LegacyLogic.Instance.WorldManager.Party; GridSlot gridSlot = CheckSlot(party.Position); if (gridSlot == null) { gridSlot = FindTargetSlot(p_monster.Position); } if (gridSlot != null) { if (gridSlot.Position != party.Position) { MoveParty(gridSlot); } SpawnCagePiece(gridSlot.Position + EDirection.WEST, true); SpawnCagePiece(gridSlot.Position + EDirection.NORTH, false); SpawnCagePiece(gridSlot.Position + EDirection.EAST, false); SpawnCagePiece(gridSlot.Position + EDirection.SOUTH, false); } else { LegacyLogger.Log("FOUND no slot :("); } }
protected virtual void SetPosition(MovingEntity entity) { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(entity.Position); transform.localPosition = Helper.SlotLocalPosition(slot.Position, slot.Height); transform.localRotation = Helper.GridDirectionToQuaternion(entity.Direction); }
public void SpawnAtSlot(GridSlot slot, Champion champion) { Champion c = Instantiate(champion, slot.transform); c.Slot = slot; slot.Champion = c; }
protected void Drag(Monster p_monster, SpellEventArgs p_result) { if (p_monster.CurrentHealth <= 0) { return; } if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.LARGE) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.BOSS) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.STATIC_OBJECT)) { return; } Party party = LegacyLogic.Instance.WorldManager.Party; Grid grid = LegacyLogic.Instance.MapLoader.Grid; EDirection direction = EDirectionFunctions.GetDirection(p_monster.Position, party.Position); Int32 num = (Int32)Position.Distance(p_monster.Position, party.Position) - 1; for (Int32 i = 0; i < num; i++) { if (!grid.CanMoveEntity(p_monster, direction)) { break; } Position p_pos = p_monster.Position + direction; GridSlot slot = grid.GetSlot(p_monster.Position); if (grid.GetSlot(p_pos).AddEntity(p_monster)) { slot.RemoveEntity(p_monster); } } if (Position.Distance(p_monster.Position, party.Position) > 1f) { LegacyLogic.Instance.WorldManager.Party.SelectedMonster = null; } }
protected override void DoExecute() { if (m_targetObj != null) { GridSlot slot = Grid.GetSlot(m_targetObj.Position); if (slot.TerrainType == m_oldTerrain) { slot.TerrainType = m_newTerrain; } } else { Position p_pos = new Position(0, 0); for (Int32 i = 0; i < Grid.Width; i++) { for (Int32 j = 0; j < Grid.Height; j++) { p_pos.X = i; p_pos.Y = j; GridSlot slot2 = Grid.GetSlot(p_pos); if (slot2.TerrainType == m_oldTerrain) { slot2.TerrainType = m_newTerrain; } } } } FinishExecution(); }
public override Boolean CheckSpellConditions(Character p_sorcerer) { if (SpellType == ECharacterSpell.WARFARE_CRIPPLING_TRAP) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot = grid.GetSlot(LegacyLogic.Instance.WorldManager.Party.Position); foreach (MovingEntity movingEntity in slot.Entities) { Summon summon = movingEntity as Summon; if (summon != null && summon.StaticID == 6) { return(false); } } return(true); } if (SpellType == ECharacterSpell.SPELL_PRIME_TIME_STOP || SpellType == ECharacterSpell.WARFARE_CRIPPLING_TRAP) { return(true); } Party party = LegacyLogic.Instance.WorldManager.Party; Grid grid2 = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot2 = grid2.GetSlot(party.Position + party.Direction); GridSlot slot3 = grid2.GetSlot(LegacyLogic.Instance.WorldManager.Party.Position); return(slot2 != null && slot2.IsPassable(m_testEntity, false, true) && slot3.GetTransition(party.Direction).NextState != EGridTransitionType.CLOSED); }
public void OnEnemyDied(GridSlot slot, EnemyScript enemy) { slot.InstanciateEnemyDelayed(enemyRespawnDelay, enemies[Mathf.Min(slot.currentDifficulty, enemies.Count - 1)]); onEnemyDied.Invoke(); }
public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic) { if (p_monster.DistanceToParty > 1f) { return; } Party party = LegacyLogic.Instance.WorldManager.Party; Grid grid = LegacyLogic.Instance.MapLoader.Grid; Position position = party.Position; Position position2 = position + EDirectionFunctions.GetLineOfSightDirection(p_monster.Position, party.Position); GridSlot slot = grid.GetSlot(position2); if (slot == null) { return; } party.IsPushed = true; if (!slot.HasEntities && grid.CanMoveEntity(party, p_monster.Direction)) { GridSlot slot2 = grid.GetSlot(position); slot2.RemoveEntity(party); party.Position = position2; grid.GetSlot(position2).AddEntity(party); MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position, position2); LegacyLogic.Instance.EventManager.InvokeEvent(party, EEventType.MOVE_ENTITY, p_eventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); LegacyLogic.Instance.ActionLog.PushEntry(p_args); } else { party.IsPushed = false; } }
internal override Boolean CalculatePath(GridSlot p_start, GridSlot p_target, List <GridSlot> p_pathBuffer) { if (!p_target.CheckForSummons()) { AStarHelper <GridSlot> .Calculate(p_start, p_target, GameConfig.MaxSteps, m_owner, false, true, true, p_pathBuffer); return(p_pathBuffer.Count > 0); } List <GridSlot> list; if (Position.Distance(p_target.Position, LegacyLogic.Instance.WorldManager.Party.Position) <= 1.1f) { list = GetMeleeTargets(LegacyLogic.Instance.MapLoader.Grid, LegacyLogic.Instance.WorldManager.Party); } else { list = GetRangedTargets(LegacyLogic.Instance.MapLoader.Grid, LegacyLogic.Instance.WorldManager.Party); } if (list.FindAll(new Predicate <GridSlot>(FindSlotsWithSummons)).Count == list.Count) { return(base.CalculatePath(p_start, p_target, p_pathBuffer)); } list.RemoveAll(new Predicate <GridSlot>(FindSlotsWithSummons)); list.Sort(new Comparison <GridSlot>(DistSortAsc)); AStarHelper <GridSlot> .Calculate(p_start, list[0], GameConfig.MaxSteps, m_owner, false, true, true, p_pathBuffer); list.Sort(new Comparison <GridSlot>(DistSortAsc)); return(p_pathBuffer.Count > 0); }
public override Boolean CanDoAction(Command p_command) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; Party party = LegacyLogic.Instance.WorldManager.Party; Monster monster = LegacyLogic.Instance.WorldManager.Party.SelectedMonster; if (monster == null || !grid.LineOfSight(party.Position, monster.Position, true)) { monster = Party.GetRandomMonsterInLineOfSight(true); } if (monster != null) { GridSlot slot = grid.GetSlot(monster.Position); Boolean flag = false; foreach (MovingEntity movingEntity in slot.Entities) { Monster monster2 = movingEntity as Monster; if (monster2 != null && monster2.IsAttackable) { flag = true; break; } } Int32 p_range = (Int32)Position.Distance(party.Position, monster.Position); Boolean flag2 = Character.InRangedAttackRange(p_range) && flag; if (flag2) { LegacyLogic.Instance.WorldManager.HintManager.TriggerHint(EHintType.RANGED); } return(flag2); } return(false); }
public override void HandleAttackResults(List <AttackResult> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic, Boolean p_isRanged) { AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); p_monster.AbilityHandler.AddEntry(m_executionPhase, p_args); GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position); List <Monster> list = new List <Monster>(); Party party = LegacyLogic.Instance.WorldManager.Party; IList <MovingEntity> entities = slot.Entities; for (Int32 i = 0; i < entities.Count; i++) { if (entities[i] != null && entities[i] != p_monster && entities[i] is Monster) { list.Add((Monster)entities[i]); } } Int32 num = (Int32)m_staticData.GetValues(m_level)[0]; for (Int32 j = 0; j < list.Count; j++) { list[j].ChangeHP(-num, null); } if (Position.Distance(party.Position, p_monster.Position) <= 1f) { for (Int32 k = 0; k < party.Members.Length; k++) { if (party.Members[k] != null && !party.Members[k].ConditionHandler.HasCondition(ECondition.DEAD)) { party.Members[k].ChangeHP(-num, p_monster); } } } LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); }
public override void CheckVisibility(Boolean skipAnimation) { base.CheckVisibility(skipAnimation); Single num = 0f; if (MyController != null) { Monster monster = (Monster)MyController; Party party = LegacyLogic.Instance.WorldManager.Party; if (party != null && party.HasDangerSense()) { Int32 monsterVisibilityRangeWithDangerSense = ConfigManager.Instance.Game.MonsterVisibilityRangeWithDangerSense; Grid grid = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot = grid.GetSlot(monster.Position); GridSlot slot2 = grid.GetSlot(party.Position); Int32 num2 = AStarHelper <GridSlot> .Calculate(slot, slot2, monsterVisibilityRangeWithDangerSense, null, false, null); if (num2 > 0) { num = 1f; } } else if (party != null && monster.IsAggro && 1f >= Position.DistanceSquared(monster.Position, party.Position)) { num = 1f; } } if (num == 0f) { TooltipManager.Instance.Hide(this); } collider.enabled = (num > 0f); TweenAlpha.Begin(gameObject, (!skipAnimation) ? 1 : 0, num); }
public IEnumerator MoveToSlot(Team team, Team team2, GridSlot slot, MapNode[] path) { // coroutines seem to take a little time to start, and since they run parallel, moving doesn't start yet. team.ActiveSoldier.moving = true; GameplayManager.m.StartCoroutine(team.ActiveSoldier.MoveToSlot(slot, path)); // enemies in overwatch fire at player's soldier when it moves. float t = Time.time; float r = 0.5f; while (team.ActiveSoldier.moving) { if (Time.time > t) { t = Time.time + r; yield return(GameplayManager.m.StartCoroutine(HandleOverwatchWithoutFog(team.ActiveSoldier, team2))); } else { yield return(null); } } //Debug.Log("moving done"); yield return(team.ActiveSoldier.CinematicsDone()); team.ActiveSoldier.HandleCover(); //Debug.Log("cover check"); SwapSoldierIfNoTurns(team); }
public override Boolean CheckSpellPreconditions(Monster p_monster) { try { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position); IList <MovingEntity> entities = slot.Entities; for (Int32 i = 0; i < entities.Count; i++) { if (entities[i] is Monster) { Monster monster = (Monster)entities[i]; List <MonsterBuff> buffList = monster.BuffHandler.BuffList; for (Int32 j = 0; j < buffList.Count; j++) { if (buffList[j].IsDebuff && (buffList[j].StaticID != 3 || monster != p_monster)) { return(true); } } } } } catch (Exception ex) { LegacyLogger.LogError(ex.Message); } return(false); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position); IList <MovingEntity> entities = slot.Entities; for (Int32 i = 0; i < entities.Count; i++) { if (entities[i] is Monster) { Monster monster = (Monster)entities[i]; List <MonsterBuff> buffList = monster.BuffHandler.BuffList; if (buffList != null && buffList.Count != 0) { List <MonsterBuff> list = new List <MonsterBuff>(); for (Int32 j = 0; j < buffList.Count; j++) { if (buffList[j].IsDebuff && (buffList[j].StaticID != 3 || monster != p_monster)) { list.Add(buffList[j]); } } if (list.Count > 0) { Int32 index = Random.Range(0, list.Count); monster.BuffHandler.RemoveBuff(list[index]); } } } } }
private Boolean TryOpenDoor(GridSlot p_slot, EDirection p_dir) { List <InteractiveObject> doors = p_slot.GetDoors(); for (Int32 i = 0; i < doors.Count; i++) { Door door = (Door)doors[i]; if (door.Location == p_dir && door.State == EInteractiveObjectState.DOOR_CLOSED && door.Commands.Count > 0) { door.Execute(LegacyLogic.Instance.MapLoader.Grid); door.Update(); return(true); } } GridSlot neighborSlot = p_slot.GetNeighborSlot(LegacyLogic.Instance.MapLoader.Grid, p_dir); doors = neighborSlot.GetDoors(); for (Int32 j = 0; j < doors.Count; j++) { Door door2 = (Door)doors[j]; if (door2.Location == EDirectionFunctions.GetOppositeDir(p_dir) && door2.State == EInteractiveObjectState.DOOR_CLOSED && door2.Commands.Count > 0) { door2.Execute(LegacyLogic.Instance.MapLoader.Grid); door2.Update(); return(true); } } return(false); }
//public ItemInfo info; public void OnBeginDrag(PointerEventData eventData) { lastSlot = transform.parent.GetComponent <GridSlot>(); if (gameObject.name.StartsWith("KEY_OBJECT")) { Desk.d.ActivateKeyDrawer(); transform.SetParent(Desk.d.transform, false); AudioManager.am.PlayRandom(AudioManager.am.keysDrag); } else if (gameObject.name.StartsWith("MONEY_OBJECT")) { Desk.d.ActivateMoneyDrawer(); AudioManager.am.PlayRandom(AudioManager.am.basicDrag); transform.SetParent(Desk.d.transform, false); } startPos = transform.position; // ici on peut actualiser les stats //transform.SetParent(lastSlot.transform.parent,true); transform.position = eventData.position; if (lastSlot != null) { //if (lastSlot.localisation != string.Empty && item is Equipement) { // item.removeStats(); } } }
// Start is called before the first frame update void Start()//build ui { board = new GameObject[gridSize]; //add all tiles to grid for (int i = 0; i < gridSize; i++) { //Instantiate(Object original, Transform parent); grid = Instantiate(gridSlot, transform.parent.GetChild(1).GetChild(0)); //slot it into the second child of the canvas, the grid, dont adjust scale grid.gameObject.GetComponent <GridSlot>().controller = this.gameObject; //tell the tile that this is the controller board[i] = grid.gameObject; } //Add Selector Tiles GameObject zinc = Instantiate(zincIcon, transform.parent.GetChild(1).GetChild(1)); //slot it into the third child of the canvas, the tool panel, dont adjust scale zinc.gameObject.GetComponent <SelectorIcon>().controller = this.gameObject; //tell the selector that this is the controller GameObject copper = Instantiate(copperIcon, transform.parent.GetChild(1).GetChild(1)); //slot it into the third child of the canvas, the tool panel, dont adjust scale copper.gameObject.GetComponent <SelectorIcon>().controller = this.gameObject; //Add Craft Window GameObject craft = Instantiate(craftTile, transform.parent.GetChild(1).GetChild(2)); //output slot craft.gameObject.GetComponent <CraftTile>().controller = this.gameObject; //tell the tile that this is the controller GetComponent <Controller>().board = board; //continuity }
private GridSlot CheckSlot(Position position) { GridSlot slot = m_grid.GetSlot(position); GridSlot slot2 = m_grid.GetSlot(position + EDirection.WEST); if (slot2 == null || (slot2.TerrainType & ETerrainType.PASSABLE) != ETerrainType.PASSABLE || slot2.Entities.Count > 0) { return(null); } slot2 = m_grid.GetSlot(position + EDirection.EAST); if (slot2 == null || (slot2.TerrainType & ETerrainType.PASSABLE) != ETerrainType.PASSABLE || slot2.Entities.Count > 0) { return(null); } slot2 = m_grid.GetSlot(position + EDirection.NORTH); if (slot2 == null || (slot2.TerrainType & ETerrainType.PASSABLE) != ETerrainType.PASSABLE || slot2.Entities.Count > 0) { return(null); } slot2 = m_grid.GetSlot(position + EDirection.SOUTH); if (slot2 == null || (slot2.TerrainType & ETerrainType.PASSABLE) != ETerrainType.PASSABLE || slot2.Entities.Count > 0) { return(null); } return(slot); }
protected override AttackResult DoAttackMonster(Character p_attacker, Monster p_target, Single p_magicPower) { Int32 num = 1; if (p_target != null) { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_target.Position); if (slot != null) { num = slot.Entities.Count; } Single criticalMagicHitChance = p_attacker.FightValues.CriticalMagicHitChance; Single magicalCriticalDamageMod = p_attacker.FightValues.MagicalCriticalDamageMod; EDamageType edamageType = ESkillIDToEDamageType(m_staticData.SkillID); List <Damage> list = new List <Damage>(); for (Int32 i = 0; i < m_staticData.Damage.Length; i++) { DamageData p_data = DamageData.Scale(m_staticData.Damage[i], p_magicPower); Damage item = Damage.Create(p_data, magicalCriticalDamageMod); if (item.Type == edamageType) { item.IgnoreResistance = p_attacker.SkillHandler.GetResistanceIgnoreValue(m_staticData.SkillID); } item.Value *= num; list.Add(item); } Attack p_attack = new Attack(0f, criticalMagicHitChance, list); return(p_target.CombatHandler.AttackMonster(p_attacker, p_attack, false, true, edamageType, true, p_attacker.SkillHandler.GetResistanceIgnoreValue(m_staticData.SkillID))); } return(null); }
public override List <GridSlot> GetRangedTargets(Grid p_grid, Party p_party) { List <GridSlot> list = new List <GridSlot>(); GridSlot slot = p_grid.GetSlot(p_party.Position); GridSlot slot2 = p_grid.GetSlot(new Position(slot.Position.X, slot.Position.Y + (Position.Up * m_owner.StaticData.AttackRange).Y)); if (slot2.IsPassable(m_owner, false) && p_grid.LineOfSight(slot2.Position, p_party.Position, true)) { list.Add(slot2); } GridSlot slot3 = p_grid.GetSlot(new Position(slot.Position.X + (Position.Right * m_owner.StaticData.AttackRange).X, slot.Position.Y)); if (slot3.IsPassable(m_owner, false) && p_grid.LineOfSight(slot3.Position, p_party.Position, true)) { list.Add(slot3); } GridSlot slot4 = p_grid.GetSlot(new Position(slot.Position.X, slot.Position.Y + (Position.Down * m_owner.StaticData.AttackRange).Y)); if (slot4.IsPassable(m_owner, false) && p_grid.LineOfSight(slot4.Position, p_party.Position, true)) { list.Add(slot4); } GridSlot slot5 = p_grid.GetSlot(new Position(slot.Position.X + (Position.Left * m_owner.StaticData.AttackRange).X, slot.Position.Y)); if (slot5.IsPassable(m_owner, false) && p_grid.LineOfSight(slot5.Position, p_party.Position, true)) { list.Add(slot5); } return(list); }
public override Int32 GetTargets(List <Object> buffer) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; Party party = LegacyLogic.Instance.WorldManager.Party; Position position = party.Position; EDirection direction = party.Direction; Int32 rangedAttackRange = party.SelectedCharacter.FightValues.RangedAttackRange; Monster monster = party.SelectedMonster; if (monster == null || !grid.LineOfSight(party.Position, monster.Position, true)) { monster = grid.GetRandomMonsterInDirection(position, direction, rangedAttackRange); } if (monster != null && !monster.IsAttackable) { GridSlot slot = grid.GetSlot(monster.Position); foreach (MovingEntity movingEntity in slot.Entities) { Monster monster2 = movingEntity as Monster; if (monster2 != null && monster2.IsAttackable) { monster = monster2; break; } } } if (monster != null) { buffer.Add(monster); return(1); } return(0); }
public void OnEndDrag(PointerEventData eventData) { RaycastHit hit; transform.position = startPos; if (transform.parent.GetComponent <GridSlot>() != null) { // je suis sur un slot valide. } else if (GhuestManager.gm.currentEvent == GhuestEvent.CHECK_IN && GhuestManager.gm.checkInStep == CheckInStep.GET_MONEY && Desk.d.drawers.boundsDrawers.Contains(Input.mousePosition - Desk.d.drawers.transform.position)) { GhuestManager.gm.ProceedCheckIn(); Destroy(this.gameObject); } else if (Desk.d.drawers.boundsDrawers.Contains(Input.mousePosition - Desk.d.drawers.transform.position) && isCollectible) { Desk.d.drawers.AddCollectibleItem(this.gameObject); } else { transform.SetParent(lastSlot.transform, false); Desk.d.drawers.Activate(0); } GridSlot gridSlot = transform.parent.GetComponent <GridSlot>(); if (gridSlot != null) { // if (gridSlot.localisation !=string.Empty && item is Equipement) { // item.applyStats(); } } if (gameObject.name.StartsWith("KEY_OBJECT")) { AudioManager.am.PlayRandom(AudioManager.am.keysDrop); } else if (gameObject.name.StartsWith("MONEY_OBJECT")) { AudioManager.am.PlayRandom(AudioManager.am.basicDrop); } // if OnGround tombe au sol. // if New case : deplace // else Retour case depart. // ici on peut actualiser les stats // On pourrait faire un RayCastAll pour vérifier ce qui est en dessous et faire des trucs // plus précis // if OnGround, Conversion. // if On // motherObject.popOnGround() }
public void SelectSlot(GridSlot slot) { if (slot != null) { selected_grid_slot = slot; selected_grid_slot.GetSpriteRenderer().sprite = grid_slot_pressed_sprite; } }
protected override void DoExecute() { GridSlot slot = Grid.GetSlot(new Position(m_gridX, m_gridY)); slot.Height += m_delta; LegacyLogic.Instance.EventManager.InvokeEvent(slot, EEventType.SLOT_HEIGHT_CHANGED, null); FinishExecution(); }
private static Boolean InMoveRange(Grid grid, Position start, Position target, Int32 range) { GridSlot slot = grid.GetSlot(start); GridSlot slot2 = grid.GetSlot(target); Int32 num = AStarHelper <GridSlot> .Calculate(slot, slot2, range, null, false, null); return(num > 0); }
private IEnumerator Cinematics_StandAndTurn(GridSlot hitSlot) { // Note: if crouching, stand animation // Note: then turn to target first. // Note(2): add slow turn or smth transform.forward = (hitSlot.transform.position - transform.position).normalized; yield return(new WaitForSeconds(0.5f)); }
public void SpawnGem(Gem gemToSpawn, GridSlot initialSlot) { Vector3 initialPostion = initialSlot.transform.position; initialPostion.y = _gemSpawnPosition.position.y; var gemType = _gemTypes[Random.Range(0, _gemTypes.Length)]; gemToSpawn.Setup(this, initialPostion, gemType, initialSlot); }
/// <summary> /// Creates the grid for use by the level. Makes a new GridSlot for each spot in the grid. /// </summary> public void CreateGrid(GridType gridType) { GridOrigin = Vector2.Zero; Grid = new GridSlot[HORIZONTAL_GRID_SPACES, VERTICAL_GRID_SPACES]; for (int i = 0; i < HORIZONTAL_GRID_SPACES; i++) { for (int j = 0; j < VERTICAL_GRID_SPACES; j++) { Vector2 SlotPosition = new Vector2(i * GRID_WIDTH, j * GRID_HEIGHT); Vector2 PositionInGrid = new Vector2(i, j); Grid[i,j] = new GridSlot(SlotPosition, PositionInGrid); } } this.gType = gridType; }