Пример #1
0
 private void TryAttack(int a_itemType, ItemDef a_handItemDef)
 {
     if (a_handItemDef.buildingIndex > 0)
     {
         bool flag = this.m_buildMan.CreateBuilding(a_handItemDef.buildingIndex, this.m_char.transform.position + this.GetForward() * 2f, this.m_pid, this.m_buildRotation, 100, true);
         if (flag)
         {
             this.m_inventory.DeclineHandItem();
             this.AddXp(20);
             if (a_handItemDef.buildingIndex == 102 && this.IsSaint())
             {
                 this.ChangeKarmaBy(-2.5f);
             }
             this.m_updateContainersFlag = true;
             this.m_updateInfoFlag       = true;
         }
     }
     else
     {
         ItemDef itemDef = a_handItemDef;
         if (itemDef.damage == 0f)
         {
             itemDef = Items.GetItemDef(0);
         }
         if (Time.time > this.m_nextAttackTime)
         {
             if (this.FireWeapon(itemDef))
             {
                 if (!this.HandleSpecialItemAbility(a_itemType))
                 {
                     Vector3   a_targetPos    = this.m_char.transform.position + this.GetForward() * 1.2f;
                     Transform victim         = this.m_victim;
                     float     a_weaponDamage = Raycaster.Attack(this.m_char.transform, itemDef, a_targetPos, ref victim);
                     this.CalculateXpAndKarma(victim, a_weaponDamage);
                 }
                 this.m_nextAttackTime = Time.time + itemDef.attackdur;
             }
             else if (Time.time > this.m_nextOutOfAmmoMsgTime)
             {
                 this.m_server.SendSpecialEvent(this, eSpecialEvent.noAmmo);
                 this.m_nextOutOfAmmoMsgTime = Time.time + 1f;
             }
         }
     }
 }
Пример #2
0
    private void TryAttack(int a_itemType, ItemDef a_handItemDef)
    {
        if (a_handItemDef.buildingIndex > 0)
        {
            if (m_buildMan.CreateBuilding(a_handItemDef.buildingIndex, m_char.transform.position + GetForward() * 2f, m_pid, m_buildRotation))
            {
                m_inventory.DeclineHandItem();
                AddXp(20);
                if (a_handItemDef.buildingIndex == 102 && IsSaint())
                {
                    ChangeKarmaBy(-2.5f);
                }
                m_updateContainersFlag = true;
                m_updateInfoFlag       = true;
            }
            return;
        }
        ItemDef itemDef = a_handItemDef;

        if (itemDef.damage == 0f)
        {
            itemDef = Items.GetItemDef(0);
        }
        if (!(Time.time > m_nextAttackTime))
        {
            return;
        }
        if (FireWeapon(itemDef))
        {
            if (!HandleSpecialItemAbility(a_itemType))
            {
                Vector3   a_targetPos    = m_char.transform.position + GetForward() * 1.2f;
                Transform a_target       = m_victim;
                float     a_weaponDamage = Raycaster.Attack(m_char.transform, itemDef, a_targetPos, ref a_target);
                CalculateXpAndKarma(a_target, a_weaponDamage);
            }
            m_nextAttackTime = Time.time + itemDef.attackdur;
        }
        else if (Time.time > m_nextOutOfAmmoMsgTime)
        {
            m_server.SendSpecialEvent(this, eSpecialEvent.noAmmo);
            m_nextOutOfAmmoMsgTime = Time.time + 1f;
        }
    }
Пример #3
0
    private void DoRaycast()
    {
        Transform a_target = null;

        Raycaster.Attack(base.transform, m_handItemDef, base.transform.position + base.transform.forward * 1.2f, ref a_target);
    }
Пример #4
0
 private void HandleEnemy()
 {
     if (!(null != m_enemy))
     {
         return;
     }
     if (m_isHappy && m_handItemDef.damage > 5f)
     {
         float   a_sqrDist = 10000f;
         Vector3 vector    = (!(m_dontAttackTime < Time.time)) ? Vector3.zero : GetAttackDir(ref a_sqrDist);
         if (Vector3.zero != vector)
         {
             base.transform.rotation = Quaternion.LookRotation(vector);
             Idle();
             if (Time.time > m_nextAttackTime)
             {
                 Transform a_target = m_enemy;
                 Raycaster.Attack(base.transform, m_handItemDef, m_enemy.transform.position, ref a_target);
                 if (m_handItemDef.ammoItemType > 0 && null != a_target && a_target != m_enemy)
                 {
                     m_dontAttackTime = Time.time + Random.Range(3f, 6f);
                 }
                 if (a_target == m_enemy && m_causeCondition != eCondition.none)
                 {
                     ControlledChar component    = m_enemy.GetComponent <ControlledChar>();
                     ServerPlayer   serverPlayer = (!(null != component)) ? null : component.GetServerPlayer();
                     if (serverPlayer != null)
                     {
                         serverPlayer.SetCondition(m_causeCondition, true);
                     }
                 }
                 m_nextAttackTime = Time.time + m_handItemDef.attackdur * attachDurMultip;
             }
             m_state = eBodyBaseState.attacking;
         }
         else if (m_approach)
         {
             if (Time.time > m_nextRepositionTime)
             {
                 GoTo(m_enemy.position);
                 m_nextRepositionTime = Time.time + 0.05f + Mathf.Clamp01(a_sqrDist / 200f);
             }
         }
         else
         {
             m_enemy = null;
             GoTo(m_homePos);
         }
     }
     else if (Time.time > m_nextRepositionTime)
     {
         Vector3 normalized = (base.transform.position - m_enemy.position).normalized;
         Vector3 vector2    = base.transform.position + normalized * 10f;
         if (0.8f > Util.GetTerrainHeight(vector2) || Random.Range(0, 5) == 0)
         {
             float y = (Random.Range(0, 2) != 0) ? 90f : (-90f);
             vector2 = base.transform.position + Quaternion.Euler(0f, y, 0f) * normalized * 10f;
         }
         GoTo(vector2);
         m_nextRepositionTime = Time.time + 1f;
     }
 }
Пример #5
0
 private void HandleEnemy()
 {
     if (null != this.m_enemy)
     {
         if (this.m_isHappy && this.m_handItemDef.damage > 5f)
         {
             float   num    = 10000f;
             Vector3 vector = (this.m_dontAttackTime >= Time.time) ? Vector3.zero : this.GetAttackDir(ref num);
             if (Vector3.zero != vector)
             {
                 base.transform.rotation = Quaternion.LookRotation(vector);
                 this.Idle();
                 if (Time.time > this.m_nextAttackTime)
                 {
                     Transform enemy = this.m_enemy;
                     Raycaster.Attack(base.transform, this.m_handItemDef, this.m_enemy.transform.position, ref enemy);
                     if (this.m_handItemDef.ammoItemType > 0 && null != enemy && enemy != this.m_enemy)
                     {
                         this.m_dontAttackTime = Time.time + UnityEngine.Random.Range(3f, 6f);
                     }
                     if (enemy == this.m_enemy && this.m_causeCondition != eCondition.none)
                     {
                         ControlledChar component    = this.m_enemy.GetComponent <ControlledChar>();
                         ServerPlayer   serverPlayer = (!(null != component)) ? null : component.GetServerPlayer();
                         if (serverPlayer != null)
                         {
                             serverPlayer.SetCondition(this.m_causeCondition, true);
                         }
                     }
                     this.m_nextAttackTime = Time.time + this.m_handItemDef.attackdur * this.attachDurMultip;
                 }
                 this.m_state = eBodyBaseState.attacking;
             }
             else if (this.m_approach)
             {
                 if (Time.time > this.m_nextRepositionTime)
                 {
                     this.GoTo(this.m_enemy.position);
                     this.m_nextRepositionTime = Time.time + 0.05f + Mathf.Clamp01(num / 200f);
                 }
             }
             else
             {
                 this.m_enemy = null;
                 this.GoTo(this.m_homePos);
             }
         }
         else if (Time.time > this.m_nextRepositionTime)
         {
             Vector3 normalized = (base.transform.position - this.m_enemy.position).normalized;
             Vector3 vector2    = base.transform.position + normalized * 10f;
             if (0.8f > Util.GetTerrainHeight(vector2) || UnityEngine.Random.Range(0, 5) == 0)
             {
                 float y = (UnityEngine.Random.Range(0, 2) != 0) ? 90f : -90f;
                 vector2 = base.transform.position + Quaternion.Euler(0f, y, 0f) * normalized * 10f;
             }
             this.GoTo(vector2);
             this.m_nextRepositionTime = Time.time + 1f;
         }
     }
 }
Пример #6
0
    private void DoRaycast()
    {
        Transform transform = null;

        Raycaster.Attack(base.transform, this.m_handItemDef, base.transform.position + base.transform.forward * 1.2f, ref transform);
    }