Ray shootRay; // A ray from the gun end forwards. #endregion Fields #region Methods public void Attack(UnitStats targetHealth) { if (targetHealth != null) { targetHealth.TakeDamage(damagePerHit); } }
void Awake() { agent = GetComponent<NavMeshAgent>(); obstacle = GetComponent<NavMeshObstacle>(); m_Animation = GetComponentInChildren<Animation>(); enemyAttack = GetComponent<EnemyAttack>(); stats = GetComponent<UnitStats>(); m_AudioSource = GetComponent<AudioSource>(); baseAttackSpeedCache = timeBetweenAttacks; switch (unitType) { case EnemyTypes.Minion: selectedAction = "Punch"; break; case EnemyTypes.Brute: selectedAction = "Slam"; break; case EnemyTypes.Evoker: selectedAction = "Shoot"; break; case EnemyTypes.Bob: selectedAction = "Explode"; break; default: break; } }
public void Heal(float healAmount, UnitStats healTarget) { if (healTarget != null) { healTarget.Heal(healAmount); } }
public Blueprint_Battle(int ammo, float reload_time, float rate, float damage, float hp, float attk, float defense, float shield) { battleStats = new TowerGunStats(ammo, reload_time); unitStats = new UnitStats(); unitStats.InitStartingStats(hp, defense, attk, shield, rate, damage, 0); unitStats.Init(); tileStats = new TileStats(hp, defense, attk, shield, nanoBotCost); }
public void AttackTarget(GameObject target) { if(target.tag == targetTag){ attackingTarget = true; targetToAttack = target; targetStats = target.GetComponent<UnitStats>(); } }
public void Heal(float healAmount, UnitStats healTarget) { if (healTarget != null) { Debug.Log("Applying Heal"); healTarget.Heal(healAmount); } }
// Use this for initialization void Start() { //master = GameObject.FindWithTag("masterMind").GetComponent<MasterMindTranslate>(); master = GameObject.FindWithTag("masterMind").GetComponent<SynchronizeORCA>(); stats = GetComponentInParent<UnitStats>(); agents = master.agents; gun = GetComponent<GunModule>(); }
// Constructor for an Enemy with no alternate target (attacks player OR Terraformer) public Enemy(string n, UnitStats unitStats, Enemy_PathHandler.MovementStats moveStats, int cost, bool chasesP, bool isAggro = false) { name = n; isAggroToBuildings = isAggro; UnitStats = unitStats; MovementStats = moveStats; chasesPlayer = chasesP; spawnCost = cost; }
public void Shoot(UnitStats targetHealth) { gameObject.transform.LookAt(targetHealth.gameObject.transform); if (targetHealth != null) { // ... the enemy should take damage. targetHealth.TakeDamage(damagePerHit); } }
void Awake() { m_EnemyAttack = GetComponent<EnemyAttack>(); m_Animation = GetComponentInChildren<Animation>(); m_AudioSource = GetComponent<AudioSource>(); m_ParticleSystem = GetComponentInChildren<ParticleSystem>(); stats = GetComponent<UnitStats>(); pathNodeCollection = navPath.GetComponentsInChildren<PathNode>(); }
public void AreaExplode(Vector3 center, float radius, float damage, GameObject source, int attackMask) { Collider[] hitColliders = Physics.OverlapSphere(center, radius, attackMask); for (int i = 0; i < hitColliders.Length; i++) { cache = hitColliders[i].gameObject.GetComponent<UnitStats>(); cache.TakeDamage(damage); } }
Buff(UnitManager source, float totalDuration, UnitStats flatStats, UnitStats percentStats, UnitFlags flags, List<SerializableEffect> periodicEffects, float period, string animationBool) { this.source = source; this.totalDuration = totalDuration; this.duration = 0; this.flatStats = flatStats; this.percentStats = percentStats; this.flags = flags; this.periodicEffects = new List<SerializableEffect> (periodicEffects); this.period = period; this.animationBool = animationBool; }
public void DeEnergizeTowerUnit(UnitStats tower) { Debug.Log("DeEnergizing!!"); Debug.Log("BEFORE: Attack " + tower.curAttack + " Damage " + tower.curDamage); // Set stats back to starting values tower.curAttack = tower.startAttack; tower.curRateOfAttk = tower.startRate; tower.curDamage = tower.startDamage; tower.curReloadSpeed = tower.startReloadSpd; Debug.Log("AFTER: Attack " + tower.curAttack + " Damage " + tower.curDamage); }
public void AreaStun(Vector3 center, float radius, float damage, float duration, GameObject source, int attackMask) { Collider[] hitColliders = Physics.OverlapSphere(center, radius, attackMask); for (int i = 0; i < hitColliders.Length; i++) { cache = hitColliders[i].gameObject.GetComponent<UnitStats>(); cache.TakeDamage(damage); if (!cache.stunImmunity) cache.ApplyStatus(UnitStats.statusEffects.stun, duration); } }
public Unit createUnitAt(int x, int y, Unit.Team team, UnitStats stats) { Tile t = GetComponent<StageManager>().tiles[x][y]; GameObject go = Instantiate(UnitPrefab, t.transform.position, Quaternion.identity) as GameObject; go.transform.parent = transform; Unit u = go.GetComponent<Unit>(); u.tile = t; t.unit = u; u.team = team; u.stats = stats; return u; }
public void SetDevice( PlayerDevice device ) { this.device = device; unitstats = gameObject.GetComponent<UnitStats>(); movement = gameObject.GetComponent<Movement>(); skeletonAnimation = gameObject.GetComponentInChildren<SkeletonAnimation>(); skeletonAnimation.state.Event += Event; skeletonAnimation.UpdateBones += UpdateBones; skeletonAnimation.state.End += End; head = gameObject.GetComponentInChildren<SkeletonAnimation>().skeleton.FindBone("head"); hip = gameObject.GetComponentInChildren<SkeletonAnimation>().skeleton.FindBone("body"); weaponmanager = gameObject.GetComponentInChildren<WeaponManager>(); meleemanager = gameObject.GetComponentInChildren<MeleeManager>(); GameObject gameGameObject = GameObject.FindGameObjectWithTag( "Level" ); level = gameGameObject.GetComponent<LevelInfo>(); }
// Default Constructor (1 Weapon, Armor, and 1 Tool) with Initial NanoBuilder public Hero(string name, Weapon weapon, Armor _armor, Tool tool, float maxHP, float curHP, float attk, NanoBuilder builder = null) { heroName = name; weapons.Add(weapon); armor = _armor; tools.Add(tool); heroStats = new UnitStats(maxHP, attk, armor.armorStats._curDefense, armor.armorStats._curShield); heroStats.curHP = curHP; if (builder == null) nanoBuilder = new NanoBuilder(); else nanoBuilder = builder; }
// Use this for initialization void Start() { stats = GetComponent<UnitStats>(); BarricadeWaypoint[] temp = GetComponentsInChildren<BarricadeWaypoint>(); stats.maxHealth = maxHealth; foreach(var curr in temp) { //curr.waypointOwner = this; if (curr.tag == "Front Waypoint") frontWaypoints.Add(curr); else backWaypoints.Add(curr); } }
void Update() { ray = MainCamera.ScreenPointToRay (Input.mousePosition); if (Physics.Raycast (ray, out hit, 100)) { HighlightedObject = hit.transform.gameObject; HighlightedParentObject = HighlightedObject.transform.parent.gameObject; //Debug.Log ("Highlighted object - " + HighlightedParentObject.name + " / " + HighlightedObject.name); if (isMaterialChanged) { HighlightedTemp.GetComponent<Renderer>().material.color = tempColor; isMaterialChanged = false; } if (HighlightedObject.tag == "Hex") { isMaterialChanged = true; rend = HighlightedObject.GetComponent<Renderer>(); ObjectMat = rend.material; tempColor = ObjectMat.color; ObjectMat.color = new Color(0.9f,0.9f,0.0f,0.0f); } HighlightedTemp = HighlightedObject; } if (HighlightedObject.tag == "Unit") { stats = HighlightedObject.GetComponent<UnitStats> (); if (Input.GetMouseButtonDown(1)) { statText = "Type: " + stats.UnitType + "\nHP: " + stats.CurrentHP + "/20"; statText += "\nAttack: " + stats.Attack + "\nDefense: " + stats.Defense; statText += "\nSpeed: " + stats.Speed + "\nRange: " + stats.Range; text.text = statText; canvas.enabled = true; } } if (canvas.enabled && Input.GetMouseButtonUp(1)) canvas.enabled = false; }
public static Sprite CreateNewSprite(String path) { Sprite result = new Sprite(new List<Sprite.SpriteAction>()); string line; System.IO.StreamReader file = new System.IO.StreamReader("Content/Stats/NPCStats.txt"); while ((line = file.ReadLine()) != null) { char[] delimiters = new char[] { ',' }; string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); UnitStats u = new UnitStats(); u.init(parts); if(u.model.CompareTo(path)==0) { result.setParam(u, 0, 0); return result; } } return result; }
public void AddSmallPortrait(UnitStats stats) { Character character = ResourcesManager.instance.GetCharacter(stats.CharID); GameObject g = Instantiate(smallPortraitTemplte, characterGridTrans) as GameObject; g.SetActive(true); //g.transform.SetParent(charcaterGrid.transform); GridLayoutGroup grid = charcaterGrid.GetComponent <GridLayoutGroup>(); Vector2 newPos = characterGridTrans.anchoredPosition; newPos.y += grid.cellSize.y + grid.spacing.y; //characterGridTrans.anchoredPosition = newPos; SmallPortrait sm = g.GetComponent <SmallPortrait>(); sm.Portrait.sprite = character.portraiteIcon; sm.CharID = stats.CharID; }
public void Start() { unitName = GetComponentInChildren <UnitName>(); unitPortrait = GetComponentInChildren <UnitPortrait>(); unitHealth = GetComponentInChildren <UnitHealth>(); unitStats = GetComponentInChildren <UnitStats>(); activeName = unitName.GetComponent <Text>(); healthSlider = unitHealth.GetComponent <Slider>(); activePortrait = unitPortrait.GetComponent <Image>(); stat1Description = unitStats.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals(stat1DescriptionText)); stat2Description = unitStats.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals(stat2DescriptionText)); stat3Description = unitStats.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals(stat3DescriptionText)); stat4Description = unitStats.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals(stat4DescriptionText)); stat1Value = stat1Description.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals("100")); stat2Value = stat2Description.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals("100")); stat3Value = stat3Description.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals("100")); stat4Value = stat4Description.GetComponentsInChildren <Text>().FirstOrDefault(s => s.text.Equals("100")); }
public void Attack() { if (ScriptLink.mouseController.SelectedUnit.GetComponent <Unit>().canAttack == false) { return; } attackingUnit = ScriptLink.mouseController.SelectedUnit; defendingUnit = ScriptLink.mouseController.EnemyUnit; attackingUnitStats = attackingUnit.GetComponent <UnitStats>(); defendingUnitStats = defendingUnit.GetComponent <UnitStats>(); CalculateFightResult(); RemoveDistantDefenseBuff(); CleanUpDeadUnits(); ScriptLink.mouseController.SelectedUnit.GetComponent <Unit>().canAttack = false; ScriptLink.mouseController.SelectedUnit.GetComponent <Unit>().canMove = false; ScriptLink.mouseController.UnselectUnit(); }
public GameObject BuildCardAI(string unitType, int aiLevel) { unitName = unitType; newCard = Instantiate(cardPrefab); //newCard.SetActive(false); unitCardScript = newCard.GetComponent <UnitCard>(); unitStatsScript = newCard.GetComponent <UnitStats>(); BuildLists(); // get how many stats will be affected on the card GetNumberOfAffectedStats(aiLevel); // get which stats on the card will be affected GetRandomStatTypesToAffect(); // Set the current and maximum possible stats for each selected type based on player level SetStatAmounts(); // build the card visuals CreateCardVisuals(); return(newCard); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.C)) { statsPanel.SetActive(!statsPanel.activeSelf); } if (statsPanel.activeSelf) { UnitStats unitStats = turnManager.activePlayer.creature.stats; healthText.text = $"HP: {unitStats.health} / {unitStats.maxHealth}"; pAttackText.text = $"Physical Attack: {unitStats.physicalAttack}"; pDefenseText.text = $"Physical Defense: {unitStats.physicalDefense}"; mAttackText.text = $"Magic Attack: {unitStats.magicAttack}"; mDefenseText.text = $"Magic Defense: {unitStats.magicDefense}"; movementText.text = $"Movement: {turnManager.activePlayer.creature.movementLeft} / {unitStats.movement}"; initiativeText.text = $"Initiative: {unitStats.speedIntit}"; roleText.text = $"Role: {unitStats.role}"; } }
public void DealDamageToTarget(UnitStats target) { if (ability.abilityType == AbilityType.Physical) { int dmg = Mathf.RoundToInt(ability.damage * (((flow.currentUnit.modAttack * flow.currentUnit.modAttack) / 6) + ability.damage) / 4); int defNum = Mathf.RoundToInt((((target.modDefense - 280.4f) * (target.modDefense - 280.4f) / 110) + 16)); int dmg2 = (dmg * defNum) / 730; int finalDmg = dmg2 * (730 - (target.modDefense * 51 - (target.modDefense * target.modDefense) / 11) / 10) / 730; int modFinalDmg = finalDmg; if (target.charMode == Mode.Defense) { modFinalDmg = Mathf.RoundToInt(modFinalDmg / 2); } target.ReceiveDamage(modFinalDmg); ui.ShowDamageText(target, modFinalDmg); } else { int dmg = Mathf.RoundToInt(ability.damage * (((flow.currentUnit.modMagAttack * flow.currentUnit.modMagAttack) / 6) + ability.damage) / 4); int defNum = Mathf.RoundToInt((((target.modMagDefense - 280.4f) * (target.modMagDefense - 280.4f) / 110) + 16)); int dmg2 = (dmg * defNum) / 730; int finalDmg = dmg2 * (730 - (target.modMagDefense * 51 - (target.modMagDefense * target.modMagDefense) / 11) / 10) / 730; int modFinalDmg = finalDmg; if (target.charMode == Mode.Defense) { modFinalDmg = Mathf.RoundToInt(modFinalDmg / 2); } target.ReceiveDamage(Mathf.RoundToInt(modFinalDmg)); ui.ShowDamageText(target, modFinalDmg); } if (target.IsDead()) { target.battleAnimator.GetComponent <Animator>().Play("Die"); flow.units.Remove(target); } else { target.battleAnimator.GetComponent <Animator>().Play("Hit" + target.facing.ToString()); } }
// Use the top skill in the currSkill stack and executes it private void UseSkill(UnitStats stats) { // If there are no skills in the currSkills stack, exit the function if (stats.currSkills.Count <= 0) { return; } Skill skill = stats.currSkills.Pop(); // Get the top skill and remove it from the stack stats.stamina -= skill.SPCost; // Subtracts SPCost from unit's stamina switch (skill.type) { // If it's a damaging skill, damage (and possibly defeat) the opponent, gain experience case "Damage": Damage(stats, skill.power); break; // If it's a utility skill, use a custom effect case "Utility": switch (skill.name) { // TODO: [ Fill in cases as necessary for what to do for utility skills ] // [ Placeholder ] case "Barrier": playerStats[uIndex].defense *= 2; AddBattleLog(playerStats[uIndex].charName + "'s defense is doubled!"); break; default: break; } break; default: break; } // TODO: [ Do skill animation ] }
public override float GetMVCost(UnitMapComponent MapComponent, UnitStats UnitStat, MovementAlgorithmTile CurrentNode, MovementAlgorithmTile TerrainToGo) { float MovementCostToNeighbor = 0; if (MapComponent.CurrentMovement == "Air") { if (Map.GetTerrainLetterAttribute(UnitStat, "Air") == 'C' || Map.GetTerrainLetterAttribute(UnitStat, "Air") == 'D' || Map.GetTerrainLetterAttribute(UnitStat, "Air") == '-') { MovementCostToNeighbor += 0.5f; } else { MovementCostToNeighbor += 1; } } else { char TerrainCharacter = Map.GetTerrainLetterAttribute(UnitStat, Map.GetTerrainType(TerrainToGo)); if ((TerrainCharacter == 'C' || TerrainCharacter == 'D' || TerrainCharacter == '-') && Map.GetTerrainType(TerrainToGo) != "Land") { MovementCostToNeighbor += TerrainToGo.MVMoveCost + 0.5f; } else if (TerrainCharacter == 'S' && TerrainToGo.MVMoveCost > 1) { MovementCostToNeighbor += TerrainToGo.MVMoveCost / 2; } else { MovementCostToNeighbor += TerrainToGo.MVMoveCost; } if (TerrainToGo.TerrainTypeIndex != GetTile(CurrentNode.Position.X, CurrentNode.Position.Y, MapComponent.LayerIndex).TerrainTypeIndex) { MovementCostToNeighbor += TerrainToGo.MVEnterCost; } } return(MovementCostToNeighbor); }
void SetEnemies() { GameObject[] _enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject unit in _enemies) { UnitStats stats = unit.GetComponent <UnitStats> (); int _rng = Random.Range(1, 10); stats.setStats(_rng); } for (int i = 0; i < _enemies.Length; i++) { _enemies [i].GetComponent <UnitStats> ().patrolArea = i + 1; if (_enemies.Length > 4) { _enemies [i].GetComponent <UnitStats> ().patrolArea = 0; } } }
private void Start() { playersStats = charSelectPortrait.GetOwner().GetComponent <UnitStats>(); if (charSelectPortrait != null) { Debug.Log($"This Affliction Statuts objects owner is : {charSelectPortrait.GetCharName()}", this); } switch (afflictType) { case AfflictionType.Attack: playersStats.attackIsUp += MakeVisible; break; case AfflictionType.Defense: playersStats.defenseIsUp += MakeVisible; break; case AfflictionType.Health: playersStats.healthIsUp += MakeVisible; break; } }
private void Awake() { var trans = transform; while (trans.parent) { var unitStatsCompo = trans.parent.GetComponent <UnitStats>(); if (unitStatsCompo) { unitStatsComponent = unitStatsCompo; break; } trans = trans.parent; } if (!unitStatsComponent) { Destroy(this); } unitStatsComponent.SubscribeViewer(this); }
// Use this for initialization void Start() { moveController = gameObject.GetComponent <BasicMovementController>(); animator = gameObject.GetComponent <Animator>(); playerBattleManager = GameObject.Find("PlayerBattleManager"); enemyBattleManager = GameObject.Find("EnemyBattleManager"); playerBattleManagerScript = playerBattleManager.GetComponent <PlayerBattleManager>(); enemyBattleManagerScript = enemyBattleManager.GetComponent <EnemyBattleManager>(); myTargeting = gameObject.GetComponent <BasicTargeting>(); myStats = gameObject.GetComponent <UnitStats>(); myStats.unitCurrentMoveSpeed = myStats.unitMoveSpeed; if (gameObject.tag == "PlayerUnit") { playerBattleManagerScript.mySpawnedUnits.Add(gameObject); } else { enemyBattleManagerScript.mySpawnedUnits.Add(gameObject); } }
// this should transfer the stats from the AI unit cards to the prefab objects // every AI will have a miner, I am skipping the miner for now because they do not have cards // deactivate the object afterwards private void BuildSpawnableUnitsFromCards() { for (int i = 1; i < mySpawnableUnitsPrefab.Count; i++) { GameObject newUnit = Instantiate(mySpawnableUnitsPrefab[i]); newUnit.SetActive(false); newUnit.name = mySpawnableUnitsPrefab[i].GetComponent <UnitStats>().name + " spawner"; newUnit.transform.SetParent(gameObject.transform); UnitStats myNewStats = aiInfo.myUnitCards[i - 1].GetComponent <UnitStats>(); UnitStats myOldStats = newUnit.GetComponent <UnitStats>(); myOldStats.health = myNewStats.health; myOldStats.unitCost = myNewStats.unitCost; myOldStats.unitDamage = myNewStats.unitDamage; myOldStats.unitBuildTime = myNewStats.unitBuildTime; myOldStats.unitCapacity = myNewStats.unitCapacity; myOldStats.unitMoveSpeed = myNewStats.unitMoveSpeed; myOldStats.unitAttackSpeed = myNewStats.unitAttackSpeed; mySpawnableUnits.Add(newUnit); } }
// Start is called before the first frame update void Start() { GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit"); foreach (GameObject unit in playerUnits) { UnitStats stats = unit.GetComponent <UnitStats>(); stats.CalculateNextActTurn(0); unitsQueue.Push(stats); } GameObject[] enemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit"); foreach (GameObject unit in enemyUnits) { UnitStats stats = unit.GetComponent <UnitStats>(); stats.CalculateNextActTurn(0); unitsQueue.Push(stats); } playerParty = GameObject.Find("PlayerParty"); enemyEncounter = GameObject.Find("EnemyEncounter"); StartCoroutine(SendMsgWait("敌人拦在了你面前!", delegate { NextTurn(); })); }
IEnumerator AttackWithCooldown(UnitStats targetStats) { while (isAttacking) { Debug.Log("ATTACKING"); if (targetStats == null) { StopAttack(); Debug.Log("Target possible dead"); break; } else { Debug.Log("GOINH to take damage"); CmdTakeDamage(targetStats.GetComponent <NetworkIdentity> (), myStats.damage.GetValue()); } yield return(new WaitForSeconds(attackSpeed)); } yield return(null); }
void Update() { //this code makes sure that this game object always targets the enemie closest to it //we do this by using the find closest enemy with tag function since there are 3 teams and 3 tags target = movement.FindClosestEnemy(Enemie, "Wizzard").transform; agent.SetDestination(target.position); Debug.DrawLine(gameObject.transform.position, target.transform.position, Color.grey); //drawing a line betwen the game object and its target to see in the debug scene float distance = Vector3.Distance(target.position, transform.position); if (distance <= agent.stoppingDistance) { //when the unit should start attaking is when the target is in range UnitStats targetStats = target.GetComponent <UnitStats>(); if (targetStats != null) { combat.Attack(targetStats); Debug.DrawLine(gameObject.transform.position, target.transform.position, Color.red); } } }
public void SetFormation() { if (myToggle.isOn) { toggleSprite.sprite = toggleOnSprite; myOriginalUnits.Clear(); foreach (GameObject unit in playerBattleManagerScript.mySpawnedUnits) { if (unit != null) { UnitStats unitStats = unit.GetComponent <UnitStats>(); myOriginalUnits.Add(unit); unitStats.unitCurrentMoveSpeed = 30; } } } else { toggleSprite.sprite = toggleOffSprite; RemoveFormation(); } }
public override void readFromNbt(NbtCompound tag) { base.readFromNbt(tag); this.lastPos = tag.getVector3("lastPos"); this.unitStats = new UnitStats(tag, this.unitData); bool flag = tag.getBool("hasMovementOverride"); if (flag) { this.overrideMovementDestination = tag.getVector3("overrideMovementDestination"); this.overrideMovementStopDis = tag.getFloat("overrideMovementStopDis"); this.moveHelper.setDestination((Vector3)this.overrideMovementDestination, this.overrideMovementStopDis); } NbtCompound tagTask = tag.getCompound("task"); ITask task = (ITask)Activator.CreateInstance(TaskManager.getTaskFromId(tagTask.getInt("taskID")), new object[] { (UnitBase)this }); task.readFromNbt(tagTask); this.setTask(task, true); }
// Use this for initialization void Start() { battleManager = BattleManager.instance; battleManager.onTurnChange += onTurnChange; enemyAnimator = GetComponent <EnemyAnimator>(); enemySkills = GetComponent <EnemySkills>(); enemyStats = GetComponent <UnitStats>(); blockIconLeft = GameObject.FindGameObjectsWithTag("BlockIconLeft")[0]; blockIconLeft.GetComponent <Image>().enabled = true; blockIconLeft.SetActive(false); blockIconRight = GameObject.FindGameObjectsWithTag("BlockIconRight")[0]; blockIconRight.GetComponent <Image>().enabled = true; blockIconRight.SetActive(false); comboIconLeft = GameObject.FindGameObjectsWithTag("ComboIconLeft")[0]; comboIconLeft.GetComponent <Image>().enabled = true; comboIconLeft.SetActive(false); comboIconRight = GameObject.FindGameObjectsWithTag("ComboIconRight")[0]; comboIconRight.GetComponent <Image>().enabled = true; comboIconRight.SetActive(false); }
public Unit(int ownerId, int maxHp, int baseDamage, int speed, int moveDistance, int range, Vector3 cubeCoordinate) { //lease an id to the unit. id = UnitIdLeaser.Instance.GenerateNewId(); //set the units stats Stats = new UnitStats( maxHp, baseDamage, speed, moveDistance, range ); //the ID of the owner is stored. this way, we can pass in a specified id to flag // AI units, instead of having to instantiate another player class. this.ownerId = ownerId; this.cubeCoordinate = cubeCoordinate; hp = maxHp; target = null; }
void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Player") { bool destroy = true; foreach (GameObject member in party.playerParty) { UnitStats unit = member.GetComponent <UnitStats>(); if (unit.charName != "Future Mason" && unit.charName != "Mason?") { if (!unit.available) { destroy = false; } } } if (destroy) { GameObject.Destroy(gameObject); } } }
// Update is called once per frame, expensive, but just demo void Update() { myStats = GetComponent <UnitStats>(); cooldown -= Time.deltaTime; if (myStats.currentHealth <= 0) { agent.SetDestination(hut.transform.position);//die } if (target != null) { agent.SetDestination(target.transform.position); float distance = Vector3.Distance(transform.position, target.transform.position); if (distance < 3f)//2f when not clumped? { if (cooldown <= 0f) { Attack(target.GetComponent <UnitStats>()); } } } else { float distance = Mathf.Abs(Vector3.Distance(transform.position, hutPivot.transform.position)); if (distance < 7f) { if (cooldown <= 0f) { Steal(hut.GetComponent <UnitStats>());//steal bananas Debug.Log(transform.name + " takes " + "banana!"); } } else { agent.SetDestination(hutPivot.transform.position); } } }
// get the next contestant to move public void NextTurn() { if (turnQueue.Count == 0 && nextQueue.Count == 0) { Debug.Log("Error: No units in battle!"); return; } else if (turnQueue.Count == 0) { // start next round turnQueue = nextQueue; turnQueue.Sort(); nextQueue = new List <UnitStats>(); } GameObject[] playerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit"); GameObject[] enemyUnits = GameObject.FindGameObjectsWithTag("EnemyUnit"); if (playerUnits.Length == 0) { Lose(); return; } if (enemyUnits.Length == 0) { Win(); return; } contestant = turnQueue[0]; if (contestant.tag == "EnemyUnit") { TurnOffMenus(); } else if (contestant.tag == "PlayerUnit") { StartPlayerTurn(contestant); } turnQueue.Remove(contestant); nextQueue.Add(contestant); contestant.Act(this); }
// Use this for initialization void Start() { mySpawningTurret = null; turretIsSlectedToSpawn = false; myStats = myUnit.GetComponent <UnitStats>(); myButton = gameObject.GetComponent <Button>(); playerBattleManager = GameObject.Find("PlayerBattleManager"); playerBattleManagerScript = playerBattleManager.GetComponent <PlayerBattleManager>(); // need to set all of my variables based on any upgrades the unit might have myUnitCost = myStats.unitCost; myCooldownTimer = (myStats.unitBuildTime - ShipStatsUpgradesStatic.turretCooldownReduction); myCostText.text = (myUnitCost - ShipStatsUpgradesStatic.turretResourceDiscount).ToString(); // button starts on cooldown isOnCooldown = true; startBuilTime = 0; cooldownImage.fillAmount = 1; myButton.interactable = false; }
void CalculateWeaponTriangle() { attackingUnitStats = attackingUnit.GetComponent <UnitStats>(); defendingUnitStats = defendingUnit.GetComponent <UnitStats>(); Weapon attackerCurrentEquipedWeapon = attackingUnit.GetComponent <UnitInventory>().currentWeapon; Weapon defenderCurrentEquipedWeapon = attackingUnit.GetComponent <UnitInventory>().currentWeapon; if (attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Shotgun && defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.MachineGun) //Attack in an advantage { attackingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies attacker damage by 20% defendingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies defender damage by -20% } else if (attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.MachineGun && defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Bazooka) { attackingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies attacker damage by 20% defendingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies defender damage by -20% } else if (attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Bazooka && defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Shotgun) { attackingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies attacker damage by 20% defendingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies defender damage by -20% } if (defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Shotgun && attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.MachineGun) //Attacker in a disadvantage { defendingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies defender damage by 20% attackingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies attacker damage by -20% } else if (defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.MachineGun && attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Bazooka) { defendingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies defender damage by 20% attackingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies attacker damage by -20% } else if (defenderCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Bazooka && attackerCurrentEquipedWeapon.WeaponType == Weapon.WeaponTypes.Shotgun) { defendingUnitStats.attack = Mathf.RoundToInt(((float)attackingUnitStats.attack) * 1.2f); //multiplies defender damage by 20% attackingUnitStats.attack = Mathf.RoundToInt(((float)defendingUnitStats.attack) * 0.8f); //multiplies attacker damage by -20% } }
private void CreateUnit() { // Creating the unit GameObject g; Vector3 t = new Vector3(0, 80, 0); Quaternion q = Quaternion.Euler(0, Random.Range(0, 360), 0); if (m_Player2Turn == false) { g = Instantiate(m_UnitRed, t, q) as GameObject; } else { g = Instantiate(m_UnitBlue, t, q) as GameObject; } UnitStats stats = g.GetComponent <UnitStats>(); // Setting the input as its stats stats.m_UnitName = m_FieldName.text; stats.m_UnitHealth = (int)m_FieldHealth.value; stats.m_UnitStrength = (int)m_FieldStrength.value; stats.m_UnitSpeed = (int)m_FieldSpeed.value; stats.m_UnitDefence = (int)m_FieldDefence.value; // Adding unit to List g.name = m_FieldName.text; if (m_Player2Turn == false) { GameManager.instance.m_P1Units.Add(g); m_Player1Text.text = "Red Team:\n" + GameManager.instance.m_P1Units.Count.ToString(); } else { GameManager.instance.m_P2Units.Add(g); m_Player2Text.text = "Blue Team:\n" + GameManager.instance.m_P2Units.Count.ToString(); } }
public void SetUpPlayerUnits() { var partyMembers = DataManager.instance.CurrentState.PartyMembers; GameObject[] playerUnitObjects = GameObject.FindGameObjectsWithTag("PlayerUnit"); UnitStats player1Stats = playerUnitObjects.Single(r => r.name == "PlayerUnit1").GetComponent <UnitStats>(); UnitStats player2Stats = playerUnitObjects.Single(r => r.name == "PlayerUnit2").GetComponent <UnitStats>(); UnitStats player3Stats = playerUnitObjects.Single(r => r.name == "PlayerUnit3").GetComponent <UnitStats>(); UnitStats player4Stats = playerUnitObjects.Single(r => r.name == "PlayerUnit4").GetComponent <UnitStats>(); player1Stats.SetUpUnitCharacter(partyMembers[0]); if (partyMembers.Count >= 2) { player2Stats.SetUpUnitCharacter(partyMembers[1]); } else { player2Stats.SelfDestruct(); } if (partyMembers.Count >= 3) { player3Stats.SetUpUnitCharacter(partyMembers[2]); } else { player3Stats.SelfDestruct(); } if (partyMembers.Count >= 4) { player4Stats.SetUpUnitCharacter(partyMembers[3]); } else { player4Stats.SelfDestruct(); } }
public CityguardUnit() { UnitStats = new UnitStats() { Attack = 10, InfanteryDefence = 10, CavaleryDefence = 10, MagicDefence = 10, ArtillerieDefence = 10, Space = 1, FoodUsage = 2, Speed = 0, AttackStructure = 0 }; UnitCost = new UnitCost() { Wood = 100 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_cityguard.png"; Name = "Cityguard"; UnitType = UnitType.Infantery; UnitEntity = UnitEntity.Cityguard; }
public RangerUnit() { UnitStats = new UnitStats() { Attack = 20, InfanteryDefence = 40, CavaleryDefence = 10, MagicDefence = 25, ArtillerieDefence = 15, Space = 1, FoodUsage = 3, Speed = 20, AttackStructure = 20 }; UnitCost = new UnitCost() { Wood = 160 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_ranger.png"; Name = "Ranger"; UnitType = UnitType.Infantery; UnitEntity = UnitEntity.Ranger; }
public BerserkerUnit() { UnitStats = new UnitStats() { Attack = 50, InfanteryDefence = 15, CavaleryDefence = 12, MagicDefence = 10, ArtillerieDefence = 15, Space = 1, FoodUsage = 6, Speed = 20, AttackStructure = 15 }; UnitCost = new UnitCost() { Iron = 150 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_berserker.png"; Name = "Berserker"; UnitType = UnitType.Infantery; UnitEntity = UnitEntity.Berserker; }
private void OnTriggerExit2D(Collider2D collision) { if (collision.isTrigger) { return; } UnitStats unit = collision.GetComponent <UnitStats>(); if (unit != null) { potential_targets.Remove(unit); // may happen if unit killed //Assert.IsTrue(target.gameObject != collision.gameObject); if (target != null) { if (target.gameObject == collision.gameObject) { target = null; } } } }
public WarlockUnit() { UnitStats = new UnitStats() { Attack = 120, InfanteryDefence = 30, CavaleryDefence = 20, MagicDefence = 50, ArtillerieDefence = 40, Space = 2, FoodUsage = 20, Speed = 10, AttackStructure = 120 }; UnitCost = new UnitCost() { Iron = 100, Gold = 350 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_warlock.png"; Name = "Warlock"; UnitType = UnitType.Magic; UnitEntity = UnitEntity.Warlock; }
public TemplarUnit() { UnitStats = new UnitStats() { Attack = 25, InfanteryDefence = 20, CavaleryDefence = 30, MagicDefence = 50, ArtillerieDefence = 15, Space = 1, FoodUsage = 3, Speed = 20, AttackStructure = 25 }; UnitCost = new UnitCost() { Iron = 90, Gold = 100 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_templar.png"; Name = "Templar"; UnitType = UnitType.Infantery; UnitEntity = UnitEntity.Templar; }
public MageUnit() { UnitStats = new UnitStats() { Attack = 75, InfanteryDefence = 15, CavaleryDefence = 10, MagicDefence = 30, ArtillerieDefence = 15, Space = 1, FoodUsage = 5, Speed = 20, AttackStructure = 75 }; UnitCost = new UnitCost() { Iron = 50, Gold = 150 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_mage.png"; Name = "Mage"; UnitType = UnitType.Magic; UnitEntity = UnitEntity.Mage; }
public PaladinUnit() { UnitStats = new UnitStats() { Attack = 60, InfanteryDefence = 50, CavaleryDefence = 20, MagicDefence = 90, ArtillerieDefence = 40, Space = 2, FoodUsage = 15, Speed = 10, AttackStructure = 60 }; UnitCost = new UnitCost() { Iron = 200, Gold = 160 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_paladin.png"; Name = "Paladin"; UnitType = UnitType.Cavalery; UnitEntity = UnitEntity.Paladin; }
public ScoutUnit() { UnitStats = new UnitStats() { Attack = 10, InfanteryDefence = 10, CavaleryDefence = 10, MagicDefence = 10, ArtillerieDefence = 10, Space = 2, FoodUsage = 5, Speed = 8, AttackStructure = 10 }; UnitCost = new UnitCost() { Iron = 40, Gold = 120 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_scout.png"; Name = "Scout"; UnitType = UnitType.Cavalery; UnitEntity = UnitEntity.Scout; }
public CrossbowUnit() { UnitStats = new UnitStats() { Attack = 40, InfanteryDefence = 40, CavaleryDefence = 90, MagicDefence = 30, ArtillerieDefence = 40, Space = 2, FoodUsage = 10, Speed = 10, AttackStructure = 40 }; UnitCost = new UnitCost() { Wood = 150, Gold = 200 }; ImagePath = "pack://application:,,,/Resources/Images/Units/units_crossbow.png"; Name = "Crossbowman"; UnitType = UnitType.Cavalery; UnitEntity = UnitEntity.Crossbow; }
void Start() { enemyStats = GetComponent<Enemy>().Stats; }