/// <summary> Rebuild unit list. </summary> public void BuildUnitList() { if (Members == null) { Units = null; return; } Units = new ObservableCollection <string>(); // Use UnitDetails if available, since it can contain units not found // in any player's roster. if (UnitDetails != null && UnitDetails.Count() > 0) { foreach (var name in UnitDetails.Where(u => u.combatType == goh_ui.UnitDetails.COMBATTYPE_CHARACTER).Select(u => u.name).OrderBy(x => x)) { Units.Add(name); } return; } // If UnitDetails not available, derive a list by combining the members' rosters. var units = Members.Select(m => m.Roster.Where(u => u.combatType == goh_ui.UnitDetails.COMBATTYPE_CHARACTER) .Select(c => c.name)) // map each member to an array of unit names .SelectMany(x => x) // flatten list .Distinct() // de-duplicate .OrderBy(x => x); // sort alphabetically foreach (var unit in units) { Units.Add(unit); } }
public void Load(UnitDetails newDetails) { transform.position = SaveManager.StringToVector(newDetails.position); transform.rotation = SaveManager.StringToQuaternion(newDetails.rotation); transform.localScale = SaveManager.StringToVector(newDetails.localScale); unitDetails = newDetails; }
public void AddUnitDetails(UnitDetails details) { if (UnitsAdded != null) { UnitsAdded(details); } }
public override void OnEnter() { Machine.Actor.GetComponent <UnitStateManager>().Active = true; unitDetails = Machine.Actor.GetComponent <UnitDetails>(); unitTilemap = ObjectReferences.Instance.UnitTilemap; }
List <GameObject> FindUnitsInRange(int range, int originGridX, int originGridY) { List <GameObject> units = new List <GameObject>(); List <TileDetails> tilesInRange = new List <TileDetails>(); tilesInRange = GetTilesInRange(2, originGridX, originGridY); foreach (GameObject u in GameManager.Instance.AllUnits) { if (u == unitDetails.gameObject) { continue; } UnitDetails unitInfo = u.GetComponent <UnitDetails>(); if (tilesInRange.Exists(x => IsUnitOnTile(unitInfo, x)) && unitInfo.TeamNumber != unitDetails.TeamNumber) { units.Add(u); } //if (unitInfo.CurrentGridX == originGridX - 1 && unitInfo.CurrentGridY == originGridY && unitInfo.TeamNumber != unitDetails.TeamNumber) //{ // units.Add(u); //} //if (unitInfo.CurrentGridX == originGridX && unitInfo.CurrentGridY == originGridY + 1 && unitInfo.TeamNumber != unitDetails.TeamNumber) //{ // units.Add(u); //} //if (unitInfo.CurrentGridX == originGridX && unitInfo.CurrentGridY == originGridY - 1 && unitInfo.TeamNumber != unitDetails.TeamNumber) //{ // units.Add(u); //} } return(units); }
public Looter(UnitDetails unitDetails) : base(unitDetails) { this.PlayerId = unitDetails.PlayerId; this.Mass = unitDetails.Mass; this.Speed = unitDetails.Speed; }
List <GameObject> FindAdjacentUnits(Node n) { List <GameObject> units = new List <GameObject>(); int originGridX = (int)n.Position.x; int originGridY = (int)n.Position.y; foreach (GameObject u in GameManager.Instance.PlayerTeam.TeamUnits) { UnitDetails unitInfo = u.GetComponent <UnitDetails>(); if (unitInfo.CurrentGridX == originGridX + 1 && unitInfo.CurrentGridY == originGridY && unitInfo.TeamNumber != unitDetails.TeamNumber) { units.Add(u); } if (unitInfo.CurrentGridX == originGridX - 1 && unitInfo.CurrentGridY == originGridY && unitInfo.TeamNumber != unitDetails.TeamNumber) { units.Add(u); } if (unitInfo.CurrentGridX == originGridX && unitInfo.CurrentGridY == originGridY + 1 && unitInfo.TeamNumber != unitDetails.TeamNumber) { units.Add(u); } if (unitInfo.CurrentGridX == originGridX && unitInfo.CurrentGridY == originGridY - 1 && unitInfo.TeamNumber != unitDetails.TeamNumber) { units.Add(u); } } return(units); }
/// <summary> Unit filtering logic. </summary> private void FilterUnits(object sender, FilterEventArgs e) { // If filters aren't supported, return everything if (UnitDetails == null || UnitDetails.Count() == 0) { e.Accepted = true; return; } // Look up character metadata var character = e.Item as string; var unit = UnitDetails.Where(u => u.name == character).FirstOrDefault(); if (unit == null) { e.Accepted = false; return; } // Apply selected filter switch (SelectedFilter) { // Handle generic filters case "All": e.Accepted = true; break; case "Light Side": e.Accepted = unit.forceAlignment == goh_ui.UnitDetails.ALIGNMENT_LIGHT; break; case "Dark Side": e.Accepted = unit.forceAlignment == goh_ui.UnitDetails.ALIGNMENT_DARK; break; // Handle tag-based filters default: e.Accepted = unit.categoryIdList.Contains(SelectedFilter); break; } }
bool IsUnitOnTile(UnitDetails unit, TileDetails tile) { if (tile != null) { return(unit.CurrentGridX == tile.GridPos.x && unit.CurrentGridY == tile.GridPos.y); } return(false); }
private void Awake() { if (UnitDetails.Instance && UnitDetails.Instance != this) { DestroyImmediate(this.gameObject); return; } UnitDetails.Instance = this; }
private void AddToList(UnitDetails details) { //Commander.Units.Add(details); GameObject button = Instantiate(UnitDetailPrefab, lstGridUnits); UnitControlPanel gridButton = button.GetComponent <UnitControlPanel>(); gridButton.Initialize(details, unitCamSwitch); Debug.Log("Button created"); }
private void TrainUnit() { Base.CreatedUnits++; GameObject unit = Instantiate(UnitPrefab, UnitSpawnLocation.position, Quaternion.identity); UnitDetails details = unit.GetComponent <UnitDetails>(); details.SetDetails(Base.Owner, Base.CreatedUnits, 1f, 0.25f, 1f); Base.Owner.AddUnitDetails(details); IsTraining = false; }
public void SetSelectedUnit(Unit unit) { selectedUnit = unit; if (unit != null) { UnitDetails.Instance().ShowUnitDetails(unit); } else { UnitDetails.Instance().Hide(); } }
// Update is called once per frame void Update() { if (GameManager.gameState == GameState.Battling) { CurrentRescource += (Time.deltaTime * RescourceGenerationRate); if (CurrentRescource >= RequiredRescource) { NewUnitPositon.x = parentPosition.position.x + Random.Range(-2f, 2.1f); NewUnitPositon.z = parentPosition.position.z + Random.Range(-2f, 2.1f); NewUnitPositon.y = 0; //Create new unit GameObject go = Instantiate(UnitPrefab, NewUnitPositon, Quaternion.identity); UnitDetails newUnit = go.GetComponent <UnitDetails>(); //Set details of new unit //ID for enemy units only instanciated here, ID is managed internally newUnit.SetDetails(Base.Owner, id, 1f, 0.2f, 1f); id++; //Add to list unitsWaiting.Add(go.GetComponent <UnitComponent>()); //Remove cost of unit CurrentRescource -= RequiredRescource; } if (unitsWaiting.Count >= 3) { //Assign random starting node SelectedRoute = staringNodes[Random.Range(0, 3)]; //REMOVE BEFORE RELEASE //SelectedRoute = staringNodes[0]; //Set starting node //unitsWaiting.ForEach(uw => uw.GetComponent<AIPathFollower>().CurrentNode = SelectedRoute); foreach (var uw in unitsWaiting) { if (uw != null) { uw.GetComponent <AIPathFollower>().CurrentNode = SelectedRoute; } uw.GetComponent <AIPathFollower>().Invoke("MoveToPathNode", 1); } //Tell units to start moving //unitsWaiting.ForEach(uw => uw.GetComponent<AIPathFollower>().Invoke("MoveToPathNode", 1)); //Clear waiting list unitsWaiting.Clear(); } } }
private void OnTriggerExit(Collider collision) { //check reverse collision is with unittype UnitDetails removeUnit = collision.gameObject.GetComponent <UnitDetails>(); if (removeUnit != null) { if (collision.gameObject.tag.Equals("Player")) { EnemiesToAttack.Remove(removeUnit); //if (AttackThese.Count == 0)//Check if enemies still in range // CanSeeTarget = false; } } }
public static IOBalanceDBV3Entity.Units DtoToEntity(this UnitDetails dto) { IOBalanceDBV3Entity.Units entity = null; if (!dto.IsNull()) { entity = new IOBalanceDBV3Entity.Units { UnitID = dto.UnitId, UnitDescription = dto.UnitDescription }; } return(entity); }
private void OnTriggerEnter(Collider collision) { UnitDetails newUnit = collision.gameObject.GetComponent <UnitDetails>(); if (newUnit != null) { if (collision.gameObject.tag.Equals("Player")) { CanSeeTarget = true; EnemiesToAttack.Add(newUnit); } } else { CanSeeTarget = false; } }
/// <summary> Rebuild the list of available filters. </summary> private void BuildFilterList() { Filters.Clear(); if (UnitDetails == null || UnitDetails.Count() == 0) { return; } // Add a few generic filters at the top of the list. Filters.Add("All"); Filters.Add("Light Side"); Filters.Add("Dark Side"); // Add filters based on unit tags Filters.AddRange(UnitDetails.Select(u => u.categoryIdList).SelectMany(x => x).Distinct().OrderBy(x => x)); }
//Used to create units public void CreateUnit(string unitName) { //Check to see if we have a unit if (unitLookup.ContainsKey(unitName)) { //Units to build UnitDetails unitToBuild = unitLookup[unitName]; //Get a random spawn location in a circle Vector2 spawnLocationOffset = Random.insideUnitCircle * spawnRange; Vector3 spawnLocation = spawnPoint.transform.position; spawnLocation.x += spawnLocationOffset.x; spawnLocation.z += spawnLocationOffset.y; //Spawn Instantiate <GameObject>(unitToBuild.prefab, spawnLocation, Quaternion.identity); } }
public void DealDamage(UnitDetails target) { int hit = Random.Range(0, 100); if (hit <= glanceChance) { target.Health -= glanceDamage; Debug.Log("A glancing blow..."); } else if (hit >= 100 - criticalChance) { target.Health -= criticalDamage; Debug.Log("A critical hit!"); } else { target.Health -= normalDamage; } }
void Attack() { AttackThis = EnemiesToAttack[0]; if (Me != null && AttackThis != null) { //Me.AttackModifier = Me.SignModifier(AttackThis.myType) * Me.LevelModifier(AttackThis); if (Time.deltaTime <= AttackDelay) { AttackThis.Health -= Me.AttackPower * Me.AttackModifier; //Reset timer timer = 0f; Debug.Log(Me.ToString()); //Debug.Log(AttackThis.ToString()); } } if (AttackThis == null) { CanSeeTarget = false; } }
static void Main(string[] args) { while (true) { var gameContext = new GameContext(); int myScore = int.Parse(Console.ReadLine()); gameContext.MyScore = myScore; int enemyScore1 = int.Parse(Console.ReadLine()); gameContext.EnemyOneScore = enemyScore1; int enemyScore2 = int.Parse(Console.ReadLine()); gameContext.EnemyTwoScore = enemyScore2; int myRage = int.Parse(Console.ReadLine()); gameContext.MyRage = myRage; int enemyRage1 = int.Parse(Console.ReadLine()); gameContext.EnemyOneRage = enemyRage1; int enemyRage2 = int.Parse(Console.ReadLine()); gameContext.EnemyTwoRage = enemyRage2; int unitCount = int.Parse(Console.ReadLine()); for (int i = 0; i < unitCount; i++) { string[] inputs = Console.ReadLine().Split(' '); var unitDetails = new UnitDetails() { UnitId = int.Parse(inputs[0]), UnitType = int.Parse(inputs[1]), PlayerId = int.Parse(inputs[2]), Mass = float.Parse(inputs[3]), Radius = int.Parse(inputs[4]), Position = new Position(int.Parse(inputs[5]), int.Parse(inputs[6])), Speed = new Speed(int.Parse(inputs[7]), int.Parse(inputs[8])), Extra = int.Parse(inputs[9]), WaterCapacity = int.Parse(inputs[10]) }; gameContext.InitializeUnit(unitDetails); } gameContext.ProcessTurn(); } }
void Update() { //Check if enemy is dead if (AttackThis != null && AttackThis.Health <= 0) { EnemiesToAttack.Remove(AttackThis); Destroy(AttackThis.gameObject); } if (AttackThis == null) //When HP reaches 0, object is destroyed which may leave null { if (EnemiesToAttack.Count <= 0) //Check if units in range { return; } else //set target to be first element of Enemy list { AttackThis = EnemiesToAttack[0]; } } if (EnemiesToAttack.Count > 0) { if (timer <= 0f) { timer = AttackDelay; } if (timer > 0f) { timer -= Time.deltaTime; } if (timer <= 0f && CanSeeTarget) { Attack(); } } }
public void Initialize(UnitDetails details, UnitCameraSwitcher switcher) { Name.text = details.Name; Type.text = details.myType.ToString(); unitDetails = details; }
public Doof(UnitDetails unitDetails) : base(unitDetails) { this.Friction = Constants.DoofFriction; }
public Destroyer(UnitDetails unitDetails) : base(unitDetails) { this.Friction = Constants.DestroyerFriction; }
public Reaper(UnitDetails unitDetails) : base(unitDetails) { this.Friction = Constants.ReaperFriction; }
public OilPool(UnitDetails unitDetails) : base(unitDetails) { this.RemainingDuration = unitDetails.Extra; }
public Wreck(UnitDetails unitDetails) : base(unitDetails) { this.WaterAmount = unitDetails.Extra; }
public Tanker(UnitDetails unitDetails) : base(unitDetails) { this.WaterAmount = unitDetails.Extra; this.WaterCapacity = unitDetails.WaterCapacity; }