• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PhysicsCollisionEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jme3.bullet.collision.PhysicsCollisionEvent的典型用法代码示例。如果您正苦于以下问题:Java PhysicsCollisionEvent类的具体用法?Java PhysicsCollisionEvent怎么用?Java PhysicsCollisionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PhysicsCollisionEvent类属于com.jme3.bullet.collision包,在下文中一共展示了PhysicsCollisionEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    EntityId a = (EntityId)event.getObjectA().getUserObject();
    EntityId b = (EntityId)event.getObjectB().getUserObject();
    //change collision list of a
    Collision collisionComponent = entityData.getComponent(a, Collision.class);
    if(collisionComponent == null){
        collisionComponent = new Collision(new HashSet<>());
    }
    Set<EntityId> collisions = collisionComponent.getCollisions();
    collisions.add(b);
    entityData.setComponent(a, new Collision(collisions));
    //change collision list of b
    collisionComponent = entityData.getComponent(b, Collision.class);
    if(collisionComponent == null){
        collisionComponent = new Collision(new HashSet<>());
    }
    collisions = collisionComponent.getCollisions();
    collisions.add(a);
    entityData.setComponent(b, new Collision(collisions));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:22,代码来源:CollisionSystem.java


示例2: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
    if (space == null) {
        return;
    }
    if (event.getObjectA() == this || event.getObjectB() == this) {
        space.add(ghostObject);
        ghostObject.setPhysicsLocation(getPhysicsLocation(vector));
        space.addTickListener(this);
        if (effect != null && spatial.getParent() != null) {
            curTime = 0;
            effect.setLocalTranslation(spatial.getLocalTranslation());
            spatial.getParent().attachChild(effect);
            effect.emitAllParticles();
        }
        space.remove(this);
        spatial.removeFromParent();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:BombControl.java


示例3: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    boolean isA = spatial == event.getNodeA();
    boolean isB = spatial == event.getNodeB();
    if (!isA && !isB) {
        return;
    }

    Spatial other = isA ? event.getNodeB() : event.getNodeA();

    CInfluenceInterface otherInterface =
            other.getControl(CInfluenceInterface.class);

    if (otherInterface == null) {
        return;
    }

    damage(other, otherInterface);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:20,代码来源:CGrenade.java


示例4: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent pce) {
	if ( !(pce.getNodeA().getUserData("entity") instanceof Actor && pce.getNodeB().getUserData("entity") instanceof Actor) ) return;
	
	Actor first = (Actor) (pce.getNodeA().getUserData("entity"));
	Actor second = (Actor) (pce.getNodeB().getUserData("entity"));
	
	if(first instanceof Player && second instanceof Player)
		return;
	
	if(second instanceof Player)
		playerCollision(first, (Player)second, pce);
	else if(first instanceof Player)
		playerCollision((Player)first, second, pce);
	else
		mobCollision(first, second, pce);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:18,代码来源:ActorCollisionManager.java


示例5: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
/**
 * Handle collision between player characters and course points.
 * @see PhysicsCollisionListener#collision(PhysicsCollisionEvent)
 */
public void collision(PhysicsCollisionEvent event) {
  Spatial nodeA = event.getNodeA();
  Spatial nodeB = event.getNodeB();

  Spatial player = null;
  Spatial coursePoint = null;
  // Determine which node is the player.
  if (nodeA != null
      && nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
      && (Boolean) nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
             && (Boolean) nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeB;
  }
  // Determine which node is the course point.
  if (nodeA != null
      && nodeA.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeB;
  }
  // If collision is player and course point, check if the course
  // point is the player's target.
  if (player != null && coursePoint != null) {
    int playerTarget
        = player.getUserData(CoursePath.PLAYER_TARGET_POINT_ATTR);
    int courseOrder = coursePoint.getUserData(CoursePath.COURSE_ORDER_ATTR);
    if (playerTarget == courseOrder) {
      // Target reached. Set next target.
      int totalCoursePoints = coursePath.getCoursePoints().length;
      player.setUserData(CoursePath.PLAYER_TARGET_POINT_ATTR,
                         (playerTarget + 1) % totalCoursePoints);
      player.setUserData(CoursePath.PLAYER_ON_COURSE_ATTR, true);
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:44,代码来源:CoursePointCollisionListener.java


示例6: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
    if ("Box".equals(event.getNodeA().getName()) || "Box".equals(event.getNodeB().getName())) {
        if ("bullet".equals(event.getNodeA().getName()) || "bullet".equals(event.getNodeB().getName())) {
            fpsText.setText("You hit the box!");
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:TestCollisionListener.java


示例7: collide

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collide(Bone bone, PhysicsCollisionObject object, PhysicsCollisionEvent event) {

        if (object.getUserObject() != null && object.getUserObject() instanceof Geometry) {
            Geometry geom = (Geometry) object.getUserObject();
            if ("Floor".equals(geom.getName())) {
                return;
            }
        }

        ragdoll.setRagdollMode();

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:TestBoneRagdoll.java


示例8: distributeEvents

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void distributeEvents() {
    //add collision callbacks
    synchronized (collisionEvents) {
        for (Iterator<PhysicsCollisionEvent> it = collisionEvents.iterator(); it.hasNext();) {
            PhysicsCollisionEvent physicsCollisionEvent = it.next();
            for (PhysicsCollisionListener listener : collisionListeners) {
                listener.collision(physicsCollisionEvent);
            }
            //recycle events
            eventFactory.recycle(physicsCollisionEvent);
            it.remove();
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:PhysicsSpace.java


示例9: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
	if (!Gripper.this.enabled) {
		return;
	}
    if (holding.size() > 0 || !checkDigitCollision) {
        return;
    }
    Spatial nodeA = event.getNodeA();
    Spatial nodeB = event.getNodeB();

    if (nodeA == leftFinger || nodeA == rightFinger) {
        if (nodeB == leftFinger || nodeB == rightFinger || nodeB == null) {
            return;
        }
        if (nodeA == leftFinger) {
        	leftContacts.put(event.getLocalPointA().z, nodeB);
        } else {
        	rightContacts.put(event.getLocalPointA().z, nodeB);
        }
    } else if (nodeB == leftFinger) {
    	if (nodeA == null) {
    		return;
    	}
    	leftContacts.put(event.getLocalPointB().z, nodeA);
    } else if (nodeB == rightFinger) {
    	if (nodeA == null) {
    		return;
    	}
    	rightContacts.put(event.getLocalPointB().z, nodeA);
    }
    
    fingerPressure += event.getAppliedImpulse();
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:34,代码来源:Gripper.java


示例10: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
    public void collision(PhysicsCollisionEvent event) {
        if (event.getNodeA()  == collisionChecker) {
            collisionTarget = event.getNodeB();
//            LOG.log(Level.INFO, "CollisionChaseCamera,Collision target(nodeB)={0}", event.getNodeB());
        } else if (event.getNodeB() == collisionChecker) {
            collisionTarget = event.getNodeA();
//            LOG.log(Level.INFO, "CollisionChaseCamera,Collision target(nodeA)={0}", event.getNodeB());
        }
        
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:12,代码来源:CollisionChaseCamera.java


示例11: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
    if ( event.getNodeA().equals(enemyShip) && event.getNodeB().getName().indexOf("enemy") == 0){
        randomMoveVec = true;
    } else if ( event.getNodeB().equals(enemyShip) && event.getNodeA().getName().indexOf("enemy") == 0){
        randomMoveVec = true;
    } else randomMoveVec = false;
    
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:9,代码来源:NPCControl.java


示例12: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {

        
//        if ((event.getNodeA() != null && event.getNodeB() != null)){
//        Spatial A = event.getNodeA();
//        Spatial B = event.getNodeB();
////        System.out.println(A + " and " + B);
////                System.out.println(event.getLocalPointA());
//        Geometry geoBullet;
//        
//        // Destroy Bullets if they collide with Asteroids
//        if((A.getUserData("Type").equals("Bullet") ||
//           B.getUserData("Type").equals("Bullet")) &&
//               (A.getUserData("Type").equals("Asteroid") ||
//           B.getUserData("Type").equals("Asteroid"))) {
//            
//            if(A.getUserData("Type").equals("Bullet")) geoBullet = (Geometry) A;
//            else geoBullet = (Geometry) B;
//            
//            if(A.getUserData("Type").equals("Asteroid") ||
//            B.getUserData("Type").equals("Asteroid")) {
//               geoBullet.getControl(Bullet.class).destroy(); 
//            }
//          }
//        geoBullet = null;
//        A = null;
//        B = null;
//        }
        
      }
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:31,代码来源:ShipWeaponControl.java


示例13: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if (hasCollided) {
        return;
    }
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }

    PhysicsCollisionObject otherObject =
            event.getObjectA().getUserObject() == spatial
            ? event.getObjectB()
            : event.getObjectA();

    int otherCollisionGroup = otherObject.getCollisionGroup();
    if (otherCollisionGroup != CollisionGroups.CHARACTERS
            && otherCollisionGroup != CollisionGroups.WALLS
            && otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
        return;
    }
    
    // This filters away shields
    if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
        Spatial targetSpatial = (Spatial) otherObject.getUserObject();
        if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
            return;
        }
    }

    hasCollided = true;

    if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
        collidedWith = (Spatial) otherObject.getUserObject();
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:38,代码来源:ACharge.java


示例14: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }

    PhysicsCollisionObject otherObject
            = event.getObjectA().getUserObject() == spatial
                    ? event.getObjectB()
                    : event.getObjectA();

    int otherCollisionGroup = otherObject.getCollisionGroup();
    if (otherCollisionGroup != CollisionGroups.CHARACTERS
            && otherCollisionGroup != CollisionGroups.WALLS
            && otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
        return;
    }

    // This filters away shields
    if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
        Spatial targetSpatial = (Spatial) otherObject.getUserObject();
        if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
            return;
        }
    }

    if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
        Spatial otherSpatial = (Spatial) otherObject.getUserObject();
        if (!spatial.getUserData(UserData.TEAM_ID).equals(otherSpatial.getUserData(UserData.TEAM_ID))) {
            enemy = otherSpatial;
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:36,代码来源:Disc.java


示例15: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if (hasCollided) {
        return;
    }
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }
    PhysicsCollisionObject otherObject = event.getObjectA().getUserObject()
            == spatial ? event.getObjectB() : event.getObjectA();
    int otherCollisionGroup = otherObject.getCollisionGroup();
    if (otherCollisionGroup != CollisionGroups.CHARACTERS
            && otherCollisionGroup != CollisionGroups.WALLS
            && otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
        return;
    }
    if (otherObject.getUserObject() == ignored) {
        return;
    }
    // This filters away shields
    if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
        Spatial targetSpatial = (Spatial) otherObject.getUserObject();
        if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
            return;
        }
    }
    hasCollided = true;
    if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
        collidedWith = (Spatial) otherObject.getUserObject();
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:34,代码来源:CMovementForcer.java


示例16: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent e) {
	Entity a = e.getNodeA().getUserData("entity");
	Entity b = e.getNodeB().getUserData("entity");
	
	if(a instanceof TriggerZone && b instanceof Player)
		((TriggerZone)a).trigger((Player)b);
	else if(a instanceof Player && b instanceof TriggerZone)
		((TriggerZone)b).trigger((Player)a);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:11,代码来源:TriggerCollisionListener.java


示例17: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent e) {
    // Check for collision with any microDrone and a bullet
    Spatial NodeA = e.getNodeA();
    Spatial NodeB = e.getNodeB();
  
    // Check for collision with a microDrone
    if(NodeA.getName().equals("microDrone")) { //check NodeA
        if(NodeB.getName().equals("bullet")) {
            shockwave.explode(NodeA.getWorldTranslation());
            bulletAppState.getPhysicsSpace().remove(e.getNodeA());
            e.getNodeA().removeFromParent();
            megaDrone.removeMinion(NodeA);
            boomSound.setLocalTranslation(NodeA.getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MicroDrone.points);
        } else if(NodeB.getName().equals("player")) {
             //TODO: make the player move or mess up the controls a bit or score

        }
    } else if(NodeB.getName().equals("microDrone")) {  //check NodeB
        if(NodeA.getName().equals("bullet")) {
            shockwave.explode(NodeA.getWorldTranslation());
            bulletAppState.getPhysicsSpace().remove(e.getNodeB());
            e.getNodeB().removeFromParent();
            megaDrone.removeMinion(NodeB);
            boomSound.setLocalTranslation(NodeB.getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeB.getName(), MicroDrone.points);
        } else if (NodeA.getName().equals("player")) {
             //TODO: make the player move or mess up the controls a bit or score
        }
    }
    
    // Check for infiltration of the mother ship's airspace
    if(megaDrone.getGhostControl().getOverlappingObjects().contains(playerNode.getControl(CharacterControl.class))) {
        MicroDrone m = megaDrone.createMicroDrone(ball_A, player.getPhysicsLocation());
        if(m != null) {
            Vector3f v = playerNode.getWorldTranslation().
                    subtract(megaDrone.getSpatial().getWorldTranslation()).normalize();
            m.getRigidBodyControl().setPhysicsLocation(megaDrone.getSpatial().getWorldTranslation().add(v.mult(10f)));
            rootNode.attachChild(m.getGeo());
            bulletAppState.getPhysicsSpace().add(m.getRigidBodyControl()); 
        }
    }
    
    // Check for bullet hitting megaDrone
    if(NodeA.getName().equals("megaDrone") && NodeB.getName().equals("bullet")) {
        megaDrone.hit();
        if(megaDrone.gethealth() > 0) {
            megaDroneHitSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            megaDroneHitSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.hitPoint);
        } else {
            boomSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.killPoint);
        }
        
    } else if(NodeB.getName().equals("megaDrone") && NodeA.getName().equals("bullet")) {
        megaDrone.hit();
        if(megaDrone.gethealth() > 0) {
            megaDroneHitSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            megaDroneHitSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.hitPoint);
        } else {
            boomSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.killPoint);
        }
    }
    
    // Remove the bullet physics control from the world
    if(NodeA.getName().equals("bullet")) {
        bulletAppState.getPhysicsSpace().remove(e.getNodeA());
        NodeA.removeFromParent();
    } else if(NodeB.getName().equals("bullet")) {
        bulletAppState.getPhysicsSpace().remove(e.getNodeB());
        NodeB.removeFromParent();       
    }
}
 
开发者ID:melombuki,项目名称:JMonkeyGame,代码行数:81,代码来源:PlayAppState.java


示例18: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if (event.getNodeA() == null || event.getNodeB() == null) {
        return;
    }

    Spatial wallA = null;
    Spatial wallB = null;

    if (event.getObjectA().getCollisionGroup() == CollisionGroups.WALLS) {
        wallA = event.getNodeA();
    }

    if (event.getObjectB().getCollisionGroup() == CollisionGroups.WALLS) {
        wallB = event.getNodeB();
    }

    CInfluenceInterface characterA
            = event.getNodeA().getControl(CInfluenceInterface.class);
    CInfluenceInterface characterB
            = event.getNodeB().getControl(CInfluenceInterface.class);

    CProjectile projectileA = event.getNodeA().getControl(CProjectile.class);
    CProjectile projectileB = event.getNodeB().getControl(CProjectile.class);

    CSpiritStonePhysics ssPhysicsA
            = event.getNodeA().getControl(CSpiritStonePhysics.class);
    CSpiritStonePhysics ssPhysicsB
            = event.getNodeB().getControl(CSpiritStonePhysics.class);

    CSkyDrop skyDrop = event.getNodeA().getControl(CSkyDrop.class);
    if (skyDrop == null) {
        skyDrop = event.getNodeB().getControl(CSkyDrop.class);
    }
    if (skyDrop != null) {
        skyDrop.onGroundCollision();
    }

    if (projectileA != null) {
        if (projectileA.getSpatial().getParent() == null) {
            return;
        }

        if (characterB != null) {
            projectileCharacterCollision(projectileA, characterB);
        } else if (wallB != null) {
            projectileWallCollision(projectileA, wallB);
        } else if (ssPhysicsB != null) {
            projectileWallCollision(projectileA,
                    (Spatial) ssPhysicsB.getUserObject());
        }
    }
    if (projectileB != null) {
        if (projectileB.getSpatial().getParent() == null) {
            return;
        }

        if (characterA != null) {
            projectileCharacterCollision(projectileB, characterA);
        } else if (wallA != null) {
            projectileWallCollision(projectileB, wallA);
        } else if (ssPhysicsA != null) {
            projectileWallCollision(projectileB,
                    (Spatial) ssPhysicsA.getUserObject());
        }
    }

}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:69,代码来源:ServerWorldCollisionListener.java


示例19: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    boolean isA = myStone == event.getNodeA();
    boolean isB = myStone == event.getNodeB();
    if (!isA && !isB) {
        return;
    }

    Spatial other = isA ? event.getNodeB() : event.getNodeA();

    if (other == null) {
        return;
    }

    int myCollisionGroup = isA ? event.getObjectA().getCollisionGroup()
            : event.getObjectB().getCollisionGroup();

    if (myCollisionGroup == CollisionGroups.NONE) {
        return;
    }

    PhysicsCollisionObject otherPhysics = isA ? event.getObjectB()
            : event.getObjectA();
    int otherCollisionGroup = otherPhysics.getCollisionGroup();

    CSpiritStonePhysics stonePhysics =
            myStone.getControl(CSpiritStonePhysics.class);

    int stoneId = myStone.getUserData(UserData.ENTITY_ID);

    Integer otherTeamId = other.getUserData(UserData.TEAM_ID);
    if (otherTeamId == null) {
        if (stonePhysics.isPunched()) {
            world.removeEntity(stoneId, RemovalReasons.COLLISION);
        } else {
        }
        return;
    }
    int myTeamId = myStone.getUserData(UserData.TEAM_ID);

    CInfluenceInterface influenceInterface =
            other.getControl(CInfluenceInterface.class);
    if (influenceInterface != null && stonePhysics.isPunched()
            && !otherTeamId.equals(myTeamId)) {

        CActionQueue cQueue = other.getControl(CActionQueue.class);
        EntityAction currentAction = cQueue.getCurrent();

        int ownerId = myStone.getUserData(UserData.PLAYER_ID);
        int playerEntityId = PlayerData
                .getIntData(ownerId, PlayerData.ENTITY_ID);
        Spatial playerEntity = world.getEntity(playerEntityId);

        if (currentAction != null && currentAction instanceof ATrance) {
            ((ATrance) currentAction).activate(playerEntity);
            world.removeEntity(stoneId, RemovalReasons.COLLISION);
            return;
        }

        CInfluenceInterface playerInterface =
                playerEntity.getControl(CInfluenceInterface.class);

        CharacterInteraction.harm(playerInterface, influenceInterface,
                M1_COMBINATION_DAMAGE, null, true);
        world.removeEntity(stoneId, RemovalReasons.COLLISION);
    } else if (stonePhysics.isPunched()
            && otherCollisionGroup == CollisionGroups.WALLS) {
        world.removeEntity(stoneId, RemovalReasons.COLLISION);
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:71,代码来源:SpiritStoneCollisionListener.java


示例20: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    // TODO: This was copied from ACharge almost exactly. It might be time
    // to write common method for this?
    if (hasCollided) {
        return;
    }
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }

    Spatial spatial = (Spatial) ghost.getUserObject();

    PhysicsCollisionObject otherObject
            = event.getObjectA().getUserObject() == spatial
                    ? event.getObjectB()
                    : event.getObjectA();

    int otherCollisionGroup = otherObject.getCollisionGroup();
    // This filters away shields
    if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
        Spatial targetSpatial = (Spatial) otherObject.getUserObject();
        if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
            return;
        }
    }

    Spatial collidedWith = (Spatial) otherObject.getUserObject();
    EntityAction aCurrent
            = collidedWith.getControl(CActionQueue.class).getCurrent();

    if (aCurrent instanceof ATrance) {
        ((ATrance) aCurrent).activate(spatial);
        ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
        return;
    }

    hasCollided = true;

    Vector3f impulse = collidedWith.getLocalTranslation()
            .subtract(spatial.getLocalTranslation()).setY(0f)
            .normalizeLocal().multLocal(25000f);

    collidedWith.getControl(CCharacterPhysics.class).applyImpulse(impulse);
    CharacterInteraction.harm(spatial.getControl(CInfluenceInterface.class),
            collidedWith.getControl(CInfluenceInterface.class),
            100f, null, true);

    ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:53,代码来源:ElectroCharge.java



注:本文中的com.jme3.bullet.collision.PhysicsCollisionEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskImpl类代码示例发布时间:2022-05-22
下一篇:
Java StorageChannel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap