示例#1
0
 private void CheckNewState()
 {
     if (pet.info.damageType == Common.WeaponDamageType.damage)
     {
         if (m_OwnerTarget.inCombat)
         {
             pet.SetState(new PetCombatState(pet));
         }
     }
     else if (pet.info.damageType == Common.WeaponDamageType.heal)
     {
         if (m_OwnerDamagable.health < m_OwnerDamagable.maximumHealth)
         {
             if (m_PetTarget.noTarget || m_PetTarget.IsNotTarget(pet.owner.Id))
             {
                 m_PetTarget.SetTarget(pet.owner);
             }
             m_PetWeapon.MakeShot();
         }
     }
 }
示例#2
0
        public override void Update(float deltaTime)
        {
            if (!m_PetTarget.targetObject)
            {
                if ((false == m_OwnerTarget.inCombat) && (m_OwnerTarget.subscriberCount == 0))
                {
                    //  s_Log.InfoFormat("set idle state with not combat".Color(LogColor.orange));
                    pet.SetState(new PetIdleState(pet));
                }
                if (pet.info.damageType == Common.WeaponDamageType.heal)
                {
                    //     s_Log.InfoFormat("set idle state not damager".Color(LogColor.orange));
                    pet.SetState(new PetIdleState(pet));
                }

                var enemy = m_OwnerTarget.anyEnemySubscriber;

                if (enemy)
                {
                    if ((false == m_PetTarget.hasTarget) || (m_PetTarget.targetId != enemy.Id))
                    {
                        m_PetTarget.SetTarget(enemy);
                    }
                    MoveToTarget(deltaTime);
                    FireAtTarget();
                }
                else
                {
                    //   s_Log.InfoFormat("set idle state with invalid enemy".Color(LogColor.orange));
                    pet.SetState(new PetIdleState(pet));
                }
            }
            else
            {
                MoveToTarget(deltaTime);
                FireAtTarget();
            }
        }
示例#3
0
        protected virtual bool FindCombatTarget()
        {
            FractionType selfFraction = (FractionType)mCharacter.fraction;

            if (mReturningToStartPosition)
            {
                return(false);
            }

            if (selfFraction == FractionType.BotNeutral)
            {
                return(false);
            }


            var it = (nebulaObject.world as MmoWorld).GetItem((item) => {
                //don't look at self
                if (item.Id == nebulaObject.Id)
                {
                    return(false);
                }
                //don't look invisible items
                if (item.invisible)
                {
                    return(false);
                }

                var itemDamagable = item.GetComponent <DamagableObject>();
                var itemCharacter = item.GetComponent <CharacterObject>();


                if (itemDamagable && itemCharacter)
                {
                    var itemFraction = (FractionType)itemCharacter.fraction;
                    if (nebulaObject.resource.fractionResolver.RelationFor(selfFraction).RelationTo(itemFraction) == FractionRelation.Enemy)
                    {
                        float distance = transform.DistanceTo(item.transform);

                        if (mUseHitProbForAgro)
                        {
                            float hitProb = mWeapon.HitProbTo(item);
                            if (hitProb >= 0.5f && distance < MAX_AGRO)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            float d = transform.DistanceTo(item.transform);

                            if (isPlanetTurret || isTurret || isOutpost || isFortification)
                            {
                                return(d < mWeapon.optimalDistance);
                            }
                            else
                            {
                                if (d < Mathf.Clamp(0.7f * mWeapon.optimalDistance, MIN_AGRO, MAX_AGRO))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                return(false);
            });

            if (it)
            {
                mStartPosition = transform.position;
                mTarget.SetTarget(it);
                return(true);
            }
            return(false);
        }