//public void ProduceUnit(int unitWorkingOn, float unitWorkingSpeed) public void ProduceUnit(GameObject unitObject) { UnitClass tmpUnitScript = unitObject.GetComponent<UnitClass>(); if (this.unitWorkingLine == 0 && HasEnoughMoney(tmpUnitScript)) { this.unitWorkingOn = unitObject; this.unitScript = tmpUnitScript; this.unitWorkingLine++; this.unitWorkingProcess = 0; GameProperties.credits -= GameProperties_CT.levelOfAllUnits[unitScript.type][ENUMS.PROPERTIES.Cost]; } else if (unitWorkingLine > 0 && unitWorkingOn == tmpUnitScript) { if (unitWorkingLine >= unitWorkingLineMax) { GameProperties_CT.AddMessage("Maximale Warteschlange erreicht."); } else if (HasEnoughMoney(tmpUnitScript)) { this.unitWorkingLine++; GameProperties.credits -= unitScript.cost[GetLevel(ENUMS.PROPERTIES.Cost)]; } } }
/// <summary> /// This overload is for ordered units which have not spawned yet. /// </summary> /// <param name="type">The type of unit which will be created.</param> /// <param name="level">The upgrade level with which the unit will spawn.</param> /// <param name="beacon">The gameObject marking where the unit will spawn.</param> /// <param name="spawnTime">The Time.time when the unit is done being built.</param> public UnitObject(UnitClass type, int level, GameObject beacon, float spawnTime) { this.Type = type; this.Level = level; this.Beacon = beacon; this.SpawnTime = spawnTime; this.Spawned = false; }
/// <summary> /// This overload is for immediately spawned units. Note: this still requires calling Spawn(). /// </summary> /// <param name="gameObject">The gameObject that will be called a unit.</param> /// <param name="type">The type of unit to create.</param> /// <param name="level">The upgrade level with which the unit will spawn.</param> public UnitObject(GameObject gameObject, UnitClass type, int level) { this.GameObject = gameObject; this.Type = type; this.Level = level; this.SpawnTime = Time.time; this.Spawned = true; }
public void unitSetup(UnitClass copy) { uC = copy.unitClass; uT = copy.unitType; att = copy.attack; def = copy.defense; owningPlayer = copy.owner; pointCost = copy.cost; texture = copy.texture; TextureManager.applyTexture(this.gameObject, texture); }
public bool CheckClass(UnitClass unitClass) { for (int i = 0; i < factionClasses.Count; i++) { if (factionClasses[i] == unitClass) { return(true); } } return(false); }
public Unit() { inventory = new UnitInventory(); items = new UnitItems(); unitInfo = new UnitInfo(); unitClass = new UnitClass(); status = new UnitStatus(); unitActor = new UnitActor(); idx = ""; unitID = ""; }
public override void classChange(UnitClass unit) { unit.maxHealth = maxHealth; unit.currentHealth = maxHealth; unit.att = att; unit.def = def; unit.currentSpeed = maxSpeed; unit.currentPower = maxPower; unit.maxSpeed = maxSpeed; unit.maxPower = maxPower; }
public bool AddUnitClass(UnitClass unitClass) { if (_UnitClasses.Find(delegate(UnitClass u) { return(u.Id == unitClass.Id); }) == null) { Debug.Log(string.Format("Adding unitclass: {0}", unitClass.UnitClassShortName)); _UnitClasses.Add(unitClass); return(true); } return(false); }
public void ProcessTurnAI(UnitClass unit, GameBoard board) { controlledUnit = unit; gameBoard = board; if (!RUNNING_AI && unit != null) { RUNNING_AI = true; StartCoroutine(CheckMovesAI()); } }
public static void HighlightAOE(GameBoard gameBoard, UnitClass unit, Tile hoveredTile) { if (hoveredTile.roundedPosition.x > unit.transform.position.x) { foreach (Tile tile in gameBoard.TileArray) { if ((Mathf.RoundToInt(tile.roundedPosition.z) == unit.transform.position.z && (tile.roundedPosition.x > unit.transform.position.x) && (tile.roundedPosition.x <= unit.transform.position.x + 3))) { tile.highlightPlane.SetActive(true); } } } if (hoveredTile.roundedPosition.x < unit.transform.position.x) { foreach (Tile tile in gameBoard.TileArray) { if ((Mathf.RoundToInt(tile.roundedPosition.z) == unit.transform.position.z && (tile.roundedPosition.x < unit.transform.position.x) && (tile.roundedPosition.x >= unit.transform.position.x - 3))) { tile.highlightPlane.SetActive(true); } } } if (hoveredTile.roundedPosition.z > unit.transform.position.z) { foreach (Tile tile in gameBoard.TileArray) { if ((Mathf.RoundToInt(tile.roundedPosition.x) == unit.transform.position.x && (tile.roundedPosition.z > unit.transform.position.z) && (tile.roundedPosition.z <= unit.transform.position.z + 3))) { tile.highlightPlane.SetActive(true); } } } if (hoveredTile.roundedPosition.z < unit.transform.position.z) { foreach (Tile tile in gameBoard.TileArray) { if ((Mathf.RoundToInt(tile.roundedPosition.x) == unit.transform.position.x && (tile.roundedPosition.z < unit.transform.position.z) && (tile.roundedPosition.z >= unit.transform.position.z - 3))) { tile.highlightPlane.SetActive(true); } } } }
// <en> Unit constructor <ru> Конструктор юнитов public Unit(int UnitId, int UnitHp, int AvatarTex, GameObject gUnit, UnitClass valUnitClass) { this.UnitId = UnitId; this.UnitHpMax = UnitHpMax; this.UnitHpCur = UnitHpCur; this.ModelId = ModelId; this.UnitDam = UnitDam; this.AvatarTex = AvatarTex; this.gUnit = gUnit; this.valUnitClass = valUnitClass; }
private void PurchaseSUnit(UnitClass unitClass) { GameEngine.GetInstance().audioManager.PlayAudio(AudioManager.BUTTON_CLICK_SOUND); if (GameEngine.GetInstance().sChoosers < 1) { GameEngine.GetInstance().messageQueue.PushMessage("Cannot purhcase unit. No S Choosers available", MessageType.NEGATIVE); return; } GameEngine.GetInstance().unitSpawner.CreatePlayerUnit(PlayerUnitRank.S, unitClass); GameEngine.GetInstance().DecrementSBonusTokenCount(); }
public void AddUnit(UnitClass unit) { using (var client = new MyCouchClient("http://31.132.4.108:5984", "dropzoneunits")) { string output = JsonConvert.SerializeObject(unit); var response = client.Documents.PostAsync(output); MessageBox.Show("Unit Added Sucesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void LoadClassDataFromXml() { GameManager.Instance.GameData.InitAllData(); Country country = GameManager.Instance.GetCountryById("no"); UnitClass unitclass = GameManager.Instance.GetUnitClassById("f22"); UnitClass unitclass2 = GameManager.Instance.GetUnitClassById("notexisting"); Assert.IsNotNull(country, "Country should not be null."); Assert.IsNotNull(unitclass, "UnitClass should not be null."); Assert.IsNull(unitclass2, "UnitClass2 should be null."); //GameManager.Instance.TerminateGame(); }
public UnitType(string name, UnitClass unitClass, int movement, int maxHealth, int productionCost, int maxFuel = -1, int cargoSize = 1, int cargoSpace = 0, params UnitType[] cargoTypes) { this.name = name; this.unitClass = unitClass; this.movement = movement; this.maxHealth = maxHealth; this.productionCost = productionCost; this.maxFuel = maxFuel; this.cargoSize = cargoSize; this.cargoSpace = cargoSpace; this.cargoTypes = cargoTypes; }
public Unit CreateInstance(string name, UnitClass unitClass, Alignment alignment, Weapon.WeaponType useable, Element affinity, Stats stats, Stats.GrowthRates growthRates) { Unit instance = CreateInstance <Unit>(); instance.name = name; instance.unitClass = unitClass; instance.alignment = alignment; instance.useable = useable; instance.affinity = affinity; instance.stats = new Stats(stats, growthRates); return(instance); }
string InspectUnitText(string uiText, UnitClass unit) { uiText = unit.Name; uiText += "\r\n"; uiText += "HP: " + unit.CurrentHealth + "/" + unit.Health; uiText += "\r\n"; uiText += "Move\t: " + unit.Move; uiText += "\r\t\n"; uiText += "Defence: " + unit.Defence; uiText += "\r\n"; uiText += "Attack: " + unit.Attack; return(uiText); }
public static void HighlightAOE(GameBoard gameBoard, UnitClass unit, Tile hoveredTile) { foreach (Tile tile in gameBoard.TileArray) { if ((tile.roundedPosition.z >= hoveredTile.roundedPosition.z - 1) && (tile.roundedPosition.z <= hoveredTile.roundedPosition.z + 1) && (tile.roundedPosition.x >= hoveredTile.roundedPosition.x - 1) && (tile.roundedPosition.x <= hoveredTile.roundedPosition.x + 1)) { tile.highlightPlane.SetActive(true); } } }
private void HandleUnitClass(IMarshallable dataReceived) { UnitClass unitClass = dataReceived as UnitClass; if (GameManager.Instance.AddUnitClass(unitClass)) { Debug.Log("UnitClass Added"); } else { Debug.Log("UnitClass not added. Already exists"); } }
public void renderUnitData(UnitClass unit) { levelTxt.text = unit.level.ToString(); classTxt.text = unit.classToString(); nameTxt.text = unit.firstName + " " + unit.lastName; hpTxt.text = unit.currentHealth.ToString() + " / " + unit.maxHealth.ToString(); atkTxt.text = unit.att.ToString(); defTxt.text = unit.def.ToString(); speedTxt.text = unit.maxSpeed.ToString(); critTxt.text = unit.crit.ToString(); dodgeTxt.text = unit.dodge.ToString(); squadTxt.text = unit.squad == 0 ? "Active" : "Reserve"; }
public void UpdateUnit(UnitClass unit) { using (var client = new MyCouchClient("http://31.132.4.108:5984", "dropzoneunits")) { string output = JsonConvert.SerializeObject(unit); string unitID = unit.GetCouchID(); var response = client.Documents.PutAsync(unitID, unit.GetCouchRev(), output); MessageBox.Show("Unit Updated Sucesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public IEnumerator AIMove() { List <UnitClass> enemies; UnitClass aiUnit = Controller.instance.currentUnit; //get info if (aiUnit.PlayerSide) { enemies = EnemyUnits(); } else { enemies = PlayerUnits(); } // Follow nearest enemy List <CellClass> moves = Pathfinder.FindPath(aiUnit.Cell, GridClass.instance, aiUnit.Move); // List<CellClass> allMoves = Pathfinder.FindPath( aiUnit.Cell, GridClass.instance, int.MaxValue ); List <CellClass> adjacents = new List <CellClass>(); if (moves.Count != 0) { foreach (UnitClass u in enemies) // Find each cell adjacent to enemy within move range { foreach (CellClass c in u.Cell.adjacentCells) { if (moves.Contains(c)) { adjacents.Add(c); } } } if (adjacents.Count != 0) { adjacents.Sort((CellClass a, CellClass b) => a.Distance.CompareTo(b.Distance)); if (adjacents[0] != null) { yield return(StartCoroutine(Controller.instance.MoveAction(adjacents[0]))); } Controller.instance.NextTurn(); } else { enemies.Sort((UnitClass a, UnitClass b) => a.Cell.Distance.CompareTo(b.Cell.Distance)); // List< CellClass> fullPath = Pathfinder.TracePath( enemies[0].Cell, aiUnit.Cell ); Pathfinder.TracePath(enemies[0].Cell, aiUnit.Cell); } } yield return(null); }
private void ActivateAreas(int n) { for (int i = 0; i < n; i++) { UpgradeArea area = GetRandomDisabledArea(); UnitClass uClass = (UnitClass)Random.Range(0, 4); area.SetAreaClass(uClass); int turns = Random.Range(_activateAreaTime.x, _activateAreaTime.y); StartCoroutine(ActivateArea(turns, area)); _activeAreasCounter++; } }
void FilterUnits() { _AvailableUnits.Clear(); UnitClass filterClass = _UnitClassSelect.Value.Value; foreach (UnitConfigurationLink link in _Links.OrderBy(i => i.UnitConfiguration.Name)) { if ((filterClass == UnitClass.NONE || link.UnitConfiguration.UnitClass == filterClass) && _Parameters.Matches(link)) { _AvailableUnits.Add(link); } } }
public static int UseHealthPotion(UnitClass unit) { int restoreAmount = (int)((unit.unitHPMax * HP_RESTORE_PERCENTAGE) / 100); if ((unit.unitHP + restoreAmount) > unit.unitHPMax) { unit.unitHP = unit.unitHPMax; } else { unit.unitHP = unit.unitHP + restoreAmount; } return(restoreAmount); }
// Pathfinder to find valid attack cells public void FindUnitAttack() { if (waitForUI) { return; } cursorMode = CursorMode.showAttack; ClearPath(); // currentUnit = units[currentTurn];UnitManager.instance. currentUnit = UnitManager.instance.units[currentTurn]; cells = Pathfinder.FindPath(currentUnit.Cell, GridClass.instance, currentUnit.Reach, currentUnit); ShowAttackArea(); HighLightCell(currentUnit.Cell); }
public Unit(UnitController _template) { this.Designation = _template.Designation; this.shipClass = _template.shipClass; this.displayName = _template.displayName; this.faction = _template.faction.FactionName; this.actionPoints = _template.baseActionPoints; this.initiative = _template.baseInitiative; this.health = _template.baseHealth; this.evasion = _template.baseEvasion; this.enginesHealth = _template.baseMovementRange; this.weaponsHealth = _template.baseEnginesHealth; this.movementRange = _template.baseWeaponsHealth; }
public Unit(resourceManager resourceManager, string newName, string newRace, string newClass, int newClassVariantIndex) { name = newName; race = resourceManager.getRace(newRace); unitClass = resourceManager.getClass(newClass); streght = new Ability(unitClass.getAbility(0).getScore()); constitution = new Ability((unitClass.getAbility(1).getScore())); dexterity = new Ability((unitClass.getAbility(2).getScore())); mind = new Ability((unitClass.getAbility(3).getScore())); charisma = new Ability((unitClass.getAbility(4).getScore())); setMaxHeath(); setHealth("SET", healthPoints[1]); classVariantIndex = newClassVariantIndex; }
public void AttemptUpgrade(UnitClass unitClass) { int upgradeCost = GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass); if (GameEngine.GetInstance().gas >= upgradeCost) { GameEngine.GetInstance().DecreaseGas(upgradeCost); GameEngine.GetInstance().upgradeManager.IncrementUpgradeClass(unitClass); GameEngine.GetInstance().upgradePanel.UpdateUpgradePanelData(unitClass); } else { GameEngine.GetInstance().upgradePanel.DisplayCantAffordUpgradeMessage(unitClass, upgradeCost); } }
void SetClassImage(UnitClass unitClass) { if (unitClass == UnitClass.Melee) { classImage.sprite = Resources.Load("Icon/meleeClass", typeof(Sprite)) as Sprite; } else if (unitClass == UnitClass.Magic) { classImage.sprite = Resources.Load("Icon/magicClass", typeof(Sprite)) as Sprite; } else { classImage.sprite = Resources.Load("Icon/transparent", typeof(Sprite)) as Sprite; } }
/// <summary> /// ユニット種類リストボックスの表示項目を更新する /// </summary> private void UpdateTypeListBox() { typeListBox.BeginUpdate(); int top = typeListBox.TopIndex; int i = 0; foreach (UnitType type in Units.UnitTypes) { UnitClass unit = Units.Items[(int)type]; typeListBox.Items[i] = unit; i++; } typeListBox.TopIndex = top; typeListBox.EndUpdate(); }
// Pathfinder to find valid move cells public void FindUnitMove() { if (waitForUI) { return; } cursorMode = CursorMode.showMove; ClearPath(); // currentUnit = units[currentTurn]; currentUnit = UnitManager.instance.units[currentTurn]; cells = Pathfinder.FindPath(currentUnit.Cell, GridClass.instance, currentUnit.Move); ShowMoveArea(); HighLightCell(currentUnit.Cell); InspectorActionText(); }
public override bool CheckCondition() { bool hasInfantry = false; bool hasMech = false; bool hasLaser = false; bool hasPsionic = false; bool hasAcid = false; bool hasBlade = false; GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit"); foreach (GameObject g in playerUnits) { PlayerUnit playerUnit = g.GetComponent <PlayerUnit>(); if (playerUnit.GetPlayerUnitData().GetRank() != PlayerUnitRank.D) { continue; } UnitClass unitClass = playerUnit.GetPlayerUnitData().GetUnitClass(); if (unitClass == UnitClass.INFANTRY) { hasInfantry = true; } else if (unitClass == UnitClass.MECH) { hasMech = true; } else if (unitClass == UnitClass.LASER) { hasLaser = true; } else if (unitClass == UnitClass.PSIONIC) { hasPsionic = true; } else if (unitClass == UnitClass.ACID) { hasAcid = true; } else if (unitClass == UnitClass.BLADE) { hasBlade = true; } } return(hasInfantry && hasMech && hasLaser && hasPsionic && hasAcid && hasBlade); }
public void SetUnitClassUpgradeDataDisplay(UnitClass unitClass) { switch (unitClass) { case UnitClass.INFANTRY: InfantryLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; InfantryCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.MECH: MechLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; MechCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.LASER: LaserLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; LaserCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.PSIONIC: PsionicLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; PsionicCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.ACID: AcidLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; AcidCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.BLADE: BladeLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; BladeCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.MAGIC: MagicLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; MagicCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; case UnitClass.FLAME: FlameLevel.text = GameEngine.GetInstance().upgradeManager.GetNumUpgrades(unitClass) + ""; FlameCost.text = "Cost: " + GameEngine.GetInstance().upgradeManager.GetUpgradeCost(unitClass) + " Gas"; break; default: throw new GameplayException("Unrecognized Unit Class: " + unitClass.ToString()); } }
public override bool CheckCondition() { int numInfantry = 0; int numMech = 0; int numLaser = 0; int numPsionic = 0; int numAcid = 0; int numBlade = 0; GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit"); foreach (GameObject g in playerUnits) { PlayerUnit playerUnit = g.GetComponent <PlayerUnit>(); if (playerUnit.GetPlayerUnitData().GetRank() != PlayerUnitRank.C) { continue; } UnitClass playerUnitClass = playerUnit.GetPlayerUnitData().GetUnitClass(); if (playerUnitClass == UnitClass.INFANTRY) { numInfantry += 1; } else if (playerUnitClass == UnitClass.MECH) { numMech += 1; } else if (playerUnitClass == UnitClass.LASER) { numLaser += 1; } else if (playerUnitClass == UnitClass.PSIONIC) { numPsionic += 1; } else if (playerUnitClass == UnitClass.ACID) { numAcid += 1; } else if (playerUnitClass == UnitClass.BLADE) { numBlade += 1; } } return((numInfantry >= 3) && (numMech >= 3) && (numLaser >= 3) && (numPsionic >= 3) && (numAcid >= 3) && (numBlade >= 3)); }
public static void SetIndicators(GameBoard gameBoard, UnitClass unit) { gameBoard.HideIndicatorPlanes(); foreach (Tile tile in gameBoard.TileArray) { if ((tile.roundedPosition.z >= unit.transform.position.z - 3) && (tile.roundedPosition.z <= unit.transform.position.z + 3) && (tile.roundedPosition.x >= unit.transform.position.x - 3) && (tile.roundedPosition.x <= unit.transform.position.x + 3)) { tile.currentUnit = unit; tile.SetAbilityIndicator(abilityName); } } }
public override void classTick(UnitClass unit) { // Self Healing float healAmount = unit.maxHealth * 0.05F; if (unit.healingCounter <= 0) { if (unit.currentHealth + healAmount > unit.maxHealth) unit.currentHealth = unit.maxHealth; else unit.currentHealth += (int)healAmount; unit.healingCounter = maxHealingCounter; print(unit.firstName + " self healed for " + (int)healAmount + " points!!"); } else unit.healingCounter--; }
public override void receiveDmgAbility1(List<UnitClass> units, UnitClass target, ref int ally, ref bool activated) { if(Random.Range(0.0F, 1.0F) <= 0.1F) { // Defend Allies - 10% chance print("-------------------------" + target.firstName + " defended ally " + units[ally].firstName + "!!!!"); for (int i = 0; i < 4; i++) { if (units[i] == target) { ally = i; activated = true; break; } } } }
void OnGUI() { if (selectionAgent.selected && state != UnitState.Spawn) { if (GUI.Button(new Rect(20, 20, 100, 20), "Spawn fast")) { state = UnitState.Spawn; spawnType = UnitClass.Fast; } if (GUI.Button(new Rect(20, 50, 100, 20), "Spawn slow")) { state = UnitState.Spawn; spawnType = UnitClass.Slow; } } if (state == UnitState.Spawn) { if (GUI.Button(new Rect(20, 20, 100, 20), "Exit spawning")) { state = UnitState.Defend; } } }
private bool HasEnoughMoney(UnitClass tmpUnitScript) { int tmpCost = tmpUnitScript.cost[GameProperties_CT.levelOfAllUnits[tmpUnitScript.type][ENUMS.PROPERTIES.Cost]]; if (GameProperties.credits >= tmpCost) { return true; } else { GameProperties_CT.AddMessage("Du hast nicht genug Geld (" + tmpCost.ToString() + ")"); return false; } }
// Use this for initialization public virtual void Start() { _class = gameObject.GetComponent<UnitClass> (); current_ap = 0; bm = GameObject.Find ("BattleManager").GetComponent<BattleManager> (); seeker = GetComponent<Seeker>(); name = name + " team: " + team; controller = GetComponent<CharacterController>(); }
public virtual void classChange(UnitClass unit) { }
// Alters the stats of enemies depending on the hex coordinates void setEnemyStats(ref UnitClass unit, int x, int y) { unit.maxHealth += unit.maxHealth*(x+1); // temporary unit.currentHealth = unit.maxHealth; }
// Adds a unit when called (e.g. start new game, recruit a new member) void addNewUnit(bool player, int classType, int battleSquad=1, int x=0, int y=0, int enemyIndex=0) { UnitClass newUnit = new UnitClass(); nameSelector.getName(); newUnit.changeName(nameSelector.firstName, nameSelector.lastName); newUnit.classType = classType; newUnit.classChange(); if(player) { allPlayerUnits.Add(newUnit); print("Added Player: " + newUnit.firstName + " " + newUnit.lastName); } else { setEnemyStats(ref newUnit, x, y); allEnemyUnits[enemyIndex].Add(newUnit); print("Added Enemy!"); } }
public virtual void classTick(UnitClass unit) { }
// Performs the attack of the unit, boolean is set true for player and false for enemy void unitAttack(UnitClass unit, bool isPlayer) { int randomTarget; int attackDamage; bool activated = false; List<UnitClass> allUnits; // Set the allUnits variable as appropriate and a random target randomly if (isPlayer) { allUnits = enemyUnits; randomTarget = getRandomEnemy(); } else { allUnits = playerUnits; randomTarget = getRandomPlayer(); } // Check if there is a living class that can modify damage received (e.g. defender) foreach (UnitClass targetUnit in allUnits) { if (!targetUnit.deadFlag && targetUnit != allUnits[randomTarget] && !activated && targetUnit.getClassScript().returnReceiveDmgModify()) { targetUnit.getClassScript().receiveDmgAbility1(allUnits, targetUnit, ref randomTarget, ref activated); } } attackDamage = (int)(unit.att * Random.Range(2 / 3f, 4 / 3f)); // Temporarily use this range instead of dexterity allUnits[randomTarget].currentHealth -= attackDamage; print(unit.firstName + " attacks " + allUnits[randomTarget].firstName + " for " + attackDamage + " damage!"); }
public override void classTick(UnitClass unit) { }
// Overload the ShowMenu function to use for unit panel public void ShowMenu(Menu menu, int unitIndex) { if (currentMenu != null) currentMenu.IsOpen = false; unitRenderScript.renderUnitData(allPlayerUnits[unitIndex]); currentUnit = allPlayerUnits[unitIndex]; currentMenu = menu; currentMenu.IsOpen = true; }
public static string UnitClassToString(UnitClass Class) { switch (Class) { case UnitClass.Infantry: return R.String("Infantry"); case UnitClass.Cavalry: return R.String("Cavalry"); case UnitClass.Artillery: return R.String("Artillery"); case UnitClass.AirForce: return R.String("AirForce"); case UnitClass.Navy: return R.String("Navy"); default: return null; } }
public override void receiveDmgAbility1(List<UnitClass> units, UnitClass target, ref int ally, ref bool activated) { }
public void ablilityHeal(UnitClass unit) { //unit.currentHealth += }