public ItemDropManager(E_GameModeType gameModeType, int defaultTier) { this.gameModeType = gameModeType; this.defaultTier = defaultTier; { groupedTables = new Dictionary<E_CousumableGroupType, HashSet<ConsumableEntity>>(); var table = TableLoader.GetTable<ConsumableEntity>(); foreach (var entity in table.Values) { if (!groupedTables.ContainsKey(entity.ConsumableGroupType)) { groupedTables.Add(entity.ConsumableGroupType, new HashSet<ConsumableEntity>()); } groupedTables[entity.ConsumableGroupType].Add(entity); } } { var table = TableLoader.GetTable<ConsumableGroupDrop>(); var groupTable = table.GetMany(gameModeType); groupDart = new Dart<E_CousumableGroupType>(); foreach (var entity in groupTable) { groupDart.Add(entity.Value.DropChance, entity.Value.CousumableGroupType); } } }
public Generator(E_HeroType heroType) { this.heroType = heroType; var table = TableLoader.GetTable<BlockSpawn>(); var data = table.GetMany(heroType).Select(x => new KeyValuePair<float, E_BlockType>(x.Value.chance, x.Value.blockType)); dart = new Dart<E_BlockType>(data); }
public ConsumableSpawn(int gameModeCode, int consumableTier) { var dropTypes = TableLoader.GetTable<ConsumableDropEntity>().GetMany(gameModeCode) .Select(x => new KeyValuePair<float, ConsumableType>(x.Value.chance, x.Value.consumableType)); this.typeDart = new Dart<ConsumableType>(dropTypes); this.tier = consumableTier; }
public void Update(GameTime gameTime) { if (cooldown > 0) cooldown -= gameTime.ElapsedGameTime.Milliseconds; else// if (level.Player.BoundingRectangle.Y < pos.Y + Tile.Height * 2 && level.Player.BoundingRectangle.Bottom > pos.Y - Tile.Height * 2) { Vector2 dartPos = new Vector2(pos.X + (effects == SpriteEffects.None ? 10 : -20), pos.Y + tex.Height / 2); Dart toAdd = new Dart(dartPos, level.Content, effects == SpriteEffects.None ? true : false); toAdd.Damage = Damage; level.Projectiles.Add(toAdd); cooldown = defCooldown; } }
private DartChainV2 InstantiateChain(DartChainV2 toAttachTo, Dart dart = null) { dart = dart ?? toAttachTo.CurrentDart; var brandNewCrossSection = (DartChainV2) Instantiate(_dartChainPrefab, _dartSpawnPoint.transform.position, _dartSpawnPoint.transform.rotation); brandNewCrossSection.CurrentGun = this; brandNewCrossSection.CurrentDart = dart; brandNewCrossSection.NextChain = toAttachTo; brandNewCrossSection.transform.parent = dart.transform; dart.ListenToCrossSection(brandNewCrossSection); return(brandNewCrossSection); }
public static int DartGame(Dart dart) { int result = 0; if (dart.Score == 0) { result = (25 * dart.Ring); } else { result = (dart.Score * dart.Ring); } return(result); }
public static int DetermineScore(Dart dart) { int value = 0; if (dart.Score > 0) // assuming dart is thrown til in bounds (and in range 0-20) { value = (dart.IsTriple) ? dart.Score * 3 : ((dart.IsDouble) ? dart.Score * 2 : dart.Score); // case double or triple } else { value = (dart.IsTriple && dart.Score == 0) ? 50 : 25; // case bullseye (also 5% of bull, else outer) } // used Bob's logic here but I think in reality it should be a different 5% chunk return(value); }
public void PlayGame(Dart playerOnesDart, Dart playerTwosDart) { while (playerOnesDart.Score < 300 && playerTwosDart.Score < 300) { for (int i = 0; i < 3; i++) { playerOnesDart.Throw(); } for (int i = 0; i < 3; i++) { playerTwosDart.Throw(); } } return; }
//Creates new Dart instance and checks to see if it was for palyer 1 or two depending on which button was clicked public int[] Play(int playerNumber) { Dart dart = new Dart(random); dart.Throw(); if (playerNumber == 1) { playerOneScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand); return(Score.DisplayDartThrow(dart.baseScore, dart.innerBand, dart.outerBand)); } else { playerTwoScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand); return(Score.DisplayDartThrow(dart.baseScore, dart.innerBand, dart.outerBand)); } }
public static void VerifyDill(string file) { var source = $"{preamble}scripts/{file}.dart"; var target = $"{preamble}scripts/{file}.dill"; if (!File.Exists(source)) { throw new Exception($"Source file {source} is missing."); } // We optimistically believe the kernel file is correct if (File.Exists(target)) { return; } Dart.CompileDill(source, target); }
void OnCollisionEnter(Collision other) { Rigidbody r = other.collider.GetComponent <Rigidbody> (); if (r != null) { r.isKinematic = true; Dart d = other.collider.GetComponent <Dart> (); d.transform.SetParent(this.transform); d.DartLand(); if (m_noun != null && d.m_dartType == Word.WordType.Noun && MenuState_GameState.instance.currentNoun == null) { MenuState_GameState.instance.SetNoun(m_noun); m_dartboard.m_resultText.text = m_noun.m_targetName; m_dartboard.m_resultText.gameObject.SetActive(true); m_dartboard.m_resultText.GetComponent <Animation> ().Play(); if (m_state != State.Active) { ChangeState(State.Active); } } else if (m_verb != null && d.m_dartType == Word.WordType.Verb && MenuState_GameState.instance.currentVerb == null) { MenuState_GameState.instance.SetVerb(m_verb); m_dartboard.m_resultText.text = m_verb.m_targetName; m_dartboard.m_resultText.gameObject.SetActive(true); m_dartboard.m_resultText.GetComponent <Animation> ().Play(); if (m_state != State.Active) { ChangeState(State.Active); } } else if ((m_verb != null && d.m_dartType == Word.WordType.Noun) || (m_noun != null && d.m_dartType == Word.WordType.Verb)) { MenuState_GameState.instance.DartMissed(d); } } }
public void IsValidScore_ValidScores_ReturnsTrue() { // Arrange List <int> validValues = new List <int> { 0, 1, 21, 25, 33, 42, 50, 57, 60 }; foreach (int item in validValues) { // Act bool result = Dart.IsValidScore(item); // Assert Assert.IsTrue(result, string.Format("{0} was expected to be valid", item)); } }
public void IsValidScore_InvalidScores_ReturnsFalse() { // Arrange List <int> invalidValues = new List <int> { -1, 23, 29, 35, 43, 52, 59, 61, 100 }; foreach (int item in invalidValues) { // Act bool result = Dart.IsValidScore(item); // Assert Assert.IsFalse(result, string.Format("{0} was expected to be invalid", item)); } }
public void IsValidDouble_ValidScores_ReturnsTrue() { // Arrange List <int> validValues = new List <int> { 2, 4, 16, 20, 30, 40, 50 }; foreach (int val in validValues) { // Act bool result = Dart.IsValidDouble(val); // Assert Assert.IsTrue(result, string.Format("{0} was expected to be valid", val)); } }
public void IsValidDouble_InvalidScores_ReturnsFalse() { // Arrange List <int> validValues = new List <int> { 0, 1, 17, 21, 31, 39, 41, 49, 51 }; foreach (int val in validValues) { // Act bool result = Dart.IsValidDouble(val); // Assert Assert.IsFalse(result, string.Format("{0} was expected to be invalid", val)); } }
public int[] Play() { int[] round = new int[2]; Dart newDart = new Dart(_random); int Score1 = 0; // score1 belongs to Player1 int Score2 = 0; // score2 belongs to Player2 do { // Player 1 throws first, add keep track of rounds, display round scores. Score1 += PlayerRound(); Score2 += PlayerRound(); } while (!(Score1 >= 300 || Score2 >= 300)); round[0] = Score1; round[1] = Score2; return(round); }
public int PlayTo300(Dart dart, Player player1, Player player2, Label resultLabel) { while ((player1.Score < 300) && (player2.Score < 300)) { PlayRound(dart, player1); PlayRound(dart, player2); } if (player1.Score >= 300) { return(1); } else { return(2); } }
public void Scored(Dart dart) { // Get percent to center of bullseye BoxCollider collider = GetComponent <BoxCollider>(); float colliderRadius = collider.size.x; Vector3 vectorToBullseye = (transform.position - dart.transform.position); vectorToBullseye.y = 0; float distToBullseye = vectorToBullseye.magnitude; Debug.Log("Radius: " + colliderRadius + " Distance to Bullseye: " + distToBullseye); float percentToCenter = distToBullseye / colliderRadius; // Update score GameManager.GetInstance().NotifyOfScore((int)(BullseyeMaxScore * percentToCenter)); }
/// <summary> /// Generates a string representation of a player's trap spell inventory. /// </summary> /// <returns>A list of trap spells possessed by the player.</returns> public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("Set Traps:"); sb.AppendLine($" Dart => {Dart?.ToString() ?? "Empty"}"); sb.AppendLine($" Flash => {Flash?.ToString() ?? "Empty"}"); sb.AppendLine($" Repeating Dart => {RepeatingDart?.ToString() ?? "Empty"}"); sb.AppendLine($" Snare => {Snare?.ToString() ?? "Empty"}"); sb.AppendLine($" Spear => {Spear?.ToString() ?? "Empty"}"); sb.AppendLine($" Poison Dart => {PoisonDart?.ToString() ?? "Empty"}"); sb.AppendLine($" Death => {Death?.ToString() ?? "Empty"}"); sb.AppendLine($" Sleep => {Sleep?.ToString() ?? "Empty"}"); sb.AppendLine($" Bladestorm => {Bladestorm?.ToString() ?? "Empty"}"); return(sb.ToString()); }
private static void _checkSegmentMap() { var boundSegments = Options.SegmentMap.Where(x => x.Value != null); var count = boundSegments.Count(); if (count == 0) { var mb = new MessageBoxScreen("Segment Map Warning", "The segment map does not contain any bindings.\nEnter options to create the segment map.", MessageBoxButtons.Ok); ScreenManager.AddScreen(mb); } else { var numberOfTotalSegments = 62; if (count != numberOfTotalSegments) { var mb = new MessageBoxScreen("Segment Map Warning", "It seems like not all segments are bound\n(The segment map contains " + count + " values,\nbut there are 62 segments on a dart board).\nEnter options to create the segment map.", MessageBoxButtons.Ok); ScreenManager.AddScreen(mb); } } foreach (var p1 in boundSegments) { foreach (var p2 in boundSegments) { if (!p1.Key.Equals(p2.Key) && p1.Value.Equals(p2.Value)) { Color c; string text1, text2; var dart1 = new Dart(null, p1.Key.X, p1.Key.Y); dart1.GetVerbose(out text1, out c); var dart2 = new Dart(null, p2.Key.X, p2.Key.Y); dart2.GetVerbose(out text2, out c); var mb = new MessageBoxScreen("Segment Map Warning", "The segment: " + text1 + " and " + text2 + "\ncontains the same coordinates: " + p1.Value + "!", MessageBoxButtons.Ok); ScreenManager.AddScreen(mb); } } } }
public int Play(int number) { //while (playerOneScore < 300 || playerTwoScore < 300) //{ // for (int i = 0; i < 6; i++) // { Dart dart = new Dart(random); dart.Throw(); if (number == 1) { return(playerOneScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand)); } return(playerTwoScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand)); // } //} }
public ButtonPanel(Rect rect, Dart<BlockEntity2> blockDart, HeroCharacter heroCharacter, ConsumableSpawn itemDropManager, int itemDropTier) { this.controlArea = rect; this.heroCharacter = heroCharacter; this.itemDropManager = itemDropManager; this.itemDropTier = itemDropTier; buttonTypes = new List<object>(); var blocks = blockDart.Values.Where(x => x.blockType != BlockType.WildCard); foreach (var entity in blocks) { buttonTypes.Add(entity); } buttonTypes.Add("damage"); buttonTypes.Add("item"); }
public static int calculateScore(Dart dart) { int throwResult = dart.Throw(); if (throwResult == 0) { throwResult = (dart.randomizer.Next() % 2 == 1) ? 25 : 50; } else if (dart.doubleRingHit == true) { throwResult = throwResult * 2; } else if (dart.tripleRingHit == true) { throwResult = throwResult * 3; } return(throwResult); }
public static void ScoreDart(Player player, Dart dart) { int score = 0; if (dart.IsDouble) { score = dart.Score * 2; } else if (dart.IsTriple) { score = dart.Score * 3; } else { score = dart.Score; } score += Bullseye(player, dart); player.Score += score; }
private void OnCollisionEnter(Collision collision) { if (_isHit) { return; } GameObject gameObject = collision.gameObject; Dart dart = gameObject.GetComponentInParent <Dart>(); if (dart != null) { Vector3 point = collision.GetContact(0).point; _isHit = true; int score = GetScoreFromPoint(point); HitEvent?.Invoke(this, score); } }
//GAME METHOD ACCEPTS TWO DART OBJECTS - ONE FOR EACH PLAYER public Game(Dart dartOne, Dart dartTwo) { //WHILE NEITHER PLAYER HAS SCORED 300 POINTS (WIN THRESHOLD) while (PlayerOneScore < 300 && PlayerTwoScore < 300) { //ALLOW EACH PLAYER TO THROW 3 DARTS PER TURN USING THE THROW METHOD //RUN EACH THROW RESULT THROUGH SCORE METHOD, AND ADD EACH RETURNED SCORE TO PLAYER'S RUNNING TOTAL //CHECK AFTER EACH THROW TO SEE IF EITHER PLAYER HAS REACHED 300 POINTS for (int i = 0; i < 3; i++) { dartOne = dartOne.Throw(dartOne); PlayerOneScore += Score.GetScore(dartOne.Throw(dartOne)); if (PlayerOneScore >= 300 || PlayerTwoScore >= 300) { break; } } for (int i = 0; i < 3; i++) { dartTwo = dartTwo.Throw(dartTwo); PlayerTwoScore += Score.GetScore(dartTwo.Throw(dartTwo)); if (PlayerOneScore >= 300 || PlayerTwoScore >= 300) { break; } } //SUMMARIZE RESULT OF GAME FOR DISPLAY if (PlayerOneScore > PlayerTwoScore) { Result += String.Format("Player One Score: {0}<br />Player Two Score: {1}<br>Player One Wins!<br />", PlayerOneScore, PlayerTwoScore); } else { Result += String.Format("Player One Score: {0}<br />Player Two Score: {1}<br>Player Two Wins!<br />", PlayerOneScore, PlayerTwoScore); } } PlayerOneScore = 0; PlayerTwoScore = 0; }
public void Play() { while (playerOneScore < 300 && playerTwoScore < 300) { for (int i = 0; i < 6; i++) { Dart dart = new Dart(random); dart.Throw(); if (i % 2 == 0) { playerOneScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand); } else { playerTwoScore += Score.CalculateDartThrow(dart.baseScore, dart.innerBand, dart.outerBand); } } } }
IEnumerator PlayingStateRoutine() { // Hide the spatial mapping mesh // Display player score and darts // Spawn the dart for the player Debug.Log("Hiding Spatial Mapping meshes: Enjoy playing!"); SpatialMappingManager.Instance.SurfacesVisible = false; GazeManager.Instance.RaycastLayerMask = LayerMask.GetMask("SpatialSurface", "Hologram", "UI"); while (!GameOver) { if (Dart == null || Dart.GetComponent <Throwable>().HasLanded == true) { Dart = SpawnDart(); } yield return(null); } CurrentState = GameState.GameOver; }
void Update() { if (startTime + interval * counter <= Time.time) { counter++; Dart dart = Instantiate(GameMaster.instance.dartPrefab); dart.transform.position = transform.position; dart.transform.position += new Vector3(direction * 0.5f, yDirection * 0.5f, 0); dart.direction = direction; dart.yDirection = yDirection; dart.source = this.gameObject; triggered = false; } if (startTime + interval * counter - 0.2f <= Time.time && !triggered) { if (GetComponent <AudioSource> ()) { GetComponent <AudioSource> ().Play(); } triggered = true; } }
public Board(Rect boardRect, PuzzlePanel puzzlePanel, Dart<BlockEntity2> dart, bool permitStartingMatch, MatchingHandler matchHandler, Handler onMatchStart, Handler onMatchFinish, TimeClient timeClient) { layout = new PuzzleLayout(boardRect); this.puzzlePanel = puzzlePanel; this.blockGenerator = new Block.Generator(dart); this.matchHandler = matchHandler; this.onMatchStart = onMatchStart; this.onMatchFinish = onMatchFinish; fsm = new FSM("PuzzleBoard.fsm", this); this.typeToEntity = new Dictionary<BlockType, BlockEntity2>(); foreach (var entity in dart.Values) { typeToEntity.Add(entity.blockType, entity); } FillWithoutAni(); if (!permitStartingMatch) { RemoveMatch(); } }
private string dartRound(Player player, string summaryOfRound) { string summary = summaryOfRound; for (int i = 0; i < 3; i++) { Dart dart = new Dart(_random); dart.Throw(); Score.ScoreDart(player, dart); if (i == 0) { summary += String.Format("{0}: {1}x{2}", player.Name, dart.Multiplier, dart.Score); } else { summary += String.Format(" {0}x{1}", dart.Multiplier, dart.Score); } } summary += " - Total: " + player.Score.ToString() + "<br/>"; return(summary); }
public override void OnPressAction() { if (this.ammo > 0) { if ((double)this._burnLife <= 0.0) { SFX.Play("dartStick", 0.5f, Rando.Float(0.2f) - 0.1f); } else { --this.ammo; SFX.Play("dartGunFire", 0.5f, Rando.Float(0.2f) - 0.1f); this.kick = 1f; if (this.receivingPress || !this.isServerForObject) { return; } Vec2 vec2 = this.Offset(this.barrelOffset); float radians = this.barrelAngle + Rando.Float(-0.1f, 0.1f); Dart dart = new Dart(vec2.x, vec2.y, this.owner as Duck, -radians); this.Fondle((Thing)dart); if (this.onFire) { Level.Add((Thing)SmallFire.New(0.0f, 0.0f, 0.0f, 0.0f, stick: ((MaterialThing)dart), firedFrom: ((Thing)this))); dart.burning = true; dart.onFire = true; } Vec2 vec = Maths.AngleToVec(radians); dart.hSpeed = vec.x * 10f; dart.vSpeed = vec.y * 10f; Level.Add((Thing)dart); } } else { this.DoAmmoClick(); } }
// Update is called once per frame void Update() { for (int i = 0; i < otherObstacles.Count; i++) { if (levelStartTime + dissapearanceTime [i] < Time.time) { otherObstacles [i].gameObject.SetActive(false); } } for (int i = 0; i < dartPositions.Count; i++) { if (nextFireTime [i] < Time.time) { Dart d = Instantiate(GameMaster.instance.dartPrefab); d.transform.position = dartPositions [i]; d.direction = 0; d.yDirection = -1; nextFireTime [i] = Time.time + Random.Range(fireRateMin, fireRateMax); } } }
public static void CalculateDartScore(Player player, Dart dart) { if (dart.Band == "triple" && dart.Score == 0) { player.Score += 50; } else if (dart.Band == "double" && dart.Score == 0) { player.Score += 25; } else if (dart.Band == "triple") { player.Score += dart.Score * 3; } else if (dart.Band == "double") { player.Score += dart.Score * 2; } else { player.Score += dart.Score; } }
private int dartScore(Dart dart) { int dartScore = dart.Score; if (dart.Score == 0 && dart.IsBullseyeInner == true) { dartScore = 50; } else if (dartScore == 0) { dartScore = 25; } else if (dart.IsDouble == true) { dartScore = dartScore * 2; } else if (dart.IsTriple == true) { dartScore = dartScore * 3; } return(dartScore); }
public ItemCommand DropItem(E_CousumableGroupType groupType, int tier) { var groupTable = groupedTables[groupType]; List<ConsumableEntity> tierItem = new List<ConsumableEntity>(); foreach (var entity in groupTable) { if (entity.ConsumableTier == 0 || tier == 0 || entity.ConsumableTier == tier) { tierItem.Add(entity); } } if (tierItem.Count == 1) { return new ItemCommand(tierItem[0]); } Dart<ConsumableEntity> ret = new Dart<ConsumableEntity>(); if (tierItem.Count > 0) { foreach (var entity in tierItem) { bool droppable = (gameModeType == E_GameModeType.Tutorial && entity.bDropTutorial) || (gameModeType == E_GameModeType.Adventure && entity.bDropAdventure) || (gameModeType == E_GameModeType.Raid && entity.bDropRaid) || (gameModeType == E_GameModeType.Arena && entity.DropArena); if (droppable) { ret.Add(1, entity); } } return new ItemCommand(ret.Get()); } return null; }
private void AddDart(Vector3 position) { GameObject dartObject = Instantiate(DartPrefab, position, Quaternion.identity); dartObject.transform.parent = Darts.transform; dartObject.transform.localPosition = position; Dart dart = dartObject.GetComponent <Dart>(); _audioSource.pitch = 1.2f + Random.value * 0.2f; _audioSource.PlayOneShot(PopClip, 1.4f); bool hitHandled = false; dart.HitEvent += (_, gameObject) => { if (hitHandled) { return; } DartBoard dartBoard = gameObject.GetComponentInParent <DartBoard>(); Dart otherDart = gameObject.GetComponentInParent <Dart>(); Table table = gameObject.GetComponentInParent <Table>(); Player player = gameObject.GetComponentInParent <Player>(); if (dartBoard == null && otherDart == null && table == null && player == null) { HandleDartBoardMiss(); hitHandled = true; } }; Throwable throwable = dartObject.GetComponent <Throwable>(); throwable.onDetachFromHand.AddListener(HandleVRDartThrow); }
public BastardHit(Dart dart, Player thrownBy, Player segmentOwner, int round) { Dart = dart; ThrownBy = thrownBy; SegmentOwner = segmentOwner; Round = round; }
public override int GetScore(Dart dart) { return dart.Multiplier; }
public Generator(Dart<BlockEntity2> dart) { this.dart = dart; }
public virtual int GetScore(Dart dart) { return dart.GetScore(); }
private DartChainV2 InstantiateChain(DartChainV2 toAttachTo, Dart dart = null) { dart = dart ?? toAttachTo.CurrentDart; var brandNewCrossSection = (DartChainV2) Instantiate(_dartChainPrefab, _dartSpawnPoint.transform.position, _dartSpawnPoint.transform.rotation); brandNewCrossSection.CurrentGun = this; brandNewCrossSection.CurrentDart = dart; brandNewCrossSection.NextChain = toAttachTo; brandNewCrossSection.transform.parent = dart.transform; dart.ListenToCrossSection(brandNewCrossSection); return brandNewCrossSection; }
public virtual void RegisterDart(int segment, int multiplier) { //Add the dart var dart = new Dart(CurrentPlayer, segment, multiplier); CurrentPlayerRound.Darts.Add(dart); }
void spawnDart() { dart = Instantiate(dartPrefab) as GameObject; dartScript = dart.GetComponent<Dart>(); dartNum++; }