示例#1
0
    // Update is called once per frame
    void Update()
    {
        m_attackTimer += Time.deltaTime;

        if (m_launcher)
        {
            GetComponent<LineRenderer>().SetPosition(0, m_launcher.transform.position);
            GetComponent<LineRenderer>().SetPosition(1, m_launcher.transform.position + (m_launcher.transform.forward * beamLength));
            RaycastHit hit;

            if (Physics.Raycast(m_launcher.transform.position, m_launcher.transform.forward, out hit, beamLength))
            {
                if (hit.transform.gameObject == m_target)
                {
                    if (m_attackTimer >= m_attackSpeed)
                    {
                        DamageData dmgData = new DamageData();
                        dmgData.damage = m_damage;

                        MessageHandler msgHandler = m_target.GetComponent<MessageHandler>();

                        if (msgHandler)
                        {
                            msgHandler.GiveMessage(MessageType.DAMAGED, m_launcher, dmgData);
                        }

                        m_attackTimer = 0.0f;
                    }
                }
            }
        }
    }
示例#2
0
文件: Damage.cs 项目: Clavus/Tank
    /// <summary>
    /// Applies explosion damage to a list of found colliders, but makes sure to apply damage only once to the same gameobject.
    /// </summary>
    /// <param name="colliders"></param>
    /// <param name="amount"></param>
    /// <param name="damageType"></param>
    /// <param name="inflictor"></param>
    public static void ApplyExplosionDamage(Collider[] colliders, int amount, DamageType damageType = DamageType.Explosion, GameObject inflictor = null)
    {
        List<GameObject> seen = new List<GameObject>();
        DamageData dm = new DamageData(amount, damageType, inflictor);
        IDamagable[] damagables;
        IDamagable[] rigidBodyDamagables;

        foreach (Collider coll in colliders)
        {
            if (seen.Contains(coll.gameObject))
                continue;

            seen.Add(coll.gameObject); // avoid applying damage twice to the IDamagable components on the same game object

            damagables = coll.GetComponents(typeof (IDamagable)).Cast<IDamagable>().ToArray();
            Array.ForEach(damagables, damagable => damagable.TakeDamage(dm)); ;

            // Also apply damage to rigidbody of this collider, but only if they're different gameobjects (otherwise we already did)
            if (coll.attachedRigidbody != null && !seen.Contains(coll.attachedRigidbody.gameObject))
            {
                seen.Add(coll.attachedRigidbody.gameObject);

                rigidBodyDamagables = coll.attachedRigidbody.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
                Array.ForEach(rigidBodyDamagables, damagable => damagable.TakeDamage(dm));
            }
        }
    }
示例#3
0
 public override void SetDamageData(DamageData damage)
 {
     damage.Damage *= DamageModifier;
     damage.Sources |= Entity.Groups;
     damage.Types |= DamageTypes;
     this.damage = damage;
 }
示例#4
0
    public override void SetDamageData(DamageData damage)
    {
        base.SetDamageData(damage);

        this.damage.Sources = damage.Sources;
        this.damage.Types = damage.Types;
    }
示例#5
0
    public override void SetDamageData(DamageData damage)
    {
        var time = Entity.GetComponent<TimeComponent>();

        damage.Damage *= DamageModifier * time.DeltaTime;
        damage.Types |= DamageTypes.Laser;
        this.damage = damage;
    }
示例#6
0
    protected virtual void OnDamaged(DamageData damage)
    {
        CurrentHealth -= damage.Damage;

        if (!died && CurrentHealth <= 0)
        {
            died = true;
            Entity.SendMessage(EntityMessages.OnDie);
        }
    }
示例#7
0
 public virtual bool Damage(DamageData damage)
 {
     if (CanBeDamagedBy(damage))
     {
         Entity.SendMessage(EntityMessages.OnDamaged, damage);
         return true;
     }
     else
         return false;
 }
示例#8
0
 public void transmitDamage(Transform damageTarget, DamageData damage)
 {
     if (damageTarget.GetComponent<DamageReceiver>())
     {
         damageTarget.GetComponent<DamageReceiver>().getDamage(damage);
     }
     else
     {
         GameObject delay = Resources.Load("Prefabs/Objects/Effects/CommonImpactExplosion") as GameObject;
         Object.Instantiate(delay, this.HittedPoint, this.DirectionRotation * Quaternion.Euler(-180, 0, 0));
     }
 }
示例#9
0
文件: Damage.cs 项目: Clavus/Tank
    /// <summary>
    /// Apply damage to collider if it, or its rigidbody, has an IDamagable derived component.
    /// </summary>
    /// <param name="coll"></param>
    /// <param name="amount"></param>
    /// <param name="damageType"></param>
    /// <param name="inflictor"></param>
    public static void ApplyTo(Collider coll, int amount, DamageType damageType, GameObject inflictor)
    {
        IDamagable[] damagables = coll.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
        DamageData dm = new DamageData(amount, damageType, inflictor);
        Array.ForEach(damagables, damagable => damagable.TakeDamage(dm));

        // Also apply damage to rigidbody of this collider, but only if they're different gameobjects (otherwise we already did)
        if (coll.attachedRigidbody != null && coll.gameObject != coll.attachedRigidbody.gameObject)
        {
            IDamagable[] rigidBodyDamagables = coll.attachedRigidbody.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
            Array.ForEach(rigidBodyDamagables, damagable => damagable.TakeDamage(dm));
        }
    }
示例#10
0
文件: ImpactGun.cs 项目: 2dkott/NSCom
    // Use this for initialization
    void Start()
    {
        rcasting = new RayCasting();
        damageData = new DamageData(damage);

        if (burrelPoint == null)
        {
            Debug.LogError("Gun Burrel Point is not recognized");
            burrelPoint = this.gameObject.transform;
        }

        gunflame = burrelPoint.GetComponent<ParticleSystem>();
    }
示例#11
0
    // Use this for initialization
    public ServerDamage()
    {
        functionName = "Damage";
        // Database tables name
        tableName = "damage_type";
        functionTitle = "Damage Configuration";
        loadButtonLabel = "Load Damage";
        notLoadedText = "No Damage loaded.";
        // Init
        dataRegister = new Dictionary<int, DamageData> ();

        editingDisplay = new DamageData ();
        originalDisplay = new DamageData ();
    }
示例#12
0
    private void CopyData(DamageData source, DamageData destination) {
		destination.soundname = source.soundname;
		destination.cStart = source.cStart;
		destination.cEnd = source.cEnd;
		destination.ownerID = source.ownerID;
		destination.Xflipped = source.Xflipped;
		destination.effectspawn = source.effectspawn;
        destination.amount = source.amount;
        destination.type = source.type;
		destination.knockback_y = source.knockback_y;
		destination.knockback_x = source.knockback_x;
		destination.effect = source.effect;
		destination.stun = source.stun;
		destination.blockstun = source.blockstun;
    }
示例#13
0
 private void CopyData(DamageData source, DamageData destination)
 {
     destination.soundname   = source.soundname;
     destination.cStart      = source.cStart;
     destination.cEnd        = source.cEnd;
     destination.ownerID     = source.ownerID;
     destination.Xflipped    = source.Xflipped;
     destination.effectspawn = source.effectspawn;
     destination.amount      = source.amount;
     destination.type        = source.type;
     destination.knockback_y = source.knockback_y;
     destination.knockback_x = source.knockback_x;
     destination.effect      = source.effect;
     destination.stun        = source.stun;
     destination.blockstun   = source.blockstun;
 }
示例#14
0
    public void SetDamageShow(DamageData damageData, Vector3 orgPos)
    {
        showDamage = 0;
        plusDamage = damageData.damage;
        speedRatio = Random.Range(0.5f, 1.2f);
        plusSpeed  = damageData.damage / speedRatio;
        seType     = SpecailEffectType.Damage;
        showTime   = 0.5f;

        damageTxtIdx = System.Convert.ToInt32(damageData.isCrt);
        damageTxt[damageTxtIdx].GetComponent <TweenPostion>().SetJump(orgPos, orgPos + Vector3.right * Random.Range(-50, 50), speedRatio);
        damageTxt [damageTxtIdx].color = Const.attriColor [damageData.attributes];
        setComplete  = true;
        isRun        = false;
        isShowDamage = false;
    }
示例#15
0
    public void TakeDamage(DamageData damageData)
    {
        var value         = damageData.damage_ammount;
        var armorPiercing = damageData.armorPiercing;

        if (armorPiercing == false)
        {
            value = value - armor;
        }

        currentHealth -= value;
        if (currentHealth < 0)
        {
            currentHealth = 0;
        }
    }
示例#16
0
        private void ApplyDamage(DamageData date)
        {
            animator.SetTrigger(hashHit);

            Vector3 damageVec = date.direction;

            damageVec.y = 0;
            damageVec   = damageVec.normalized;

            Vector3 localHurtDir = this.transform.InverseTransformDirection(damageVec);

            animator.SetFloat(hashHitFromX, localHurtDir.x);
            animator.SetFloat(hashHitFromY, localHurtDir.z);

            CameraShake.Shake(hitShakeRadius, hitShakeTime);
        }
示例#17
0
 protected override AttackResult DoAttackMonster(Character p_attacker, Monster p_target, Single p_magicPower)
 {
     if (p_target != null)
     {
         Single        criticalMagicHitChance   = p_attacker.FightValues.CriticalMagicHitChance;
         Single        magicalCriticalDamageMod = p_attacker.FightValues.MagicalCriticalDamageMod;
         List <Damage> list   = new List <Damage>();
         Int32         num    = Convert.ToInt32(Math.Round(p_target.CurrentHealth * m_staticData.Damage[0].Minimum / 100f, MidpointRounding.AwayFromZero));
         DamageData    p_data = new DamageData(EDamageType.EARTH, num, num);
         list.Add(Damage.Create(p_data, magicalCriticalDamageMod));
         Attack      p_attack     = new Attack(0f, criticalMagicHitChance, list);
         EDamageType p_damageType = ESkillIDToEDamageType(m_staticData.SkillID);
         return(p_target.CombatHandler.AttackMonster(p_attacker, p_attack, false, true, p_damageType, true, p_attacker.SkillHandler.GetResistanceIgnoreValue(m_staticData.SkillID)));
     }
     return(null);
 }
示例#18
0
文件: Packet.cs 项目: wyuurla/006772
        //
        public bool Deserialize(ref DamageData element)
        {
            if (GetDataSize() == 0)
            {
                // 데이터가 설정되어 있지 않습니다.
                return(false);
            }

            bool ret = true;

            ret &= Deserialize(ref element.target, DamageData.characterNameLength);
            ret &= Deserialize(ref element.attacker);
            ret &= Deserialize(ref element.damage);

            return(ret);
        }
示例#19
0
    public void TakeDamage(DamageData dd)
    {
        float shieldBlock = 0f;

        if (shieldOn)
        {
            //shieldBlock = hardwareShield.GetComponent<Shield>().GetShieldBlock();
        }
        dd.armorvalue = shieldBlock;
        dd.defense    = 0f;
        float take = Const.a.GetDamageTakeAmount(dd);

        hm.health -= take;
        PlayerNoise.PlayOneShot(PainSFXClip);
        //Debug.Log("Player Health: " + health.ToString());
    }
        public void ApplyDamage(DamageData data)
        {
            if (InvalidTimer <= 0.0f && data.Attacker.GetAttackerType() != Status.AttackerType)
            {
                InvalidTimer = InvalidTime;

                if (tag == "Player")
                {
                    Counter.Instance.Attacked();
                }
                else
                {
                    Counter.Instance.Attack();
                }
            }
        }
示例#21
0
文件: Shove.cs 项目: McPalm/FEPonies
    public void OnHit(DamageData dd)
    {
        Tile moveTo = dd.target.Tile;

        new Mydebuff(dd.target.Character, speedPenalty);
        //if we can enter the tile
        if (!(moveTo is WaterTile) & !dd.source.Character.Flight)
        {
            // and we can push the target
            if (Push.SmartStaticApply(moveTo, dd.SourceTile))
            {
                dd.source.AttackInfo.AttackAnimation.Cancel();
                dd.source.MoveTo(moveTo);
            }
        }
    }
示例#22
0
    void ExplodeOnDeath()
    {
        ExplosionForce ef    = GetComponent <ExplosionForce> ();
        DamageData     ddNPC = Const.SetNPCDamageData(index, Const.aiState.Attack3, gameObject);
        float          take  = Const.a.GetDamageTakeAmount(ddNPC);

        ddNPC.other  = gameObject;
        ddNPC.damage = take;
        //enemy.GetComponent<HealthManager>().TakeDamage(ddNPC); Handled by ExplodeInner
        if (ef != null)
        {
            ef.ExplodeInner((transform.position + viewVerticalOffset) + explosionOffset, attack3Force, attack3Radius, ddNPC);
        }
        healthManager.ObjectDeath(SFXAttack1);
        GetComponent <MeshRenderer> ().enabled = false;
    }
示例#23
0
        public override void FillFightValues(Boolean p_offHand, FightValues p_fightValue)
        {
            DamageData baseDamage = GetBaseDamage();

            if (p_offHand)
            {
                p_fightValue.OffHandDamage.Add(baseDamage);
                p_fightValue.OffHandCriticalDamageMod = 0f;
            }
            else
            {
                p_fightValue.MainHandDamage.Add(baseDamage);
                p_fightValue.MainHandCriticalDamageMod = 0f;
            }
            p_fightValue.MagicalCriticalDamageMod += m_staticData.AddCritDamage;
        }
示例#24
0
        private void OnTriggerEnter(Collider other)
        {
            var damageable = other.GetComponent <IDamagable>();

            if (damageable == null)
            {
                return;
            }

            var damageData = new DamageData(1);

            damageable.ReceiveDamage(damageData);
            onHit.OnNext(Unit.Default);

            Destroy();
        }
示例#25
0
文件: GunShot.cs 项目: 2dkott/NSCom
    public void shootWithRayStraight(DamageData damage)
    {
        gunSourceDirection = gunSource.TransformDirection(Vector3.forward);
        if (Physics.Raycast(gunSource.position, gunSourceDirection, out hit, 10000f))
        {
            if (hit.transform != null)
            {
                //this.HittedTransform = hit.transform;
                //this.HittedVector = hit.point;
            }
            else
            {

            }
        }
    }
示例#26
0
    /**********************************************************************************/
    // функция нанесения урона юниту
    //
    /**********************************************************************************/
    public virtual void TakeDamage(DamageData damage)
    {
        m_unitHP -= damage.Damage;

        // если юнит повержен
        if (m_unitHP <= 0)
        {
            m_unitHP = 0;

            // извещаем всех о смерти юнита
            if (UnitIsDown != null)
            {
                UnitIsDown(damage);
            }
        }
    }
示例#27
0
    /// <summary>
    /// Receive messages.
    /// Must have the same parameters as the MessageDelegate delegate.
    /// </summary>
    /// <param name="messageType"></param>
    /// <param name="go"></param>
    /// <param name="data"></param>
    void ReceiveMessage(MessageType messageType, GameObject go, MessageData data)
    {
        switch (messageType)
        {
        case MessageType.DAMAGED:

            // Cast message to damage data
            DamageData damageData = data as DamageData;

            if (damageData != null)
            {
                ApplyDamage(damageData.damage, go);
            }

            break;
        }
    }
示例#28
0
    void ApplyAndShit(Tile ti)
    {
        Character user = GetComponent <Unit>().Character;
        int       dmg  = user.Level + 4 + user.ModifiedStats.intelligence;

        foreach (Tile t in _tgts)
        {
            if (t.isOccuppied)
            {
                DamageData attackData = new DamageData();
                attackData.baseDamage           = dmg;
                attackData.resistanceMultiplier = 1f;
                attackData.defenceMultiplier    = 0f;
                t.Unit.Damage(attackData);
            }
        }
    }
示例#29
0
文件: Damage.cs 项目: McPalm/FEPonies
    static public int StaticApply(DamageData attackData)
    {
        Unit targetUnit = attackData.target;

        if (targetUnit != null)
        {
            // deliver damage to target.
            return(targetUnit.Damage(attackData));
        }
        else
        {
            Debug.LogError("Damage IEffect failed!\n" +
                           "User="******"\n" +
                           "Target=" + attackData.target);
            return(0);
        }
    }
示例#30
0
    private void BroadcastDamageAction(TriggerEnterData data)
    {
        // if the source was with me.
        if (data.source.transform != transform)
        {
            return;
        }

        var actionData = new DamageData
        {
            target = data.other.transform,
            damage = CreatureData.damage,
            source = data.source
        };

        DamageAction(actionData);
    }
示例#31
0
    private void Awake()
    {
        damageDatas = new DamageData[createDamageObjectCount];
        for (int i = 0; i < createDamageObjectCount; i++)
        {
            var createObject = GameObject.Instantiate(baseDamageObject, transform);
            createObject.transform.position = GlobalDefine.DisablePos;

            DamageData data = new DamageData();
            data.transform = createObject.transform;
            data.animation = createObject.GetComponent <Animation>();
            data.text      = createObject.GetComponentInChildren <TextMeshProUGUI>();
            damageDatas[i] = data;
        }

        baseDamageObject.SetActive(false);
    }
示例#32
0
    private IEnumerator TakeDamagePerSecondInDuration(DamageData data)
    {
        while (data.duration >= 0)
        {
            if (data.damageImmediate)
            {
                // Would not trigger critical. (Ex: Blood, Ignite, Poison...)
                DamageData newData = new DamageData(data.damageSource, data.element, data.damage, false);
                TakeDamage(newData);
            }
            yield return(new WaitForSeconds(data.timesOfPerDamage));

            data.duration       -= data.timesOfPerDamage;
            data.damageImmediate = true;
        }
        yield break;
    }
    /// <summary>
    ///
    /// </summary>
    void MakeDamageRepeting()
    {
        DamageData info = new DamageData();

        info.Damage = m_RepetingDamage;
        if (RepetingDamageInfo != null)
        {
            info        = RepetingDamageInfo;
            info.Damage = m_RepetingDamage;
        }
        else
        {
            info.Direction = Vector3.zero;
            info.Cause     = DamageCause.Map;
        }
        GetDamage(info);
    }
示例#34
0
                } // end MoveBackward

                private void FlightArrow()
                {
                    AnimationState state = character.avatar.GetCurrentState("skill1_2");

                    if (null == state || state.normalizedTime < 0.3f)
                    {
                        return;
                    }
                    // end if
                    isFlight = true;
                    DamageData  damage = new DamageData(character);
                    PierceArrow arrow  = Object.Instantiate(ResourcesTool.LoadPrefab("pierce_arrow")).AddComponent <PierceArrow>();

                    arrow.transform.position = character.position + Vector3.up * 0.8f;
                    arrow.transform.rotation = character.rotation;
                    arrow.SetDamage(damage);
                } // end FlightArrow
示例#35
0
    public void ProcessDamage(DamageData hit)
    {
        TankArmourPiece piece = FindBestPieceAtPoint(hit.point, SearchFlags.FullOnly, true);

        if (piece == null)
        {
            Debug.LogWarning("Something weird happened, I got damaged without finding a best");
        }
        piece.maxHealth -= hit.damage;
        List <TankArmourPickup> pickups = new List <TankArmourPickup>();

        if (piece.maxHealth <= 0)
        {
            TryRemovePiece(piece, ref pickups);
            pickups = piece.ReevaulateChildren(pickups);
        }
    }
示例#36
0
    public void Shoot(GameObject go, DamageData data)
    {
        this.go   = go;
        this.data = data;



        /*
         *
         * //go.GetComponent<Health>().TakeDamage(data.damage_ammount);
         *
         * //Debug.DrawLine(transform.position, go.transform.position, new Color(5f,5f,5f));
         * Vector3[] positions = new Vector3[2];
         * positions[0] = transform.position;
         *
         * var posX = (transform.position.x + go.transform.position.x)/2;
         * if(posX < 0) posX *= -1;
         *
         * var posY = go.transform.position.y + 10f;
         *
         * //position2.y = data.range - position2.x;
         * //position2.y = transform.position.y + position2.y;
         *
         * //positions[1] = new Vector3(posX, posY);
         *
         * TravelData ts = go.GetComponent<MoverData>().travel;
         *
         * float timeFactor = data.maxTimeProjectileStaysInAir / ts.time;
         *
         *
         * Vector3 predictedPositionFactor = ts.difference * timeFactor;
         *
         *
         * positions[1] = go.transform.position - predictedPositionFactor;
         * //positions[1] = go.transform.position;
         */

        positionss = GeneratePath();
        draw       = true;

        GameObject newGo = Instantiate(data.projectile) as GameObject;

        //newGo.transform.SetParent(transform.parent);
        //newGo.transform.localScale = transform.localScale;
        newGo.GetComponent <Projectile>().HitTarget(positionss, data, go);
    }
示例#37
0
    protected virtual void XLDIce(DamageData damaData)
    {
        Burnt b = GetComponent <Burnt>();

        if (b)
        {
            damaData.Mediated = true;
            b.EndUp();
        }
        else
        {
            if (Random.Range(0, 1f) < damaData.IceRatio)
            {
                Freeze.Freezed(this, damaData.IceTime);
            }
        }
    }
    public void DealDamage(IDamageType damage, GameObject causer = null)
    {
        damage.ChangeHealth(this, causer);

        var data = new DamageData(damage, causer);

        if (IsAlive())
        {
            BroadcastMessage("OnReceiveDamage", data);
        }
        else
        {
            BroadcastMessage("OnDeath", data);
        }

        actual = Mathf.Clamp(actual, 0, max);
    }
    /// <summary>
    ///
    /// </summary>
    void MakeDamageRepeting()
    {
        DamageData info = new DamageData();

        info.Damage = m_RepetingDamage;
        if (RepetingDamageInfo != null)
        {
            info        = RepetingDamageInfo;
            info.Damage = m_RepetingDamage;
        }
        else
        {
            info.Direction = Vector3.zero;
            info.Cause     = DamageCause.Map;
        }
        DoDamage((int)info.Damage, "[Burn]", info.Direction, bl_GameManager.m_view, false, PhotonNetwork.LocalPlayer.GetPlayerTeam(), false);
    }
    void RecieveMessage(MessageTypes msgType, GameObject go, MessageData msgData)
    {
        switch (msgType)
        {
        case MessageTypes.DAMAGED:
            DamageData dmgData = msgData as DamageData;

            if (gameObject.tag == "Objects")
            {
                if (dmgData != null)
                {
                    ApplyDamage(dmgData.damage, go);
                }
            }
            break;
        }
    }
        private static async ETTask CommonAttack_Internal(this CommonAttackComponent self)
        {
            MessageHelper.Broadcast(new M2C_CommonAttack()
            {
                AttackCasterId = self.Entity.Id, TargetUnitId = self.CachedUnitForAttack.Id, CanAttack = true
            });
            HeroDataComponent heroDataComponent = self.Entity.GetComponent <HeroDataComponent>();
            float             attackPre         = heroDataComponent.NodeDataForHero.OriAttackPre / (1 + heroDataComponent.GetAttribute(NumericType.AttackSpeedAdd));
            float             attackSpeed       = heroDataComponent.GetAttribute(NumericType.AttackSpeed);

            //播放动画,如果动画播放完成还不能进行下一次普攻,则播放空闲动画
            await TimerComponent.Instance.WaitAsync((long)(attackPre * 1000), self.CancellationTokenSource.Token);

            DamageData damageData = ReferencePool.Acquire <DamageData>().InitData(BuffDamageTypes.PhysicalSingle | BuffDamageTypes.CommonAttack,
                                                                                  heroDataComponent.GetAttribute(NumericType.Attack), self.Entity as Unit, self.CachedUnitForAttack);

            self.Entity.GetComponent <CastDamageComponent>().BaptismDamageData(damageData);
            float finalDamage = self.CachedUnitForAttack.GetComponent <ReceiveDamageComponent>().BaptismDamageData(damageData);

            if (finalDamage >= 0)
            {
                self.CachedUnitForAttack.GetComponent <HeroDataComponent>().NumericComponent.ApplyChange(NumericType.Hp, -finalDamage);
                //抛出伤害事件,需要监听伤害的buff(比如吸血buff)需要监听此事件
                Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.ExcuteDamage}{self.Entity.Id}", damageData);
                //抛出受伤事件,需要监听受伤的Buff(例如反甲)需要监听此事件
                Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.TakeDamage}{self.CachedUnitForAttack.Id}", damageData);
            }

            CDComponent.Instance.TriggerCD(self.Entity.Id, "CommonAttack");
            CDInfo commonAttackCDInfo = CDComponent.Instance.GetCDData(self.Entity.Id, "CommonAttack");

            commonAttackCDInfo.Interval = (long)(1 / attackSpeed - attackPre) * 1000;

            List <NP_RuntimeTree> targetSkillCanvas = self.Entity.GetComponent <SkillCanvasManagerComponent>().GetSkillCanvas(10001);

            foreach (var skillCanva in targetSkillCanvas)
            {
                skillCanva.GetBlackboard().Set("CastNormalAttack", true);
                skillCanva.GetBlackboard().Set("NormalAttackUnitIds", new List <long>()
                {
                    self.CachedUnitForAttack.Id
                });
            }

            await TimerComponent.Instance.WaitAsync(commonAttackCDInfo.Interval, self.CancellationTokenSource.Token);
        }
示例#42
0
    public virtual void TakeDamage(DamageData data, Vector3 forward, Fighter owner)
    {
        if (invincible)
        {
            return;
        }

        currHealth -= data.GetDamage(); // Lose health from damage

        if (animator)
        {
            animator.SetBool("hurt", true);
        }

        hitstunning = true;
        if (data.GetDamage() > 0)
        {
            onHurt.Invoke();
        }

        //forward.y = 1f; // For knockback

        // Death
        if (currHealth <= 0)
        {
            currHealth = 0;

            if (rb)
            {
                rb.velocity = Vector3.zero;    // Cancel velocity
            }
            if (!dead)
            {
                Die();
            }

            return;
        }

        if (data.GetDamage() > 0)
        {
            rb.velocity = Vector3.zero; // Cancel velocity

            Knockback(data, forward);
        }
    }
示例#43
0
    public void OnTriggerEnter(Collider other)
    {
        var damagable = other.GetComponent <IDamageable>();

        if (damagable == null)
        {
            return;
        }

        DamageData damageData = new DamageData();

        damageData.damage = 10f;
        damageData.buff   = null;
        damageData.player = gameObject;

        damagable.TakeDamage(damageData);
    }
示例#44
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject == m_target)
        {
            DamageData dmgData = new DamageData();
            dmgData.damage = m_damage;

            MessageHandler msgHandler = m_target.GetComponent<MessageHandler>();

            if (msgHandler)
            {
                msgHandler.GiveMessage(MessageType.DAMAGED, m_launcher, dmgData);
            }
        }

        if (other.gameObject.GetComponent<BaseProjectile>() == null)
            Destroy(gameObject);
    }
示例#45
0
    public void TakeDamage(DamageData damage)
    {
        if (damage.inflictor == gameObject)
            return;

        float boomTime = Time.time;
        if (damage.type == DamageType.Explosion)
        {
            float delay = Random.Range(explosionDelayMin, explosionDelayMax);
            boomTime = Time.time + delay; // delay explosion chains

            if (explodeTime < 0) // only trigger effect on first explosion contact
                RpcPrimeForExplosion(delay);
        }

        // set explosion timer to whatever f****d it up the fastest
        if (explodeTime < 0 || explodeTime > boomTime)
            explodeTime = boomTime;
    }
示例#46
0
    public override void Fire()
    {
        if (CanFire())
        {
            float laserDistance = range;

            Ray ray = new Ray(this.transform.position, this.transform.forward);
            RaycastHit[] hits = Physics.RaycastAll(ray, range, 1 << LayerMask.NameToLayer("PhysicalObject"));

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != this.transform.parent.gameObject)
                {
                    laserDistance = Vector3.Distance(hit.collider.transform.position, this.transform.position);

                    DamageData damageData = new DamageData();

                    if (hit.collider.gameObject.tag == "Ship")
                    {
                        damageData.SetData(damage, DamageData.HitLocations.hull);
                    }
                    else if (hit.collider.gameObject.tag == "Shield")
                    {
                        damageData.SetData(damage, DamageData.HitLocations.shield);
                    }

                    hit.collider.gameObject.SendMessageUpwards("ProjectileHit", damageData, SendMessageOptions.DontRequireReceiver);
                    break;
                }
            }

            GameObject projectileObject = (GameObject)Instantiate(projectilePrefab,  this.transform.position, Quaternion.identity);
            Laser laser = projectileObject.GetComponent<Laser>();
            laser.SetLaser(this.transform.position, this.transform.position + (this.transform.forward * laserDistance));

            base.Fire ();
        }
    }
示例#47
0
    // Load Database Data
    public override void Load()
    {
        if (!dataLoaded) {
            // Clean old data
            dataRegister.Clear ();
            displayKeys.Clear ();

            // Read all entries from the table
            string query = "SELECT * FROM " + tableName;

            // If there is a row, clear it.
            if (rows != null)
                rows.Clear ();

            // Load data
            rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
            //Debug.Log("#Rows:"+rows.Count);
            // Read all the data
            int fakeId = 0;
            if ((rows != null) && (rows.Count > 0)) {
                foreach (Dictionary<string,string> data in rows) {
                    //foreach(string key in data.Keys)
                    //	Debug.Log("Name[" + key + "]:" + data[key]);
                    //return;
                    DamageData display = new DamageData ();
                    // As we don have a primary key ID field
                    fakeId++;
                    display.id = fakeId;

                    display.name = data ["name"];
                    display.resistanceStat = data ["resistance_stat"];

                    display.isLoaded = true;
                    //Debug.Log("Name:" + display.name  + "=[" +  display.id  + "]");
                    dataRegister.Add (display.id, display);
                    displayKeys.Add (display.id);
                }
                LoadSelectList ();
            }
            dataLoaded = true;
        }
    }
示例#48
0
 public override void SetDamageData(DamageData damage)
 {
     DamageAmount = damage.Damage;
 }
示例#49
0
 void Start()
 {
     State = WeaponStates.Hidden;
     if (damage == 0f) { Debug.LogError("Weapon: " + transform.name + " has 0 damage!"); }
     damageData = new DamageData(damage);
 }
示例#50
0
 public virtual bool CanBeDamagedBy(DamageData damage)
 {
     return ((BySources & ~damage.Sources) != BySources) && ((ByTypes & ~damage.Types) != ByTypes);
 }
示例#51
0
 public override void CreateNewData()
 {
     editingDisplay = new DamageData ();
     originalDisplay = new DamageData ();
     selectedDisplay = -1;
 }
示例#52
0
    public override void SetDamageData(DamageData damage)
    {
        base.SetDamageData(damage);

        this.damage.Types |= DamageTypes;
    }
示例#53
0
文件: Damage.cs 项目: Clavus/Tank
 /// <summary>
 /// Apply damage to game object if it has an IDamagable derived component.
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="amount"></param>
 /// <param name="damageType"></param>
 /// <param name="inflictor"></param>
 public static void ApplyTo(GameObject obj, int amount, DamageType damageType, GameObject inflictor)
 {
     IDamagable[] damagables = obj.GetComponents(typeof(IDamagable)).Cast<IDamagable>().ToArray();
     DamageData dm = new DamageData(amount, damageType, inflictor);
     Array.ForEach(damagables, damagable => damagable.TakeDamage(dm));
 }
 private void Die()
 {
     var data = new DamageData(Entity.GetComponent<Status>().Health, Entity.Groups, DamageTypes.None);
     Entity.GetComponent<Damageable>().Damage(data);
 }
示例#55
0
 public abstract void SetDamageData(DamageData damage);
示例#56
0
 protected virtual void OnDamaged(DamageData damage)
 {
     currentColor = Damaged;
 }
示例#57
0
 /// <summary>
 /// 將字典傳入,依json表設定資料
 /// </summary>
 public static void SetData(Dictionary<int, DamageData> _dic)
 {
     string jsonStr = Resources.Load<TextAsset>("Json/Damage").ToString();
     JsonData jd = JsonMapper.ToObject(jsonStr);
     JsonData DamageItems = jd["Damage"];
     for (int i = 0; i < DamageItems.Count; i++)
     {
         DamageData DamageData = new DamageData(DamageItems[i]);
         int id = int.Parse(DamageItems[i]["ID"].ToString());
         _dic.Add(id, DamageData);
     }
 }
示例#58
0
 public void TakeDamage(DamageData damage)
 {
     RpcPunchVehicle();
 }
示例#59
0
    // Edit or Create
    public override void DrawEditor(Rect box, bool newItem)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        // Draw the content database info
        //pos.y += ImagePack.fieldHeight;
        if (!linkedTablesLoaded) {
            LoadStatsOptions ();
            linkedTablesLoaded = true;
        }

        if (newItem) {
            ImagePack.DrawLabel (pos.x, pos.y, "Create a new Damage");
            pos.y += ImagePack.fieldHeight;
        }

        editingDisplay.name = ImagePack.DrawField (pos, "Name:", editingDisplay.name, 0.75f);
        pos.y += ImagePack.fieldHeight;
        editingDisplay.resistanceStat = ImagePack.DrawCombobox (pos, "Resistance Stat:", editingDisplay.resistanceStat, statOptions);
        pos.y += ImagePack.fieldHeight;

        pos.y += 1.5f * ImagePack.fieldHeight;
        // Save data
        pos.x -= ImagePack.innerMargin;
        pos.width /= 3;
        if (ImagePack.DrawButton (pos.x, pos.y, "Save Data")) {
            if (newItem)
                InsertEntry ();
            else
                UpdateEntry ();

            state = State.Loaded;
        }

        // Delete data
        if (!newItem) {
            pos.x += pos.width;
            if (ImagePack.DrawButton (pos.x, pos.y, "Delete Data")) {
                DeleteEntry ();
                newSelectedDisplay = 0;
                state = State.Loaded;
            }
        }

        // Cancel editing
        pos.x += pos.width;
        if (ImagePack.DrawButton (pos.x, pos.y, "Cancel")) {
            editingDisplay = originalDisplay.Clone ();
            if (newItem)
                state = State.New;
            else
                state = State.Loaded;
        }

        if (resultTimeout != -1 && resultTimeout > Time.realtimeSinceStartup) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawText(pos, result);
        }
    }
示例#60
0
 public void getDamage(DamageData damageData)
 {
     Debug.Log("Hitted: " + damageData.Value);
     //Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube) as GameObject, damageData.HittedPoint, Quaternion.identity);
 }