public bool AddBulletAndHit(VanillaCharacter source, Vector3 decalage, VanillaCharacter target) { Vector3 sourcePoint = source.FeetPosition + (source.Size.y / 2) * Vector3.UNIT_Y + decalage; Vector3 targetPoint = target.FeetPosition + target.Size.y / 2 * Vector3.UNIT_Y; Vector3 diff = targetPoint - sourcePoint; if (Math.Abs(diff.y / Cst.CUBE_SIDE) > 6) { return false; } Degree pitch = -Math.ATan2(diff.y, diff.z); Degree yaw = source.GetYaw(); if (yaw.ValueAngleUnits > 90 && yaw.ValueAngleUnits < 270) { yaw *= -1; yaw += new Degree(180); } float targetDistance = diff.Length; Ray ray = new Ray(sourcePoint + Vector3.NEGATIVE_UNIT_Z, diff.NormalisedCopy); float blockDistance = VanillaBlock.getBlockOnRay(source.getIsland(), ray, Bullet.DEFAULT_RANGE, 30); if (targetDistance > blockDistance) { return false; } SceneNode pitchNode = this.SceneMgr.RootSceneNode.CreateChildSceneNode(); pitchNode.Position = sourcePoint; pitchNode.Pitch(pitch); SceneNode yawNode = pitchNode.CreateChildSceneNode(); yawNode.Yaw(yaw); yawNode.AttachObject(StaticRectangle.CreateLine(this.SceneMgr, Vector3.ZERO, new Vector3(0, 0, 15), ColoredMaterials.YELLOW)); this.mBullets.Add(new Bullet(source, target, pitchNode, yawNode)); return true; }
public Bullet(VanillaCharacter source, SceneNode node, Vector3 forwardDir) { this.mSource = source; this.mYawNode = node; this.mRay = new Ray(this.mYawNode.Position, this.mYawNode.Orientation * Vector3.NEGATIVE_UNIT_Z); this.mForwardDir = forwardDir; this.mAccurateTest = true; }
public CollisionMgr(API.Geo.World world, VanillaCharacter charac) { this.mWorld = world; this.mCharac = charac; this.mNbrHitStage = 2 + (int)charac.Size.y / Cst.CUBE_SIDE; this.mHitRadius = charac.Size.x / 2 * COL_SIDE_MARGE; this.mHitDegrees = new Degree[NBR_HIT_POINTS]; Degree delta = 360 / this.mHitDegrees.Length; for (int i = 0; i < this.mHitDegrees.Length; i++) this.mHitDegrees[i] = i * delta; }
public bool IsCharactInBat(VanillaCharacter charac) { for (int i = 0; i < 2; i++) { Vector3 blockPos = charac.BlockPosition + Vector3.UNIT_Y * i; if (this.RealPos.x <= blockPos.x && blockPos.x < this.RealPos.x + this.Size.x && this.RealPos.y <= blockPos.y && blockPos.y < this.RealPos.y + this.Size.y && this.RealPos.z <= blockPos.z && blockPos.z < this.RealPos.z + this.Size.z) { return(true); } } return(false); }
public Bullet(VanillaCharacter source, VanillaCharacter target, SceneNode pitchNode, SceneNode yawNode) { this.mSource = source; this.mTarget = target; this.mForwardDir = Vector3.UNIT_Z; this.mAccurateTest = false; this.Speed = DEFAULT_SPEED; this.Range = DEFAULT_RANGE; this.Damage = DEFAULT_DAMAGE; this.mTarget.Hit(this.Damage, source); this.mPitchNode = pitchNode; this.mYawNode = yawNode; }
public bool AddBulletAndHit(VanillaCharacter source, Vector3 decalage, VanillaCharacter target) { Vector3 sourcePoint = source.FeetPosition + (source.Size.y / 2) * Vector3.UNIT_Y + decalage; Vector3 targetPoint = target.FeetPosition + target.Size.y / 2 * Vector3.UNIT_Y; Vector3 diff = targetPoint - sourcePoint; if (Math.Abs(diff.y / Cst.CUBE_SIDE) > 6) { return(false); } Degree pitch = -Math.ATan2(diff.y, diff.z); Degree yaw = source.GetYaw(); if (yaw.ValueAngleUnits > 90 && yaw.ValueAngleUnits < 270) { yaw *= -1; yaw += new Degree(180); } float targetDistance = diff.Length; Ray ray = new Ray(sourcePoint + Vector3.NEGATIVE_UNIT_Z, diff.NormalisedCopy); float blockDistance = VanillaBlock.getBlockOnRay(source.getIsland(), ray, Bullet.DEFAULT_RANGE, 30); if (targetDistance > blockDistance) { return(false); } SceneNode pitchNode = this.SceneMgr.RootSceneNode.CreateChildSceneNode(); pitchNode.Position = sourcePoint; pitchNode.Pitch(pitch); SceneNode yawNode = pitchNode.CreateChildSceneNode(); yawNode.Yaw(yaw); yawNode.AttachObject(StaticRectangle.CreateLine(this.SceneMgr, Vector3.ZERO, new Vector3(0, 0, 15), ColoredMaterials.YELLOW)); this.mBullets.Add(new Bullet(source, target, pitchNode, yawNode)); return(true); }
public bool IsCharactInBat(VanillaCharacter charac) { for (int i = 0; i < 2; i++) { Vector3 blockPos = charac.BlockPosition + Vector3.UNIT_Y * i; if (this.RealPos.x <= blockPos.x && blockPos.x < this.RealPos.x + this.Size.x && this.RealPos.y <= blockPos.y && blockPos.y < this.RealPos.y + this.Size.y && this.RealPos.z <= blockPos.z && blockPos.z < this.RealPos.z + this.Size.z) return true; } return false; }