private ScoreMaker SpawnScoreMaker(float range) { GridBlock gb = null; while (gb == null) { gb = GetEmptyIsolatedGridBlock(range); } if (gb.isOccupied || gb.hasItem) { return(null); } GameObject scorePrefab = Instantiate(scoreMaker_prefab, getGridBlockPosition(gb.X, gb.Z, 0.8f), Quaternion.identity) as GameObject; ScoreMaker sm = scorePrefab.GetComponent <ScoreMaker> (); sm.grid_ref = GetComponent <TheGrid> (); sm.rhythmSystem_ref = rhythmSystem_ref; sm.gridBlockOwner = gb; sm.x = gb.X; sm.y = gb.Y; sm.z = gb.Z; gb.hasItem = true; gb.Item = sm; itemList.Add(sm); return(sm); }
//spawn ScoreMaker Item private ScoreMaker SpawnScoreMaker(int x, int z) { GridBlock gb = GetGridBlock(x, z); if (gb.isOccupied || gb.hasItem) { return(null); } GameObject scorePrefab = Instantiate(scoreMaker_prefab, getGridBlockPosition(x, z, 0.8f), Quaternion.identity) as GameObject; ScoreMaker sm = scorePrefab.GetComponent <ScoreMaker> (); sm.grid_ref = GetComponent <TheGrid> (); sm.rhythmSystem_ref = rhythmSystem_ref; sm.gridBlockOwner = gb; sm.x = gb.X; sm.y = gb.Y; sm.z = gb.Z; gb.hasItem = true; gb.Item = sm; itemList.Add(sm); return(sm); }
public void PutBruger(string id, [FromBody] ScoreMaker scoreMaker) { string updateBruger = "ERROR"; if (scoreMaker.Gamemode == "AI") { updateBruger = $"UPDATE Bruger SET AI_Wins_Total = AI_Wins_Total + {scoreMaker.Win}, AI_Loses_Total = AI_Loses_Total + {scoreMaker.Loss} WHERE Bruger_Id={id};"; } else if (scoreMaker.Gamemode == "Multiplayer") { updateBruger = $"UPDATE Bruger SET Wins_Total = Wins_Total + {scoreMaker.Win}, Loses_Total = Loses_Total + {scoreMaker.Loss} WHERE Bruger_Id={id};"; } else if (scoreMaker.Gamemode == "Brugernavn") { updateBruger = $"UPDATE Bruger SET Brugernavn = '{scoreMaker.Brugernavn}' WHERE Bruger_Id={id};"; } else if (scoreMaker.Gamemode == "Description") { updateBruger = $"UPDATE Bruger SET Description = '{scoreMaker.Description}' WHERE Bruger_Id={id};"; } //string updateBrugerAI = $"UPDATE Bruger (AI_Wins_Total, AI_Loses_Total) VALUES (@AI_Wins_Total, @AI_Loses_Total) WHERE Bruger_Id={id};"; SqlConnection connect = new SqlConnection(connection); using (SqlCommand insertCommand = new SqlCommand(updateBruger, connect)) { Console.WriteLine(scoreMaker.Id + " " + scoreMaker.Gamemode); connect.Open(); insertCommand.ExecuteNonQuery(); } }
void itemTimersUpdate() { if (scoreMakerTimer.stop) { if (isRandomScoreMakerSpawnTime) { scoreMakerTimer.startTimer(Random.Range(ScoreMakerSpawnTimeMin, ScoreMakerSpawnTimeMax)); } else { scoreMakerTimer.startTimer((ScoreMakerSpawnTimeMax + ScoreMakerSpawnTimeMin) / 2); } // if more than 5 scoremakers in the stage if (itemList.OfType <ScoreMaker> ().Count() < scoreMakerCountLimit) { ScoreMaker sm = SpawnScoreMaker(2.0f); } } if (arrowTimer.stop) { if (isRandomLockSpawnTime) { lockTimer.startTimer(Random.Range(lockSpawnTimeMin, lockSpawnTimeMax)); } else { lockTimer.startTimer((lockSpawnTimeMin + lockSpawnTimeMax) / 2); } // if more than 5 scoremakers in the stage if (itemList.OfType <Lock> ().Count() < lockCountLimit) { Lock sm = SpawnLock(2.0f); } } if (arrowTimer.stop) { if (isRandomArrowSpawnTime) { arrowTimer.startTimer(Random.Range(ArrowSpawnTimeMin, ArrowSpawnTimeMax)); } else { arrowTimer.startTimer((ArrowSpawnTimeMin + ArrowSpawnTimeMax) / 2); } if (itemList.OfType <Arrow> ().Count() < arrowCountLimit) { float ratioTotal = singleArrowRatio + doubleArrowRatio + quadrupleArrowRatio; float ar = Random.Range(0f, ratioTotal); Arrow.arrowType t = Arrow.arrowType.Single; if ((ar - quadrupleArrowRatio) < 0) { t = Arrow.arrowType.Quadruple; } else if ((ar - doubleArrowRatio) < 0) { t = Arrow.arrowType.Double; } else if ((ar - singleArrowRatio) < 0) { t = Arrow.arrowType.Single; } Arrow sm = SpawnArrow(1.0f, t); } } }