Ejemplo n.º 1
0
    void SimulateCollision(List <Unit> targets)
    {
        List <bool>          clean = new List <bool>();
        List <CollisionInfo> infos = new List <CollisionInfo>();

        //Simulate Collision:manipulate only veloity and position
        PhysicsSimulator.SimulateCollision(targets, mapBehaviour, this, clean, infos);

        for (int i = 0; i < targets.Count; i++)
        {
            if (clean[i])
            {
                PhysicsSimulator.ApplyIntegral(targets[i]);
            }
            else
            {
                PhysicsSimulator.SimulateIntegral(targets[i], Time.deltaTime, mapBehaviour);
                PhysicsSimulator.ApplyIntegral(targets[i]);
            }
        }
        for (int i = 0; i < infos.Count; i++)
        {
            CollisionInfo collision = infos[i];
            // Stop healing buff
            infos[i].me.buff    &= ~BuffFlag.BUFF_HEALING;
            infos[i].other.buff &= ~BuffFlag.BUFF_HEALING;
            UnitInfoTag unitInfoTag = FindInstance(collision.me.uuid);
            if (unitInfoTag != null)
            {
                unitInfoTag.CollisionEvent(collision);
            }
        }
        List <Unit> remains = new List <Unit>();

        for (int i = 0; i < targets.Count; i++)
        {
            Unit curUnit = targets[i];
            //死亡判定
            if (isClient == 0 && !curUnit.isDead)
            {
                if (curUnit.HP <= 0)
                {
                    curUnit.isDead = true;
                }
                else if (isOutOfBounds(curUnit))     //ユニットが範囲外に出たときの死亡判定
                {
                    curUnit.isDead = true;
                }
            }
            if (!curUnit.isDead)
            {
                remains.Add(curUnit);
            }
        }
        units = remains;
        checkGameSet();
    }