Exemple #1
0
        private void ImpactAreaWithSplash(Bullet bullet)
        {
            int targetBoardX = bullet.TargetBoardX;
            int targetBoardZ = bullet.TargetBoardZ;
            int splashRadius = bullet.SplashVO.SplashRadius;
            BoardCellDynamicArray     cellsInSquare = Service.BoardController.Board.GetCellsInSquare(splashRadius, targetBoardX, targetBoardZ);
            Dictionary <Entity, bool> dictionary    = new Dictionary <Entity, bool>();
            Vector3 targetWorldLocation             = bullet.TargetWorldLocation;

            for (int i = 0; i < cellsInSquare.Length; i++)
            {
                BoardCell boardCell           = cellsInSquare.Array[i];
                int       chessboardDistance  = BoardUtils.GetChessboardDistance(boardCell.X, boardCell.Z, targetBoardX, targetBoardZ);
                int       splashDamagePercent = bullet.SplashVO.GetSplashDamagePercent(chessboardDistance);
                if (splashDamagePercent != 0)
                {
                    ShieldGeneratorComponent activeShieldAffectingBoardPos = Service.ShieldController.GetActiveShieldAffectingBoardPos(boardCell.X, boardCell.Z);
                    if (activeShieldAffectingBoardPos != null && !bullet.ProjectileType.PassThroughShield && activeShieldAffectingBoardPos.Entity.Get <TeamComponent>().TeamType != bullet.OwnerTeam)
                    {
                        TransformComponent transformComponent = activeShieldAffectingBoardPos.Entity.Get <TransformComponent>();
                        Vector3            targetPos          = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), transformComponent.CenterX(), Units.BoardToWorldZ(transformComponent.CenterZ()));
                        Vector3            zero = Vector3.zero;
                        if (Service.ShieldController.GetRayShieldIntersection(targetWorldLocation, targetPos, activeShieldAffectingBoardPos, out zero))
                        {
                            bullet.SetTargetWorldLocation(zero);
                        }
                        this.ImpactTargetFromSplashDamage((SmartEntity)activeShieldAffectingBoardPos.ShieldBorderEntity, bullet, splashDamagePercent, ref dictionary);
                    }
                    else if (boardCell.Children != null)
                    {
                        LinkedListNode <BoardItem> next;
                        for (LinkedListNode <BoardItem> linkedListNode = boardCell.Children.First; linkedListNode != null; linkedListNode = next)
                        {
                            next = linkedListNode.Next;
                            this.ImpactTargetFromSplashDamage((SmartEntity)linkedListNode.Value.Data, bullet, splashDamagePercent, ref dictionary);
                        }
                    }
                }
            }
        }