public int runCheckWithMovement(CharacterStatus theTarget, int abilNum, int range) { if (_casterStatus._numMovesRemaining > 0 && theTarget.currentHealth > 0 && _casterStatus.currentHealth > 0 && _casterStatus.currentAction < _casterStatus.maxAction) { if (Math.Abs(_unit.tileX - theTarget.GetComponent <Unit>().tileX) <= range && Math.Abs(_unit.tileZ - theTarget.GetComponent <Unit>().tileZ) <= range) { if (range != 0 && range != 1) { if (Math.Abs(_unit.tileX - theTarget.GetComponent <Unit>().tileX) == range && Math.Abs(_unit.tileZ - theTarget.GetComponent <Unit>().tileZ) == range) { return(-1); } } if (!rangeCheck) { _unit.abil = abilNum; } _unit.UnhighlightWalkableTiles(); return(range); } else { return(-1); } } else { return(-1); } }
public int runCheck(CharacterStatus theTarget, int AP, int abilNum, int range) { if (_casterStatus.currentAction >= AP && theTarget.currentHealth > 0 && _casterStatus.currentHealth > 0) { if (Math.Abs(_unit.tileX - theTarget.GetComponent <Unit>().tileX) <= range && Math.Abs(_unit.tileZ - theTarget.GetComponent <Unit>().tileZ) <= range) { if (range != 0 && range != 1) { if (Math.Abs(_unit.tileX - theTarget.GetComponent <Unit>().tileX) == range && Math.Abs(_unit.tileZ - theTarget.GetComponent <Unit>().tileZ) == range) { return(-1); } } if (!rangeCheck) { _unit.abil = abilNum; _unit.CmdSynchAnimations(abilNum, _unit._isMoving, _unit.react, _unit.dead); } _unit.UnhighlightWalkableTiles(); return(range); } else { return(-1); } } else { return(-1); } }
private void Start() { chStatus = GetComponent <CharacterStatus>(); chAnim = GetComponent <CharacterAnimation>(); navAngent = GetComponent <NavMeshAgent>(); chSkillSys = chStatus.GetComponent <CharacterSkillSystem>(); }
public bool IsEnemy(CharacterStatus unit) { var identity = unit.characterIdentity; switch (identity) { case CharacterIdentity.transfiguration: if (playerNumber != unit.playerNumber) { var buff = (TransfigurationBuff)unit.Buffs.Find(b => b.GetType() == typeof(TransfigurationBuff)); //buff中的目标不是自己人,则一定可以判定为敌人。 if (buff.target.GetComponent <Unit>().playerNumber != playerNumber) { return(true); } //buff中的目标是自己人,则只有与该目标相同外观的角色能判定其为敌人。 else if (unit.GetComponent <Animator>().runtimeAnimatorController == GetComponent <Animator>().runtimeAnimatorController) { return(true); } } break; default: return(playerNumber != unit.playerNumber); } return(false); }
public override bool InitMagicalObject(GameObject Weapon, GameObject Direction) { CharacterStatus Charstats = Weapon.GetComponentInParent <CharacterStatus>(); GameObject target = Charstats.GetComponent <MouseControl>().SelectedObject; if (Charstats.CurrentMana >= Cost && target != null) { GameObject Sphere = Instantiate(SpellPrefab); Sphere.transform.position = Weapon.transform.position - Weapon.transform.right * 2; Sphere.transform.LookAt(Direction.transform); HomingObj homingSphere = Sphere.GetComponent <HomingObj>(); homingSphere.onExplosion = OnExplosion; homingSphere.Duration = EffectDuration; homingSphere.Target = target.GetComponent <CharacterStatus>(); homingSphere.Caster = Charstats.gameObject.name; homingSphere.Go = true; Charstats.CurMana = -Cost; return(true); } return(false); }
//this function actually applies the spell effect to the target public void castAbility(CharacterStatus target, float damage, float healing, float apCost, float armorPen, float magicPen, float buff, bool isMagic) { _unit.UnhighlightWalkableTiles(); _unit.CmdLookAt(target.gameObject); //if the target is not dead if (target.currentHealth > 0) { float resistance = 0; //check if the caster has enough AP to cast a spell - currently redundant if (_casterStatus.currentAction >= apCost) { //use casters ability points _casterStatus.CmdLoseAction(apCost); //check if the spell effect is reduced by magic resistance or armor if (isMagic) { magicPen += _casterStatus.tempMagicPen; if (magicPen == 0) { resistance = target.magicArmor + target.tempPhysicalArmor; } else { resistance = (target.magicArmor + target.tempMagicArmor) * (1 - magicPen); } //ensure penetration doesnt add damage and that resistance doesn't cause healing if (resistance < 0) { resistance = 0; } if (resistance >= 1) { resistance = 1; } target.tempMagicArmor -= .1f; _casterStatus.tempMagicPen -= .1f; if (target.tempMagicArmor < 0) { target.tempMagicArmor = 0; } if (_casterStatus.tempMagicPen < 0) { _casterStatus.tempMagicPen = 0; } //deal damage wieghted by resistance target.loseHealth(damage * (1 - resistance)); } else { armorPen += _casterStatus.tempArmorPen; if (armorPen == 0) { resistance = target.physicalArmor + target.tempPhysicalArmor; } else { resistance = target.physicalArmor * (1 - armorPen); } //ensure penetration doesnt add damage and that resistance doesn't cause healing if (resistance < 0) { resistance = 0; } if (resistance >= 1) { resistance = 1; } target.tempPhysicalArmor -= .1f; _casterStatus.tempArmorPen -= .1f; if (target.tempPhysicalArmor < 0) { target.tempPhysicalArmor = 0; } if (_casterStatus.tempArmorPen < 0) { _casterStatus.tempArmorPen = 0; } //deal damage weighted by resistance target.loseHealth(damage * (1 - resistance)); } //check if target is dead - may have received damage before healing if (target.currentHealth <= 0) { target.GetComponent <CapsuleCollider>().enabled = false; target.currentHealth = 0; target.GetComponentInChildren <StatusBars>().gameObject.SetActive(false); if (target.isLeader) { _casterStatus.CmdEndGame(target.teamNum); } } else { //if alive heal the target target.gainHealth(healing); if (target.currentHealth > target.maxHealth) { target.currentHealth = target.maxHealth; } if (buff > 0) { if (isMagic) { target.maxAction += buff; } else { target.maxHealth += buff; } } } //ability is finished set boolean usingAbility = false; } else { //not enough AP - set boolean usingAbility = false; } //syncs the server values with those of the clinet target.CmdSyncValues(target.teamNum, target.maxAction, target.currentAction, target.maxHealth, target.currentHealth, target.physicalArmor, target.magicArmor); } }