示例#1
0
        private bool IsWeaponBlocked(MuzzleLogicAccessor muzzlePoint, int mask, out RaycastHit hitInfo, GameObject[] raycastExclusionGameObjects)
        {
            Vector3 worldPosition     = muzzlePoint.GetWorldPosition();
            Vector3 barrelOriginWorld = muzzlePoint.GetBarrelOriginWorld();
            float   distance          = (worldPosition - barrelOriginWorld).magnitude + 0.1f;

            return(PhysicsUtil.RaycastWithExclusion(barrelOriginWorld, worldPosition - barrelOriginWorld, out hitInfo, distance, mask, raycastExclusionGameObjects));
        }
示例#2
0
        public void StartKickback(BaseShotEvent evt, KickbackNode weapon, [JoinByTank] TankNode tank)
        {
            KickbackComponent   kickback      = weapon.kickback;
            MuzzleLogicAccessor accessor      = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);
            Vector3             vector        = -accessor.GetFireDirectionWorld() * kickback.KickbackForce;
            Vector3             worldPosition = accessor.GetWorldPosition();

            tank.rigidbody.Rigidbody.AddForceAtPositionSafe(vector * WeaponConstants.WEAPON_FORCE_MULTIPLIER, worldPosition);
        }
示例#3
0
        public void PrepareTargetsAtFirstFrame(NodeAddedEvent e, BulletNode bulletNode, [JoinByTank] WeaponNode weaponNode)
        {
            MuzzleLogicAccessor accessor          = new MuzzleLogicAccessor(weaponNode.muzzlePoint, weaponNode.weaponInstance);
            Vector3             barrelOriginWorld = accessor.GetBarrelOriginWorld();
            TargetingData       targetingData     = BattleCache.targetingData.GetInstance().Init();

            targetingData.Origin       = barrelOriginWorld;
            targetingData.Dir          = bulletNode.bullet.Direction;
            targetingData.FullDistance = (accessor.GetWorldPosition() - barrelOriginWorld).magnitude * 1.2f;
            base.ScheduleEvent(BattleCache.targetingEvent.GetInstance().Init(targetingData), bulletNode);
            base.ScheduleEvent(BattleCache.updateBulletEvent.GetInstance().Init(targetingData), bulletNode);
        }
        public void PrepareTargeting(TargetingEvent evt, TargetingNode verticalTargeting)
        {
            TargetingData targetingData          = evt.TargetingData;
            VerticalTargetingComponent component = verticalTargeting.verticalTargeting;
            MuzzleLogicAccessor        accessor  = new MuzzleLogicAccessor(verticalTargeting.muzzlePoint, verticalTargeting.weaponInstance);

            targetingData.Origin       = accessor.GetWorldPosition();
            targetingData.Dir          = accessor.GetFireDirectionWorld();
            targetingData.FullDistance = component.WorkDistance;
            targetingData.MaxAngle     = (component.AngleUp <= component.AngleDown) ? component.AngleDown : component.AngleUp;
            base.ScheduleEvent(BattleCache.collectDirectionsEvent.GetInstance().Init(targetingData), verticalTargeting);
            base.ScheduleEvent(BattleCache.collectTargetsEvent.GetInstance().Init(targetingData), verticalTargeting);
            base.ScheduleEvent(BattleCache.targetEvaluateEvent.GetInstance().Init(targetingData), verticalTargeting);
        }