private void Kill(Core.Unit unit) { DebugLog.Fine(this, $"{_prefix} Killing Unit {{{unit.ID}}}"); if (onlineUnits.TryGetValue(unit.ID, out Unit unitView)) { Core.Unit u = unitView.unit; if (!u.IsDead() | !unit.IsDead()) { DebugLog.Warning(this, $"{_prefix} Unit {{{unit.ID}}} is not dead, but called kill."); } OnUnitViewRemoveEvent.Invoke(unitView); unitView.OnUnitDeathEvent.Invoke(unitView.gameObject); onlineUnits.Remove(unit.ID); Destroy(unitView.gameObject); DebugLog.Finest(this, $"{_prefix} Killed Unit {unitView.ToString()}"); return; } else { DebugLog.Severe(this, $"{_prefix} Could not find unit {{{unit.ID}}}!!"); return; } }
// MissionHandlerManager sequence // Add => Check => Assign => Update => Check => Complete => Check => Assign... public void AddMission(MissionHandler handler, bool check = true) { DebugLog.Fine(this, $"{_prefix} Adding new mission: {MH_ToString(handler)}"); _missionHandlers.Enqueue(handler); CheckMission(check); }
private GameObject Spawn(Core.Unit unit) { DebugLog.Fine(this, $"{_prefix} Spawning Unit {{{unit.ID}}}"); GameObject unitObj = Spawn(balloonUnit, unit.ID, unit.X, unit.Y); Unit unitView = unitObj.GetComponent <Unit>(); unitView.unit = unit; onlineUnits.Add(unit.ID, unitView); OnUnitViewAddEvent.Invoke(unitView); DebugLog.Finest(this, $"{_prefix} Spawned Unit: {unitView.ToString()}"); return(unitObj); }
public void AssignMission() { if (_missionHandlers.Count != 0) { if (_currentMission != null) { DebugLog.Warning(this, $"{_prefix} Overwriting mission!: {MH_ToString(_currentMission)}"); } _currentMission = _missionHandlers.Dequeue(); DebugLog.Fine(this, $"{_prefix} Assigned mission: {MH_ToString(_currentMission)}"); OnMissionAssignEvent.Invoke(GetCurrentMission()); } }
public void CompleteMission(bool check = true) { DebugLog.Fine(this, $"{_prefix} Completing mission: {MH_ToString(_currentMission)}"); if (_currentMission == null) { DebugLog.Severe(this, $"{_prefix} Cannot complete mission because current mission is null!!"); return; } OnMissionCompleteEvent.Invoke(_currentMission); _currentMission = null; CheckMission(check); }
public void UpdateMission(int val, bool check = true) { DebugLog.Fine(this, $"{_prefix} Updating mission: {val}, {MH_ToString(_currentMission)}"); if (_currentMission == null) { DebugLog.Severe(this, $"{_prefix} Cannot update mission because current mission is null!!"); return; } //_currentMission.enemiesKilled += val; OnMissionUpdateEvent.Invoke(_currentMission); CheckMission(check); }
private void Damage(Core.Unit unit, int amount) { DebugLog.Fine(this, $"{_prefix} Damaging Unit {{{unit.ID}}}"); if (onlineUnits.TryGetValue(unit.ID, out Unit unitView)) { Core.Unit u = unitView.unit; u.hp -= amount; OnUnitViewDamageEvent.Invoke(unitView); } else { DebugLog.Severe(this, $"{_prefix} Could not find unit [{unit.ID}]!!"); return; } }
private GameObject Spawn(Player player) { DebugLog.Fine(this, $"{_prefix} Spawning Player {{{player.Name}}}"); GameObject playerObj = Spawn(playerUnit, player.Name, player.X, player.Y); // Disable object because we still don't need it! playerObj.SetActive(false); PlayerView playerView = playerObj.GetComponent <PlayerView>(); playerView.player = player; onlinePlayers.Add(player.Name, playerView); OnPlayerViewAddEvent.Invoke(playerView); DebugLog.Finest(this, $"{_prefix} Spawned Player: {playerView.ToString()}"); return(playerObj); }
private void Remove(Player player) { DebugLog.Fine(this, $"{_prefix} Removing Player {{{player.Name}}}"); if (onlinePlayers.TryGetValue(player.Name, out PlayerView playerView)) { OnPlayerViewRemoveEvent.Invoke(playerView); onlinePlayers.Remove(player.Name); Destroy(playerView.gameObject); DebugLog.Finest(this, $"{_prefix} Removed Player: {playerView.ToString()}"); return; } else { DebugLog.Severe(this, $"{_prefix} Could not find player {{{player.Name}}}!!"); return; } }