コード例 #1
0
        public int GetBeamDamagePercent(int x, int z)
        {
            if (this.beamSegment >= this.ProjectileType.BeamDamageLength)
            {
                return(0);
            }
            int num = 512;

            x = x * 1024 + num;
            z = z * 1024 + num;
            int num2 = x - this.beamX;
            int num3 = z - this.beamZ;
            int num4 = (num2 * this.beamDirectionX + num3 * this.beamDirectionZ) / 1024;
            int num5 = num;
            int num6 = -num - this.beamTrail * 1024;

            if (num6 < num4 && num4 <= num5)
            {
                int x2   = this.beamX + num4 * this.beamDirectionX / 1024;
                int y    = this.beamZ + num4 * this.beamDirectionZ / 1024;
                int num7 = 2 * IntMath.FastDist(x2, y, x, z) / 1048576;
                if (num7 < this.ProjectileType.BeamWidthSegments.Length)
                {
                    return(this.ProjectileType.BeamLengthSegments[this.beamSegment] * this.ProjectileType.BeamWidthSegments[num7] / 100);
                }
            }
            return(0);
        }
コード例 #2
0
        private int HeuristicDiagonal(BoardCell fromCell, BoardCell toCell)
        {
            uint num  = (uint)(IntMath.FastDist(fromCell.X, fromCell.Z, toCell.X, toCell.Z) / 1024);
            uint num2 = 0u;

            if (num > this.maxShooterRange)
            {
                num2 = num - this.maxShooterRange;
            }
            else if (num < this.minShooterRange)
            {
                num2 = this.minShooterRange - num;
            }
            return(this.heristicMultiplier * (int)num2 * 10 / this.maxSpeed);
        }
コード例 #3
0
 private void SetProjectileTravelTime(Bullet bullet, int targetBoardX, int targetBoardZ)
 {
     if (bullet.ProjectileType.IsMultiStage)
     {
         bullet.SetTravelTime(bullet.ProjectileType.Stage1Duration + bullet.ProjectileType.StageTransitionDuration + bullet.ProjectileType.Stage2Duration);
     }
     else
     {
         int  num        = (!bullet.ProjectileType.IsBeam) ? IntMath.FastDist(bullet.SpawnBoardX, bullet.SpawnBoardZ, targetBoardX, targetBoardZ) : ((bullet.ProjectileType.BeamLifeLength - bullet.ProjectileType.BeamInitialZeroes) * 1024);
         uint travelTime = 0u;
         if (bullet.ProjectileType.MaxSpeed > 0)
         {
             int val = num / bullet.ProjectileType.MaxSpeed;
             travelTime = (uint)IntMath.Normalize(0, 1024, val, 0, 1000);
         }
         bullet.SetTravelTime(travelTime);
     }
 }
コード例 #4
0
        private void SetupBeam()
        {
            this.InternalSetBeamSegment(0);
            this.BeamTargets = new Dictionary <uint, BeamTarget>();
            this.beamOriginX = this.SpawnBoardX;
            this.beamOriginZ = this.SpawnBoardZ;
            this.GetAccurateBoardLocation(this.Owner, ref this.beamOriginX, ref this.beamOriginZ);
            this.beamX = this.beamOriginX;
            this.beamZ = this.beamOriginZ;
            int num  = this.TargetBoardX;
            int num2 = this.TargetBoardZ;

            this.GetAccurateBoardLocation(this.Target, ref num, ref num2);
            int num3 = IntMath.FastDist(this.beamOriginX, this.beamOriginZ, num, num2) / 1024;

            if (num3 == 0)
            {
                this.beamDirectionX = 1024;
                this.beamDirectionZ = 0;
            }
            else
            {
                this.beamDirectionX = (num - this.beamOriginX) * 1024 / num3;
                this.beamDirectionZ = (num2 - this.beamOriginZ) * 1024 / num3;
            }
            int beamLifeLength = this.ProjectileType.BeamLifeLength;

            num  = this.beamOriginX + this.beamDirectionX * beamLifeLength;
            num2 = this.beamOriginZ + this.beamDirectionZ * beamLifeLength;
            float num4 = 0.0029296875f;

            this.SetTargetWorldLocation(new Vector3((float)num * num4, 0f, (float)num2 * num4));
            this.SpawnBoardX  = this.beamOriginX / 1024;
            this.SpawnBoardZ  = this.beamOriginZ / 1024;
            this.TargetBoardX = num / 1024;
            this.TargetBoardZ = num2 / 1024;
            this.SetTarget(null);
            for (int i = 0; i < this.ProjectileType.BeamInitialZeroes; i++)
            {
                this.AdvanceBeam();
            }
        }
コード例 #5
0
        private void ChooseTargetLocationForDeathProjectile(SmartEntity attacker, int distance, ref int boardX, ref int boardZ, out int rotateDegrees)
        {
            int num  = boardX;
            int num2 = boardZ;
            PathingComponent pathingComp = attacker.PathingComp;

            if (pathingComp != null)
            {
                BoardCell <Entity> targetCell = pathingComp.TargetCell;
                if (targetCell != null && targetCell.Children != null)
                {
                    bool flag = false;
                    LinkedListNode <BoardItem <Entity> > linkedListNode = targetCell.Children.First;
                    while (linkedListNode != null && !flag)
                    {
                        SmartEntity target = (SmartEntity)linkedListNode.Value.Data;
                        flag           = this.TryGetBoardPositionFromTarget(target, ref num, ref num2);
                        linkedListNode = linkedListNode.Next;
                    }
                }
            }
            if (num == boardX && num2 == boardZ)
            {
                num  = 0;
                num2 = 0;
            }
            if (num == boardX && num2 == boardZ)
            {
                num++;
                num2++;
            }
            int num3 = num - boardX;
            int num4 = num2 - boardZ;
            int num5 = IntMath.FastDist(boardX, boardZ, num, num2);
            int num6 = 1024 * distance * 1;
            int num7 = num5 * 3;

            boardX       += num3 * num6 / num7;
            boardZ       += num4 * num6 / num7;
            rotateDegrees = -IntMath.Atan2Lookup(num3, num4) * 180 / 16384;
        }
コード例 #6
0
        public bool StartPathing(SmartEntity troop, SmartEntity target, TransformComponent transform, bool clampPathLength, out bool found, int rangeOverride, PathTroopParams troopParams, PathBoardParams boardParams, bool isRepathing, bool allowTroopFanning)
        {
            if (troop == null || target == null)
            {
                found = false;
                return(true);
            }
            if (this.IsPathingOngoing())
            {
                found = false;
                return(false);
            }
            boardParams.IgnoreWall = (boardParams.IgnoreWall || troop.TroopComp.TroopType.IsFlying);
            this.troop             = troop;
            this.target            = target;
            this.noWall            = boardParams.IgnoreWall;
            this.crushesWalls      = troopParams.CrushesWalls;
            this.transform         = transform;
            SmartEntity         smartEntity    = (SmartEntity)transform.Entity;
            int                 x              = transform.X;
            int                 z              = transform.Z;
            BoardCell <Entity>  cellAt         = this.boardController.Board.GetCellAt(x, z);
            BoardCell <Entity>  boardCell      = null;
            DamageableComponent damageableComp = target.DamageableComp;
            ShooterComponent    shooterComp    = troop.ShooterComp;

            this.pathingComp = smartEntity.PathingComp;
            BoardCell <Entity> boardCell2;

            if ((this.pathingComp != null & isRepathing) && this.pathingComp.TargetCell != null && this.pathingComp.EndCell != null && damageableComp != null)
            {
                boardCell2 = this.pathingComp.TargetCell;
                boardCell  = this.pathingComp.EndCell;
            }
            else if (damageableComp != null)
            {
                uint maxRange = (uint)((rangeOverride >= 0) ? rangeOverride : ((int)shooterComp.ShooterVO.MaxAttackRange));
                boardCell = damageableComp.FindAttackCell(maxRange, troopParams.TroopWidth, x, z, allowTroopFanning);
                int x2;
                int z2;
                damageableComp.GetCenterPosition(out x2, out z2);
                boardCell2 = this.boardController.Board.GetCellAt(x2, z2);
            }
            else
            {
                TransformComponent transformComp = target.TransformComp;
                boardCell2 = this.boardController.Board.GetCellAt(transformComp.CenterGridX(), transformComp.CenterGridZ());
                int  squaredDistanceToTarget = GameUtils.GetSquaredDistanceToTarget(shooterComp, target);
                bool flag = (long)squaredDistanceToTarget > (long)((ulong)shooterComp.MaxAttackRangeSquared);
                if (boardCell2 != cellAt && !troopParams.IsHealer)
                {
                    if (flag)
                    {
                        int x3          = boardCell2.X - cellAt.X;
                        int y           = boardCell2.Z - cellAt.Z;
                        int num         = IntMath.Atan2Lookup(x3, y) * 180 / 16384;
                        int targetCount = target.TroopComp.TargetCount;
                        int num2        = (int)((troopParams.MaxRange > 1u) ? (troopParams.MaxRange - 1u) : 1u);
                        for (int i = num2; i > 0; i--)
                        {
                            if (boardCell != null)
                            {
                                break;
                            }
                            int num3 = i * 3 + 1;
                            int num4 = 180 / num3;
                            for (int j = 0; j < num3; j++)
                            {
                                int num5       = (j + targetCount) % num3;
                                int twiceAngle = (num + 90 + num5 * num4) % 360 * 2;
                                int x4         = boardCell2.X + IntMath.cosLookup(twiceAngle) * i / 1024;
                                int z3         = boardCell2.Z + IntMath.sinLookup(twiceAngle) * i / 1024;
                                boardCell = this.boardController.Board.GetClampedToBoardCellAt(x4, z3, troopParams.TroopWidth);
                                if ((boardCell.Children == null || boardCell.Children.Count == 0) && boardCell.Clearance >= troopParams.TroopWidth)
                                {
                                    break;
                                }
                                boardCell = null;
                            }
                        }
                    }
                    else
                    {
                        boardCell = cellAt;
                    }
                }
                if (boardCell == null)
                {
                    boardCell = boardCell2;
                    if (boardCell.Clearance < troopParams.TroopWidth)
                    {
                        this.pathingComp = null;
                        found            = false;
                        return(false);
                    }
                }
            }
            WalkerComponent walkerComp = smartEntity.WalkerComp;

            if (this.pathingComp == null)
            {
                this.pathingComp = new PathingComponent(walkerComp.SpeedVO.MaxSpeed, target);
            }
            else
            {
                this.pathingComp.Reset();
                this.pathingComp.MaxSpeed = walkerComp.SpeedVO.MaxSpeed;
                this.pathingComp.Target   = target;
            }
            this.pathingComp.TargetCell = boardCell2;
            this.pathingComp.EndCell    = boardCell;
            int maxLength = -1;
            BattleController battleController = Service.Get <BattleController>();

            if (clampPathLength && (battleController == null || battleController.GetCurrentBattle().Type == BattleType.Pvp || battleController.GetCurrentBattle().Type == BattleType.ClientBattle))
            {
                int num6 = IntMath.FastDist(cellAt.X, cellAt.Z, boardCell2.X, boardCell2.Z);
                maxLength = 2 * num6 / 1024 + 2;
            }
            this.path = new Path(cellAt, boardCell, boardCell2, maxLength, troopParams, boardParams);
            this.UpdatePathing(out found);
            return(true);
        }