//Method to encapsulate whether we should turn off the terrain affector void DetectsTerrainAffectorOff(ShipRevamped s) { if (s != null) { PlayerManager.PlayerInfo p = PlayerManager.GetPlayer(s); //Debug.Log ("Points cache size is " + pointsCache.Count); if (!pointsCache.ContainsKey(s)) { return; } if (p != null && pointsCache[s].Count == 0) { //Debug.Log ("Setting terrainAffector off"); s.SetTerrainAffectorOff(); } } }
void InitStat(Text t, string s, PlayerManager.Metric m, string num, bool plural = true) { t.text = s + ": "; PlayerManager.PlayerInfo p = PlayerManager.TopPlayer(m); if (p != null) { t.text += "Player " + (p.order + 1); string ps = plural?Mathf.Abs(p.GetMetric(m)) != 1?"s":"":""; t.text += (num == ""?"":" (" + p.GetMetric(m) + " " + num + ps + ")"); t.color = PlayerManager.TeamColor(p); } else { t.text += "Not today..."; t.color = Color.white; } SetAlpha(t, 0); }
void OnTriggerEnter2D(Collider2D c) { //print(c.gameObject.name+" entered"); //Debug.Log ("On Trigger Enter"); //Debug.Log (c.GetComponent<Point> ().position); ShipRevamped s = null; //Checks if ship has collided with goal if (c.gameObject.layer == pointLayer && c.GetComponent <Point> ().handler != null) { s = c.GetComponent <Point> ().handler.GetComponent <ShipRevamped> (); if (s != null && !s.totaled) { if (!pointsCache.ContainsKey(s)) { pointsCache.Add(s, new List <Point> ()); } pointsCache[s].Add(c.GetComponent <Point> ()); } } if (s != null && !s.totaled && pointsCache[s].Count > 0) { //Debug.Log ("Ship is not null"); PlayerManager.PlayerInfo p = PlayerManager.GetPlayer(s); if (p != null) { //Debug.Log ("Setting terrainAffector on"); s.SetTerrainAffectorOn(terrainAffectorDragFactor); } else { //Debug.Log ("Player is null"); } } }
//Observe void OnKill(ShipRevamped targetShip, Rowball rowball) { int targetScore = PlayerManager.GetPlayer(targetShip).score; PlayerManager.PlayerInfo shooter = PlayerManager.GetPlayer(rowball.shooter.GetComponent <ShipRevamped>()); PlayerManager.Player target = PlayerManager.GetPlayer(targetShip).player; CreateExplosion(rowball.position); string killContext = ""; PlayerManager.GetPlayer(targetShip).spree = 0; if (scoreMode == ScoreMode.KILL) { if (rowball.shooter != null) { float score = baseScorePoints; if (shooter.player.team == target.team) { score = penaltyPoints; killContext += "SUICIDE"; //+" (-1)\n"; killContext += "\n"; Observer.OnSuicide.Invoke(); shooter.Score((int)score); shooter.suicides++; } else { if (Time.time <= shooter.lastKillTime + multiKillThreshhold) { shooter.multikill++; } else { shooter.multikill = 0; } shooter.lastKillTime = Time.time; shooter.spree++; if (shooter.spree > shooter.longestSpree) { shooter.longestSpree = shooter.spree; } if (PlayerManager.GetPlayer(targetShip) == PlayerManager.leader && PlayerManager.leader.score != 0) { //score *= leaderKillBonus; score++; killContext += "LEADER KILL"; //+" (+1) \n"; killContext += "\n"; shooter.leaderKills++; // Observer.OnLeaderKill.Invoke(); //Debug.Log ("Leader has been killed! x" + leaderKillBonus + "\n"); } //float relativeSpeed = rowball.RelativeVelocity (targetShip.velocity).magnitude; // if (relativeSpeed > brutalityThreshold) { // score += (baseScorePoints * (relativeSpeed / 1000)); // if(displayPercentScore) // shooter.player.textRef.text += "Brutality (+" + (baseScorePoints * relativeSpeed/1000)/scoreToWin * 100 + "%)" + "\n"; // else // shooter.player.textRef.text += "Brutality (+" + (int)(baseScorePoints * relativeSpeed/1000) + ")" + "\n"; // Debug.Log ("Brutality: +" + (baseScorePoints * relativeSpeed / 1000)); // } if (shooter.multikill > 0) { score += (shooter.multikill); // Multikill bonus killContext += shooter.multikill == 1?"DOUBLE KILL": shooter.multikill == 2?"TRIPLE KILL": "MULTI: " + (shooter.multikill + 1); killContext += "\n"; // if (shooter.multikill == 1) { Observer.OnDoubleKill.Invoke(); } else if (shooter.multikill == 2) { Observer.OnTripleKill.Invoke(); } //Stats if (shooter.multikill > 0) { shooter.multiKills++; } //killContext+=" (+" + shooter.player.multikill + ")" + "\n"; //Debug.Log ("Multi ("+ shooter.player.multikill +"): x" + (shooter.player.multikill * (1.0f + multiKillMultiplier))); } if (shooter.spree >= spreeThreshhold) { score++; killContext += "SPREE: " + shooter.spree; // + " (+1)\n"; killContext += "\n"; //Debug.Log ("Spree: " + shooter.player.spree); } //Debug.Log ("Player has earned " + score + " points for a kill."); shooter.Score((int)score); } if (score != 1) { InterfaceManager.CreateTextEffect( killContext, target.ship.position, PlayerManager.TeamColor(shooter.player.team) ); } //else /* * InterfaceManager.CreateTextEffect( * InterfaceManager.instance.deathMessages[(int)Random.Range (0, InterfaceManager.instance.deathMessages.Length)], * target.ship.position, * PlayerManager.TeamColor(shooter.player.team), * 2,13 * ); */ } } else if (scoreMode == ScoreMode.LMS) { if (rowball.shooter != null) { if (rowball.shooter == targetShip || shooter.player.team == target.team) { shooter.Score(penaltyPoints + targetScore / 10); } else { shooter.Score(baseScorePoints); } } } float respawnTimePenalty = (targetScore > scoreToWin / 2)? targetScore / 100 * penaltyMultiplier:0.0f; if (useRespawns && winners == null) { targetShip.Respawn(respawnTime + respawnTimePenalty); } }