Пример #1
0
 public HitChancer(UnitScript attacker, UnitScript defender, int testNumber)
 {
     dc         = new DamageCalculator();
     Attacker   = attacker;
     Defender   = defender;
     TestNumber = testNumber;
 }
Пример #2
0
        public IAbility GetAutoAttackAbility(IGameUnit user, IGameUnit target)
        {
            if (user.Abilities == null || !user.Abilities.Any(x => x.CanCounterAttack))
            {
                return(null);
            }

            // Get all possible counter abilities for this user
            var counterAbilities = user.Abilities.Where(ability => ability.CanCounterAttack && user.CanUseAbility(ability) && AbilityRangeCalculator.CanAbilityTargetUnit(user, target, ability)).ToList();

            if (!counterAbilities.Any())
            {
                return(null);
            }
            // And pick the strongest one!
            var strongestAbility = counterAbilities.Select(ability =>
            {
                var abilityParams = new AbilityExecuteParameters(user, ability, target, new List <IGameMapObject> {
                    target
                }, target.MapPoint, _gameMap);
                var repeatCount = DamageCalculator.RepeatCount(ability, user, target);
                var results     = ability.AbilityEffects.Select(x => x.PreviewResults(abilityParams)).Sum(x => x.BaseDamage * x.HitRate) * repeatCount;
                return(new { Ability = ability, DamageScore = results });
            }).MaxBy(x => x.DamageScore).Ability;

            return(strongestAbility);
        }
Пример #3
0
        public void  利タイプ()
        {
            var param = new MonsterParams(prop, Type.Water);
            var dmg   = DamageCalculator.Calculate(param, fireMove);

            Assert.That(dmg.value, Is.EqualTo(50));
        }
Пример #4
0
        public void 通常タイプ()
        {
            var param = new MonsterParams(prop, Type.Normal);
            var dmg   = DamageCalculator.Calculate(param, normalMove);

            Assert.That(dmg.value, Is.EqualTo(100));
        }
Пример #5
0
    private IEnumerator WaterPulseAction(Pokemon attacker, Pokemon defensor)
    {
        Transform effectTransform = Instantiate(waterPulseEffect).transform;

        effectTransform.localScale = Vector2.zero;
        effectTransform.position   = transform.position;
        Destroy(effectTransform.gameObject, 3f);

        AudioSource audioSource = GetComponent <AudioSource>();

        audioSource.PlayOneShot(waterPulseSound);

        attacker.StopAnimation();

        for (float timer = 0f; timer < 1.5f; timer += Time.deltaTime)
        {
            effectTransform.localScale += new Vector3(Time.deltaTime / 2f, Time.deltaTime / 2f);
            effectTransform.position    = Vector2.Lerp(attacker.transform.position, attacker.uiTransform.position, timer / 1f);

            yield return(null);
        }

        for (float timer = 0f; timer < 0.5f; timer += Time.deltaTime)
        {
            Vector2 destionation = (defensor.transform.position + defensor.uiTransform.position) / 2f;
            effectTransform.position = Vector2.Lerp(attacker.uiTransform.position, destionation, timer / 0.5f);

            yield return(null);
        }

        Destroy(effectTransform.gameObject);
        audioSource.PlayOneShot(hitSound);
        defensor.Hit(DamageCalculator.CalculateSkillDamage(attacker, defensor, baseDamage, PokemonType.Water), attacker);
        EndSkill(attacker);
    }
Пример #6
0
 protected override void Start()
 {
     base.Start();
     rayShooter       = GetComponent <RayShooter>();
     forceApplier     = GetComponent <ForceApplier>();
     damageCalculator = GetComponent <DamageCalculator>();
 }
    /////////////////////////////////////////////////////////////////////////////////////
    //void TakeDamage(CharacterData.CharacterEntry, int float, bool                    //
    //Takes damage using the appropriate stats                                         //
    //CharacterData.CharacterEntry other - The CharacterEntry representing the attacker//
    //int otherWeapon - The attacker's weapon attack                                   //
    //float attackBase - The base attack multiplier of the attack                      //
    //bool isMagical - is the attack magical?                                          //
    /////////////////////////////////////////////////////////////////////////////////////
    public void TakeDamage(CharacterData.CharacterEntry other, float attackBase, bool isMagical)
    {
        int damage;

        if (isMagical)
        {
            damage = DamageCalculator.CalculateMagicalDamage(other.GetMATK(), attackBase, stats.enemyMDEF);
        }

        else
        {
            damage = DamageCalculator.CalculatePhysicalDamage(other.GetATK(), attackBase, stats.enemyDEF);
        }

        currentHP -= damage;
        Debug.Log("Damage Taken: " + damage);

        if (currentHP < 0)
        {
            currentHP = 0;
        }

        if (currentHP == 0)
        {
            Debug.Log("Enemy Defeated!");
        }
    }
Пример #8
0
    int CalculateDamage(UnitScript Attacker, UnitScript Defender, bool badRangeShooting, out int hits)
    {
        DamageCalculator dc = new DamageCalculator();

        hits = dc.GetHits(Attacker, Defender, badRangeShooting);
        return(dc.CalculateAmountOfDamage(Attacker, Defender, badRangeShooting, hits));
    }
Пример #9
0
        public override List <AbilityResult> Process(List <Combatant> targets)
        {
            List <AbilityResult> results = new List <AbilityResult>();

            // It's a physical attack, so let's do some physical damage!
            if (this.model.PhysicalDamageModifier != 0)
            {
                foreach (Combatant target in targets)
                {
                    results.Add(DamageCalculator.CalculatePhysicalDamage(this.actingCombatant, target, this.model.PhysicalDamageModifier));
                }
            }

            if (this.model.MagicalDamageModifier != 0)
            {
                if (this.model.TargetingType == Spells.Abilities.TargetingType.DEFENSIVE_SINGLE || this.model.TargetingType == Spells.Abilities.TargetingType.DEFENSIVE_ALL)
                {
                    foreach (Combatant target in targets)
                    {
                        results.Add(DamageCalculator.CalculateHealing(this.actingCombatant, target, this.model.MagicalDamageModifier));
                    }
                }
                else
                {
                    foreach (Combatant target in targets)
                    {
                    }
                }
            }

            return(results);
        }
Пример #10
0
    IEnumerator BattleAction()
    {
        try
        {
            int targetKey = TargetChanger.TargetIndex <= enemies.Count ? TargetChanger.TargetIndex : enemies.Count;
            targetEnemy = new KeyValuePair <int, Character>(targetKey, enemies[targetKey]);
        }
        catch
        {
            targetEnemy = new KeyValuePair <int, Character>(0, enemies[0]);
        }
        while (Card.selectedCards.Count != 0)
        {
            if (targetEnemy.Value == null)
            {
                targetEnemy = new KeyValuePair <int, Character> (0, enemies[0]);
            }
            int damage = DamageCalculator.DamageCalc(Card.selectedCards.Dequeue(), targetEnemy.Value);
            targetEnemy.Value.hp -= damage;
            targetEnemy.Value.Damage(damage);
            if (targetEnemy.Value.hp <= 0)
            {
                Destroy(targetEnemy.Value.transform.gameObject);
                enemies.RemoveAt(targetEnemy.Key);

                if (enemies.Count == 0)
                {
                    StartCoroutine(BattleFinish());
                    yield break;
                }
            }
            yield return(new WaitForSeconds(1));
        }

        while (enemySelectedCards.Count != 0)
        {
            int targetKey = Random.Range(0, servant.Count);

            targetEnemy = new KeyValuePair <int, Character>(targetKey, servant[targetKey]);
            int damage = DamageCalculator.DamageCalc(enemySelectedCards.Dequeue(), targetEnemy.Value);
            targetEnemy.Value.hp -= damage;
            targetEnemy.Value.Damage(damage);
            if (targetEnemy.Value.hp <= 0)
            {
                Destroy(targetEnemy.Value.transform.gameObject);
                servant.RemoveAt(targetEnemy.Key);

                if (servant.Count == 0)
                {
                    StartCoroutine(GameOver());
                    // gameover
                    yield break;
                }
            }

            yield return(new WaitForSeconds(1));
        }

        SetCard();
    }
Пример #11
0
        public void GetDamageAfterWeaknessAndResistance_Resistance_Modifier()
        {
            var attacker = new PokemonCard()
            {
                Type = EnergyTypes.Grass, Name = "Brock's Golem"
            };
            var defender = new PokemonCard()
            {
                Type = EnergyTypes.Grass, Resistance = EnergyTypes.Grass
            };
            var attack = new Attack()
            {
                ApplyResistance = false, ApplyWeakness = true
            };

            var modifier = new ResistanceModifierAbility()
            {
                Modifier     = 0,
                AttackerName = "Brock"
            };

            var result = DamageCalculator.GetDamageAfterWeaknessAndResistance(30, attacker, defender, attack, modifier);

            Assert.Equal(30, result);
        }
Пример #12
0
        /// <summary>
        /// Applies damage and healing from all StatusEffects afflicting a CombatEntity and reduces their timers by 1.
        /// Removes any StatusEffects that are expired.
        /// </summary>
        /// <param name="entity">The CombatEntity to apply damage and healing to.</param>
        public void ApplyEffects(CombatEntity entity)
        {
            var removeStatuses = new List <AppliedStatusEffect>();

            foreach (var statusEffect in entity.StatusEffects)
            {
                var damage      = DamageCalculator.GetTotalDamage(statusEffect.CumulativeDamage, entity);
                var totalChange = DamageCalculator.GetDamageTypesAsInt(damage) - statusEffect.CumulativeHeal;
                entity.Resources.CurrentHealth -= totalChange;

                statusEffect.Duration--;
                if (statusEffect.Duration == 0)
                {
                    removeStatuses.Add(statusEffect);
                }
            }

            if (entity.Resources.CurrentHealth <= 0)
            {
                RemoveAll(entity);
            }
            else
            {
                if (entity.Resources.CurrentHealth > entity.Resources.MaxHealth)
                {
                    entity.Resources.CurrentHealth = entity.Resources.MaxHealth;
                }

                entity.StatusEffects = entity.StatusEffects.Except(removeStatuses).ToList();
            }
        }
Пример #13
0
        /// <summary>
        /// Gets the amount of damage, healing, and crit chance/damage a status effect does as a list of key value pairs.
        /// </summary>
        /// <param name="character">The character to use to calculate the amount of damage and healing a status effect does.</param>
        /// <param name="status">The status effect to get data for.</param>
        /// <returns>A list of key value pairs containing the name of the stat and the value of that stat.</returns>
        private List <KeyValuePair <string, int> > GetStatusDamageData(Character character, StatusEffect status)
        {
            var data = new List <KeyValuePair <string, int> >();

            var damage = GetElementalData(DamageCalculator.GetDamage(character, status), "Damage/Turn");
            // Calculate heals
            int  healAmount    = DamageCalculator.GetHealing(character, status);
            int  healPercent   = DamageCalculator.GetHealingPercentage(character, status);
            bool healsOrDamage = damage.Any() || healAmount != 0 || healPercent != 0;

            // Add damage first
            data.AddRange(damage);

            if (healsOrDamage)
            {
                data.Add(new KeyValuePair <string, int>("Crit Chance", status.DamageCritChance + character.CritChance));
                data.Add(new KeyValuePair <string, int>("Crit Damage", status.DamageCritMultiplier + character.CritMultiplier));
            }

            // Add any healing amounts
            if (healAmount != 0)
            {
                data.Add(new KeyValuePair <string, int>("Health Restored/Turn", healAmount));
            }
            if (healPercent != 0)
            {
                data.Add(new KeyValuePair <string, int>("% Health Restored/Turn", healPercent));
            }

            return(data);
        }
    void OnCollisionEnter(Collision collision)
    {
        collision.GetContacts(CachedContactPoints);
        foreach (var contact in CachedContactPoints)
        {
            Collider thisCollider  = contact.thisCollider;
            Collider otherCollider = contact.otherCollider;

            // calculate and inflict damage if collided with another robot part
            if (otherCollider != null && otherCollider.GetComponent <PartHealth>() != null &&
                thisCollider != null && thisCollider.GetComponent <PartHealth>() != null)
            {
                string thisPartType  = thisCollider.tag;
                string otherPartType = otherCollider.tag;

                float thisVelocity  = GetComponent <Rigidbody>().GetPointVelocity(contact.point).sqrMagnitude;
                float otherVelocity = otherCollider.GetComponentInParent <Rigidbody>().GetPointVelocity(contact.point).sqrMagnitude;

                // only take damage if this part is moving slower than the other part
                if (thisVelocity < otherVelocity)
                {
                    float damage = DamageCalculator.DamageToInflictOnCollision(thisPartType, otherPartType);
                    thisCollider.GetComponent <PartHealth>().SubtractHealth(damage);
                }
            }
        }
    }
Пример #15
0
        public void PlayerShoots(MapEntity target)
        {
            var damage = DamageCalculator.CalculateDamage(this.Player, target);

            this.HarmAlien(target, damage);
            this.OnPlayerMoved();
        }
Пример #16
0
        /// <summary>
        /// Applies the effects of a DelayedAbility to all of its targets.
        /// </summary>
        /// <param name="ability">The DelayedAbility to apply.</param>
        /// <param name="targets">The CombatEntity targets of the DelayedAbility.</param>
        private void ApplyEffects(DelayedAbility ability, IEnumerable <CombatEntity> targets)
        {
            foreach (var target in targets)
            {
                var damage  = DamageCalculator.GetTotalDamage(ability.StoredDamage, target);
                int healing = ability.StoredHealing;
                healing += target.Resources.MaxHealth * ability.BaseAbility.PercentHeal / 100;

                target.Resources.CurrentHealth += healing;
                target.Resources.CurrentHealth -= DamageCalculator.GetDamageTypesAsInt(damage);
                if (target.Resources.CurrentHealth > 0)
                {
                    _statusEffectManager.Apply(target, ability.Actor, ability.BaseAbility.AppliedStatusEffects, ability.IsCrit);
                }
                else
                {
                    _statusEffectManager.RemoveAll(target);
                }
            }

            if (ability.BaseAbility.SelfAppliedStatusEffects.Any())
            {
                _statusEffectManager.Apply(ability.Actor, ability.Actor, ability.BaseAbility.SelfAppliedStatusEffects, ability.IsCrit);
            }
        }
Пример #17
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //void TakeDamage(EnemyEntry, float, bool)                                                                           //
    //Calculates damage from an enemy attack                                                                             //
    //For balancing difficulty, I am considering allowing only certain enemies to crit, so LUCK is not considered for now//
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void TakeDamage(EnemyEntry otherStats, float baseDamage, bool isMagical)
    {
        if (iframesTimer < iframes)
        {
            //iframes are active, take no damage//
            return;
        }

        int damage = 0;

        if (DamageCalculator.Hits(stats.GetAGI(), otherStats.enemyAGI))
        {
            if (isMagical)
            {
                damage = DamageCalculator.CalculateMagicalDamage(otherStats.enemyMATK, baseDamage, stats.GetMDEF());
            }

            else
            {
                damage = DamageCalculator.CalculatePhysicalDamage(otherStats.enemyATK, baseDamage, stats.GetDEF());
            }
        }

        currentHP -= damage;

        if (currentHP <= 0)
        {
            currentHP = 0;
            HandleDeath();
        }

        iframesTimer = 0;
    }
Пример #18
0
        public int CalculateDamage(IPokemon pokemon, IPokemon target)
        {
            int damage = 0;

            if (AdditionalEffects.ContainsEffectType(typeof(AlwaysSameDamage)))
            {
                AlwaysSameDamage alwaysSameDamage = AdditionalEffects.First(e => e is AlwaysSameDamage) as AlwaysSameDamage;
                damage = alwaysSameDamage.IsBasedOnLevel() ? pokemon.Level : (int)alwaysSameDamage.PrimaryParameter;
            }

            if (damage == 0 && Power.HasValue)
            {
                damage = DamageCalculator.CalculateAttackDamage(this, pokemon, target);
                if (damage < 1)
                {
                    damage = 1;
                }
                if (BattleHelper.IsCritical(AdditionalEffects, pokemon.IsEnergyFocused))
                {
                    damage *= 2;
                    //_battleLogController.SetText("Critical hit!");
                }
            }
            return(damage);
        }
Пример #19
0
    public override void OnAdvantage(GameObject collider, GameObject other)
    {
        Debug.Log("LASER ADVANTAGE");

        isReflecting = false;

        // If this is a weapon spawn, destroy it.
        if (other.GetComponent <IWeaponSpawn>() != null)
        {
            Destroy(other);
        }

        // If this is a destructible, attempt to inflict damage.
        IDestructable destructable = other.GetComponent <IDestructable>();

        if (destructable != null)
        {
            destructable.ReceiveDamage(DamageCalculator.CalculateByDistance(collider.transform.position,
                                                                            other.transform.position, damageMultiplier));
            ParticleController.GetInstance().InstantiateParticle(ParticleController.PlayerLaserCollision, other.transform.position, transform.position);
            return;
        }

        // Finally, jam the laser if applicable.
        if (charge != null)
        {
            charge.Jam();
            Debug.Log("LASER JAMMED");
        }
    }
Пример #20
0
        /// <summary>
        /// Applies a StatusEffect onto a CombatEntity.
        /// </summary>
        /// <param name="recipient">The CombatEntity who is receiving the StatusEffect.</param>
        /// <param name="applicator">The CombatEntity applying the StatusEffect on the receiver.</param>
        /// <param name="statusEffect">The StatusEffect to apply onto the receiver.</param>
        /// <param name="isCrit">If true, will include critical damage in the calculations.</param>
        public void Apply(CombatEntity recipient,
                          CombatEntity applicator,
                          StatusEffect statusEffect,
                          bool isCrit)
        {
            var status = recipient.StatusEffects.FirstOrDefault(se => se.BaseStatus.Id == statusEffect.Id);

            if (status == null)
            {
                var appliedStatusEffect = CreateAppliedStatus(applicator, recipient, statusEffect);
                ApplyStatEffects(recipient, statusEffect);
                recipient.StatusEffects.Add(appliedStatusEffect);
            }
            else
            {
                // Apply another stack of StatusEffect
                if (statusEffect.StackSize > 1 && status.CurrentStacks < statusEffect.StackSize)
                {
                    status.CumulativeDamage += DamageCalculator.GetDamage(applicator, statusEffect, isCrit);
                    status.CumulativeHeal   += DamageCalculator.GetHeal(applicator, statusEffect, isCrit);
                    status.CurrentStacks++;
                    status.Duration = statusEffect.Duration;
                }
                // Can't apply another stack, refresh duration instead
                else
                {
                    status.Duration = statusEffect.Duration;
                }
            }
        }
Пример #21
0
    public void TakeDamage(InstancePokemonObject enemy, MoveObject move)
    {
        int damage = DamageCalculator.CalculateDamage(enemy.Level, move.Power, enemy.Attack, Pokemon.Defense);

        Pokemon.CurrentHp -= damage;
        StartCoroutine(PauseAndTakeDamage());
    }
Пример #22
0
        public void CalculateDamage_Test(float health, float damage, float defense, bool critical, float expectedHealth)
        {
            var damageCalculator = new DamageCalculator();
            var remainingHealth  = damageCalculator.calculate(health, damage, defense, critical);

            Assert.That(remainingHealth, Is.EqualTo(expectedHealth));
        }
Пример #23
0
        /// <summary>
        /// Applies the effects of the ability being used on all of it's targets.
        /// </summary>
        /// <param name="attacker">The entity performing the ability.</param>
        /// <param name="ability">The ability to apply the effects of.</param>
        /// <param name="targets">The targets of the ability.</param>
        private void ApplyEffects(CombatEntity attacker, Ability ability, IEnumerable <CombatEntity> targets)
        {
            bool isCrit = IsCritical(attacker, ability);

            foreach (var target in targets)
            {
                var damage  = DamageCalculator.GetTotalDamage(attacker, target, ability, isCrit);
                var healing = DamageCalculator.GetHeal(attacker, ability, isCrit);
                healing += target.Resources.MaxHealth * ability.PercentHeal / 100;

                target.Resources.CurrentHealth += healing;
                target.Resources.CurrentHealth -= DamageCalculator.GetDamageTypesAsInt(damage);
                if (target.Resources.CurrentHealth > 0)
                {
                    _statusEffectManager.Apply(target, attacker, ability.AppliedStatusEffects, isCrit);
                    if (target.Resources.CurrentHealth > target.Resources.MaxHealth)
                    {
                        target.Resources.CurrentHealth = target.Resources.MaxHealth;
                    }
                }
                else
                {
                    _statusEffectManager.RemoveAll(target);
                    target.Resources.CurrentHealth = 0;
                }
            }

            if (ability.SelfAppliedStatusEffects.Any())
            {
                _statusEffectManager.Apply(attacker, attacker, ability.SelfAppliedStatusEffects, isCrit);
            }
        }
Пример #24
0
        /// <inheritdoc />
        public virtual ActionUseResult <TSource> Use <TSource>(Character user, IEnumerable <Character> otherCharacters)
        {
            if (ActionTargetCalculator.IsReactive)
            {
                EstablishTargets(user, otherCharacters);
            }

            if (!_targetsSet)
            {
                return(new ActionUseResult <TSource>
                {
                    Success = false,
                    Results = Enumerable.Empty <IActionResult <TSource> >(),
                    Tags = new HashSet <string>
                    {
                        DamageActionResultTags.NoTargetsSet,
                    },
                });
            }

            // action only succeeds if damage is calculated against all targets successfully
            var damageCalculations = DamageCalculator.Calculate(user, this, _targets.Where(c => !c.IsDead));

            if (damageCalculations.Any(d => !d.Success))
            {
                return(new ActionUseResult <TSource>
                {
                    Success = false,
                    Results = Enumerable.Empty <IActionResult <TSource> >(),
                    Tags = new HashSet <string>
                    {
                        DamageActionResultTags.DamageCalculationFailed,
                    },
                });
            }

            var results = new List <IActionResult <TSource> >();

            foreach (var calculation in damageCalculations)
            {
                var result = calculation.Target.ReceiveDamage <TSource>(calculation.Amount, user);
                result.Action = this;

                foreach (var tag in Tags)
                {
                    result.Tags.Add(tag);
                }

                results.Add(result);
            }

            _targetsSet = false;

            return(new ActionUseResult <TSource>
            {
                Success = true,
                Results = results,
            });
        }
Пример #25
0
        public void More()
        {
            var calc = new DamageCalculator();

            calc.Base = 10;
            calc.More.Add(.1f);
            Check(11, calc.CalcDamage());
        }
Пример #26
0
 public Trap(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     Charge = (int)info.GetValue(chargeSerializationName, typeof(int));
     Bonus = (int)info.GetValue(bonusSerializationName, typeof(int));
     Damage = (DamageCalculator)info.GetValue(damageSerializationName, typeof(DamageCalculator));
     IsCurrentlyTriggerable = (bool)info.GetValue(currTriggerableSerializationName, typeof(bool));
 }
Пример #27
0
        public void Increased()
        {
            var calc = new DamageCalculator();

            calc.Base      = 10;
            calc.Increased = .1f;
            Check(11, calc.CalcDamage());
        }
Пример #28
0
 public Trap(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     Charge = (int)info.GetValue(chargeSerializationName, typeof(int));
     Bonus  = (int)info.GetValue(bonusSerializationName, typeof(int));
     Damage = (DamageCalculator)info.GetValue(damageSerializationName, typeof(DamageCalculator));
     IsCurrentlyTriggerable = (bool)info.GetValue(currTriggerableSerializationName, typeof(bool));
 }
Пример #29
0
        public void 相性倍率のダメージは切り捨てられる()
        {
            var fireMove2 = new MonsterMove(new MonsterMovePower(3), Type.Fire);
            var param     = new MonsterParams(prop, Type.Water);
            var dmg       = DamageCalculator.Calculate(param, fireMove2);

            // 1.5 が 切り捨てで 1 になる
            Assert.That(dmg.value, Is.EqualTo(1));
        }
Пример #30
0
        public void DamageReduction()
        {
            var first = DamageCalculator.ReduceDamageByArmor(100, 10);

            Assert.Equal(90, first);
            var second = DamageCalculator.ReduceDamageByArmor(100, 33);

            Assert.Equal(67, second);
        }
Пример #31
0
 public HealSpell(ISpellcaster launcher,
                  List <IDamageable> targets,
                  DamageCalculator dmg,
                  Animation animation = null)
     : base(launcher, animation)
 {
     this.targets = targets;
     this.dmg     = dmg;
 }
Пример #32
0
    void Awake()
    {
        if (calculator == null)
        {
            calculator = this;
            DontDestroyOnLoad(this.gameObject);

        }
        else if (calculator != this)
        {
            Destroy(this.gameObject);
        }
    }
Пример #33
0
 public Trap(string name,
             int charge,
             int bonus,
             DamageCalculator damage,
             string description = "Basic Trap",
             Coord position = new Coord())
     : base(name,
           "^",
           System.Drawing.Color.Blue,
           true,
           false,
           description,
           position,
           true)
 {
     Charge = charge;
     Bonus = bonus;
     Damage = damage;
     IsCurrentlyTriggerable = true;
 }
Пример #34
0
 void Awake()
 {
     //ACCESS TO HASHES, ANIMATOR AND GLOBAL DATA
     audio = GetComponent<AudioSource> ();
     globalData = GameObject.FindGameObjectWithTag("GameController");
     looker = GameObject.FindGameObjectWithTag("CamFollow").GetComponent<CamLooker>();
     follow = GameObject.FindWithTag("CamFollow").transform;
     hash = globalData.GetComponent<HashIDs>();
     gameData = globalData.GetComponent<GameData>();
     controller = GetComponent<CharacterController>();
     animator = GetComponent<Animator>();
     lightLevels = GameObject.FindGameObjectWithTag("LightLevels").GetComponent<LightLevels>();
     damageCalculator = globalData.GetComponent<DamageCalculator>();
     agent = GetComponent<NavMeshAgent> ();
     blinker = transform.FindChild ("Flash");
     swapper = GameObject.FindWithTag("PlayerSwapper").transform;
     Vector3 startingPos = new Vector3(transform.position.x, 0, transform.position.z);
     transform.position = startingPos;
     voice = transform.FindChild ("Voice").GetComponent<AudioSource>();
     originalVolume = voice.volume;
     originalPitch = voice.pitch;
     if(body!=null) {
         mesh = body.GetComponent<SkinnedMeshRenderer>();
         toggleBlendShape(0);
     }
     meshObjects = transform.FindChild ("Body").gameObject;
     if(weaponObject!=null) weaponMeshRenderer = weaponObject.GetComponent<MeshRenderer>();
 }
Пример #35
0
    void Awake()
    {
        blinker = transform.FindChild ("Flash");
        if(blinker == null) Debug.LogError ("EnemyFlash Projector Not Found!");
        rigidbody = GetComponent<Rigidbody> ();
        globalData = GameObject.FindGameObjectWithTag("GameController");
        damageCalculator = globalData.GetComponent<DamageCalculator>();
        animator = GetComponent<Animator>();
        hash = globalData.GetComponent<HashIDs>();
        gameData = globalData.GetComponent<GameData>();
        agent = GetComponent<NavMeshAgent>();
        blinkShader = Shader.Find("Reflective/Bumped Diffuse");
        lightLevels = GameObject.FindGameObjectWithTag("LightLevels").GetComponent<LightLevels>();
        audio = GetComponent<AudioSource>();
        lifeBar = GameObject.Find ("EnemyLife").GetComponent<Slider>();

        //GET PLAYER
        playerObject = GameObject.FindWithTag("Player"); //Get player container
        if(playerObject != null) {
            player = playerObject.transform;
            playerAnimator = player.GetComponent<Animator>();
        }
        col = GetComponent<SphereCollider>();

        if (body != null) {
            materials = body.GetComponent<SkinnedMeshRenderer>().materials;
            colors = new Color[materials.Length];
            storeColors();
            regularShader = materials[0].shader;
        }

        if(selfWeaponData == null && changesElementWithWeather) Debug.LogError("WeaponData on enemy body not referenced!");
        originalElement = element;

        if(changesElementWithWeather) swapElement();
    }