public void ReportDeath(CharacterBuildScript build) { if(build.networkView.isMine) //we only report scores for our own player { networkView.RPC("AddDeath", RPCMode.Server, build.build.owner); //GetPlayerScore(build.build.owner).deaths++; Targetable playerHit = build.GetComponent<Targetable>(); if(!playerHit) { Debug.LogError("There is no Targetable on this player to report a score for"); return; } HitStruct lastHit = new HitStruct(-1f); List<HitStruct> hits = playerHit.GetHits(GameSettings.hitAddsToScoreTime); foreach(HitStruct hit in hits) { if(hit.timestamp > lastHit.timestamp) lastHit = hit; } //apply kill/assist points appropriately to all players that had hit the dead player foreach(HitStruct hit in hits) { if(hit.attacker == lastHit.attacker) networkView.RPC("AddKill", RPCMode.Server, lastHit.attacker.build.owner); //GetPlayerScore(lastHit.attacker.build.owner).kills++; else networkView.RPC("AddAssist", RPCMode.Server, hit.attacker.build.owner); //GetPlayerScore(hit.attacker.build.owner).assists++; } } }
public void AddToPlayer(CharacterBuildScript player) { Ability ability = (Ability)player.gameObject.AddComponent(scriptName); ability.abilityData = this; player.AddAbility(ability); ability.AddPlayer(player); }
HitStruct GetMostRecentHit(CharacterBuildScript player) { HitStruct mostRecent = new HitStruct(-1); foreach(HitStruct hit in hits) { if(hit.attacker == player && hit.timestamp > mostRecent.timestamp) mostRecent = hit; } return mostRecent; }
// Use this for initialization void Start() { character = GetComponent <CharacterBuildScript>(); movement = GetComponent<CharacterMoveScript>(); GameObject game = GameObject.FindGameObjectWithTag("GameController"); cameraController = game.GetComponent<CameraControllerScript>(); settings = game.GetComponent<PlayerSettingsScript>(); ability1IsHeld = false; ability2IsHeld = false; }
void Start() { character = GetComponent<CharacterBuildScript> (); }
public void AddPlayer(CharacterBuildScript build) { player = build; }
public void RegisterPlayerData(PlayerCharacterSettingsScript characterBuild) { build = characterBuild.character; }
public void ClearCharacterBuild() { playerBuild = null; }
public void RegisterCharacterBuild(CharacterBuildScript build) { playerBuild = build; }
public void HitBy(CharacterBuildScript attacker) { hits.Add(new HitStruct(attacker, build)); }
public HitStruct(CharacterBuildScript atkr, CharacterBuildScript dfnd) { playerHit = dfnd; attacker = atkr; timestamp = Time.time; }
public HitStruct(float ts) { playerHit = null; attacker = null; timestamp = ts; }
void Start() { build = GetComponent<CharacterBuildScript>(); build.totalJumps++; }