예제 #1
0
    void hitSpark(Rigidbody rbOutSide)
    {
        if (refreshTimer > Time.time)
        {
            return;
        }


        var cs = Physics.OverlapSphere(rbOutSide.position, 3.0f, UserLayer.player | UserLayer.enemyEnvelope);

        foreach (var c in cs)
        {
            var rb = c.attachedRigidbody;

            if (rb != null)
            {
                var act = rb.GetComponent <_Action3>();


                act.changeToDamageMode(null);


                var ds = new _Bullet3.DamageSourceUnit(0.0f, 1.0f, 1.0f);

                act.move.stopping(ref ds, act.speedRate);                  //キャリアーはキャラクタじゃないので例外出る
            }
        }


        refreshTimer = Time.time + 1.0f;
    }
예제 #2
0
    // ヒット処理 -----------------------

    public override void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
    {
        if (ds.damage > 0.0f)
        {
            var breaker = breakManager.getBreaker(hit.collider);


            force *= 0.005f;


            var partId = breaker.triIdToPartId(hit.triangleIndex);

            var part = structure.parts[partId];


            if (part.isShootBreakable && !breakManager.isPartBroken(partId))
            {
                if (isPartDestructed(partId, ref ds))                   //part.isDestroy( ref ds ) )
                {
                    breakDurability(part.getDurabilityWeight());


                    part.fallDownAllChildren(this, force, hit.point);
                }


                applyDamage(ref ds, part.getDamageRate(), 1);
            }
        }
    }
예제 #3
0
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
    //public override void blasted( float damage, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, int teamFlag )
    {
        var direction = (transform.position - center);          //.normalized;

        fallDownTree(pressure * 0.005f * direction, center);
    }
예제 #4
0
 public override void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
 //public override void shot( float damage, float pressure, Vector3 direction, Vector3 point, int hitIndex, Collider collider, int teamFlag )
 {
     if (ds.damage > 0.0f)
     {
         fallDownTree(force * 0.01f, hit.point);
     }
 }
예제 #5
0
파일: Hit3BodyPart.cs 프로젝트: abarabone/a
    public override void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
    {
        ds.damage *= damageRate;

        mainHitter.shot(ref ds, force, ref hit, attacker);


        rb.AddForceAtPosition(force * damageRate, hit.point, ForceMode.Impulse);
    }
예제 #6
0
파일: Hit3BodyPart.cs 프로젝트: abarabone/a
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider_, _Action3 attacker)
    {
        //	ds.damage *= damageRate;

        //	mainHitter.blasted( ref ds, pressure, boringFactor, center, radius, GetComponent<Collider>(), attacker );


        rb.AddForceAtPosition(pressure * damageRate * 20.0f * 0.75f * ((rb.position - center).normalized + Vector3.up * 0.25f), center, ForceMode.Impulse);
    }
예제 #7
0
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider c, _Action3 attacker)
    //public override void blasted( float damage, float pressure, float boringFactor, Vector3 center, float radius, Collider c, int teamFlag )
    {
        StartCoroutine(terrainOperator.adjustSphere(center, radius, boringFactor, terrain, terrainCollider, rb));
        //	terrainOperator.adjustSphere( center, radius, boringFactor, terrain, terrainCollider );


        GM.groundDustCloud.emit(center, Vector3.up, 1.0f, radius * 2.0f, Mathf.Max((int)radius, 8));
    }
예제 #8
0
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
    {
        if (ds.damage > 0.0f)
        {
            var tf = structure.tf;

            var mt = tf.localToWorldMatrix;

            var structureViewCenter = tf.InverseTransformPoint(center);              //mt.transpose.MultiplyPoint3x4( center );

            var spos = tf.position;


            var force = pressure * 0.005f;



            var hitCount = 0.0f;

            var sumDamageRate = 0.0f;


            foreach (var part in structure.parts)
            {
                if (!part.isBlastBreakable || breakManager.isPartBroken(part.partId))
                {
                    continue;
                }


                if (part.hitLocalBounds.check(structureViewCenter, radius))
                {
                    if (isPartDestructed(part.partId, ref ds))                       //part.isDestroy( ref ds ) )
                    {
                        breakDurability(part.getDurabilityWeight());


                        var v = mt.MultiplyVector(part.hitLocalBounds.structureViewCenter - structureViewCenter);

                        part.fallDownAllChildren(this, v * force, spos);
                    }


                    hitCount++;

                    sumDamageRate += part.getDamageRate();
                }
            }


            applyDamage(ref ds, sumDamageRate, hitCount);
        }
    }
예제 #9
0
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
    {
        base.blasted(ref ds, pressure, boringFactor, center, radius, collider, attacker);


        var building = (Building3)structure;


        checkMoving(building);


        building.rb.AddForceAtPosition((building.rb.worldCenterOfMass - center).normalized * pressure * 10.0f, center, ForceMode.Impulse);
    }
예제 #10
0
    public override void eroded(ref _Bullet3.DamageSourceUnit ds, Vector3 force, Vector3 hitpos, Collider collider, _Action3 attacker)
    {
        if (!attacker || attacker.targetTeam.isMate(act.attachedTeam))
        {
            if (!act.isDead)
            {
                act.move.stopping(ref ds, act.speedRate);

                armor.applyDamage(ref ds, 0.5f, 5.0f * GM.t.delta);
            }
        }

        act.rb.AddForceAtPosition(force, hitpos, ForceMode.Force);
    }
예제 #11
0
파일: Hit3Enemy.cs 프로젝트: abarabone/a
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
    {
        if (!attacker || attacker.targetTeam.isMate(act.attachedTeam))
        {
            if (!act.isDead)
            {
                armor.applyDamage(ref ds, 0.5f, 30.0f);

                act.changeToBlowingMode(attacker, 0);

                act.connection.notifyAttack(act, attacker, act.mode);
            }
        }

        //act.rb.AddExplosionForce( pressure * 20.0f, center, radius * 10.0f, 1.0f, ForceMode.Impulse );//
        act.rb.AddForceAtPosition(pressure * 20.0f * 0.75f * ((act.tfBody.position - center).normalized + Vector3.up * 0.25f), center, ForceMode.Impulse);
    }
예제 #12
0
파일: Hit3Enemy.cs 프로젝트: abarabone/a
    public override void fired(ref _Bullet3.DamageSourceUnit ds, Vector3 force, Vector3 hitpos, Collider collider, _Action3 attacker)
    {
        if (!attacker || attacker.targetTeam.isMate(act.attachedTeam))
        {
            if (!act.isDead)
            {
                act.move.stopping(ref ds, act.speedRate);

                armor.applyDamage(ref ds, 0.3f * GM.t.delta, 30.0f * GM.t.delta);

                //act.connection.notifyAttack( act, attacker, act.mode );

                act.changeToDamageMode(attacker);
            }
        }

        act.rb.AddForceAtPosition(force, hitpos, ForceMode.Force);
    }
예제 #13
0
파일: Hit3Enemy.cs 프로젝트: abarabone/a
    public override void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
    {
        if (!attacker || attacker.targetTeam.isMate(act.attachedTeam))
        {
            if (!act.isDead)
            {
                act.move.stopping(ref ds, act.speedRate);

                armor.applyDamage(ref ds, 0.0f, 30.0f);

                act.changeToDamageMode(attacker);

                act.connection.notifyAttack(act, attacker, act.mode);
            }
        }

        act.rb.AddForceAtPosition(force, hit.point, ForceMode.Impulse);
    }
예제 #14
0
    /// <summary>
    /// 特定コライダの被ヒット処理(爆発)を呼び出す。
    /// </summary>
    /// <param name="c"></param>
    /// <param name="pos"></param>
    /// <param name="impulsiveForce"></param>
    /// <param name="boringFactor"></param>
    /// <param name="radius"></param>
    void hitTo(Collider c, Vector3 pos, float impulsiveForce, float boringFactor, float radius)
    {
        var otherHitter = _Bullet3.getHitter(c);


        if (otherHitter != null)
        {
            if (otherHitter.getAct() != mainHitter.act)
            {
                var ds = new _Bullet3.DamageSourceUnit(mainHitter.act.rb.mass, 1.0f, 1.0f, 1.0f, 0.0f);

                otherHitter.blasted(ref ds, impulsiveForce, boringFactor, pos, radius, c, null);
            }
        }
        else
        {
        }
    }
예제 #15
0
        /// <summary>
        /// 移動値を弾丸ダメージ構造体によって、その場で減じる。
        /// </summary>
        /// <param name="speedRate">移動速度の実効率</param>
        public void stopping(ref _Bullet3.DamageSourceUnit ds, float speedRate)
        {
            if (0.0f >= ds.moveStoppingDamage)
            {
                return;
            }

            stopping(ds.moveStoppingDamage);


            ds.moveStoppingRate *= speedRate;            // 実行率が少ないほどダメージ大

            //var speed = speedRate * threshold;

            //var rate = ds.moveStoppingDamage > speed ? speed / ds.moveStoppingDamage : 1.0f;

            //ds.moveStoppingRate *= rate;// 実行率が0にならないとダメージを受けない
        }
예제 #16
0
    public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
    {
        var act = this.act;


        var line = act.tfBody.position - center;

        var sqrmag = line.sqrMagnitude;

        var magR = MathOpt.invSqrt(sqrmag);

        var mag = magR * sqrmag;


        //if( action.ragdoll.isRagdollMode ) action.ragdoll.rbBase.AddForceAtPosition( line * ( magR * pressure * 0.6f ) + Vector3.up * 0.4f, center, ForceMode.Impulse );
        //else act.rb.AddForceAtPosition( line * ( magR * pressure * 0.6f ) + Vector3.up * 0.4f, center, ForceMode.Impulse );
        //act.rb.AddExplosionForce( pressure, center, radius, 0.8f, ForceMode.Impulse );//
        //act.rb.AddForceAtPosition( pressure * ( act.tfBody.position - center ).normalized, center, ForceMode.Impulse );

        //if( act.ragdoll.isRagdollMode	) foreach( var i in act.ragdoll.rbs ) i.AddForceAtPosition( ( line + Vector3.up ) * ( magR * pressure ), center, ForceMode.Impulse );
        //else
        rbHit.AddForceAtPosition((line + Vector3.up) * (magR * pressure), center, ForceMode.Impulse);
        //rbHit.AddExplosionForce( pressure, center, radius, 0.8f, ForceMode.Impulse );//

        if (!attacker || attacker.targetTeam.isMate(act.attachedTeam))
        {
            if (!act.isDead)
            {
                //var level = ( act.move.speed > 1.5f ) | ( mag / radius < 0.4f ) ? (int)ds.moveStoppingDamage + 1 : 0;
                var level = act.isAvoiding ? (int)(ds.moveStoppingDamage * 0.1f + 1) : 0;

                act.changeToBlowingMode(attacker, level);


                ds.moveStoppingDamage = 0.0f;

                //armor.applyDamage( ref ds, 1.5f, 1.0f );
            }
            else
            {
                act.ragdoll.switchToRagdoll();
            }
        }
    }
예제 #17
0
        public override void applyDamage(ref _Bullet3.DamageSourceUnit ds, float takeTime, float recoveryTime)
        {
            var vaildDamage = ds.damage * (1.0f - ds.moveStoppingRate);

            var recoverableRate = 1.0f - ds.heavyRate;


            dsi = new DamageSourceInfo(ref ds);


            if (!outer.isDestroyed)
            {
                var hardDamage = vaildDamage;                // Debug.Log(hardDamage);

                outer.applyDamage(hardDamage, takeTime, recoverableRate, recoveryTime);
            }
            else                                                     // if( !inner.isDestroyed )
            {
                var softDamage = vaildDamage * ds.fragmentationRate; // Debug.Log( softDamage );

                inner.applyDamage(softDamage, takeTime, recoverableRate, recoveryTime);
            }
        }
예제 #18
0
        public override void applyDamage(ref _Bullet3.DamageSourceUnit ds, float takeTime, float recoveryTime)
        {
            var vaildDamage = ds.damage * (1.0f - ds.moveStoppingRate);

            var recoverableRate = 1.0f - ds.heavyRate;


            if (mode == enMode.ready)
            {
                var hardDamage = vaildDamage;

                skin.applyDamage(hardDamage, takeTime, recoverableRate, recoveryTime);
            }
            else if (mode == enMode.repairingSkin)
            {
                var softDamage = vaildDamage * ds.fragmentationRate;

                under.applyDamage(softDamage, takeTime, recoverableRate, recoveryTime);
            }
            else            // if( mode == enMode.repairingUnder )
            {
                under.applyDamage(under.durability * 1.5f, 0.1f);
            }
        }
예제 #19
0
 public DamageSourceInfo(ref _Bullet3.DamageSourceUnit ds)
 {
     fragmentationRate = ds.fragmentationRate;
 }
예제 #20
0
 public override void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
 {
     mainHitter.shot(ref ds, force, ref hit, attacker);
 }
예제 #21
0
    public virtual void applyDamage(ref _Bullet3.DamageSourceUnit ds, float sumDamageRate, float hitCount)
    {
        //ds.damage *= sumDamageRate / hitCount;

        checkDestruction();
    }
예제 #22
0
 public abstract void applyDamage(ref _Bullet3.DamageSourceUnit ds, float takeTime, float recoveryTime = 0.0f);
예제 #23
0
    // ダメージ系 --------------------


    public virtual bool isPartDestructed(int partId, ref _Bullet3.DamageSourceUnit ds)      //これパーツにもたせられん?
    {
        // 基底のパーツは、breakFlag によってのみ壊せるか壊せないかが決まる(一撃で壊れる)。

        return(true);
    }
예제 #24
0
    /*public void rejectHook()
     * {
     *      gameObject.layer = 0;// フック解除のためにレイヤーをゼロにしてるけど、これは混乱をまねくかもしれない…
     * }
     */



    public virtual void shot(ref _Bullet3.DamageSourceUnit ds, Vector3 force, ref RaycastHit hit, _Action3 attacker)
    {
    }
예제 #25
0
 public virtual void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker)
 {
 }
예제 #26
0
 public virtual void fired(ref _Bullet3.DamageSourceUnit ds, Vector3 force, Vector3 hitpos, Collider collider, _Action3 attacker)
 {
 }
예제 #27
0
 public override void eroded(ref _Bullet3.DamageSourceUnit ds, Vector3 force, Vector3 hitpos, Collider collider, _Action3 attacker)
 {
     mainHitter.eroded(ref ds, force, hitpos, collider, attacker);
 }
예제 #28
0
 public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider_, _Action3 attacker)
 {
     mainHitter.blasted(ref ds, pressure, boringFactor, center, radius, collider_, attacker);
 }